-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from zenon-network/feature/normalize
Generalize `KeyFile` to `EncryptedFile`
- Loading branch information
Showing
10 changed files
with
115 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Metadata | ||
const String baseAddressKey = 'baseAddress'; | ||
const String walletTypeKey = 'walletType'; | ||
|
||
// KeyStore | ||
const String keyStoreWalletType = 'keystore'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'dart:convert'; | ||
import 'package:test/test.dart'; | ||
import 'package:znn_sdk_dart/znn_sdk_dart.dart'; | ||
|
||
void main() async { | ||
var keyStoreString = ''' | ||
{ | ||
"crypto": { | ||
"argon2Params": { | ||
"salt": "0x5b85100f186953332faddeaf2b6d68de" | ||
}, | ||
"cipherData": "0xcfe2e1aa498229aaf78ab9634592a19c1f45ad5178ed4d530fdeef8fe528e4b78955a389e0d1e832fd0c21346b3a45cd", | ||
"cipherName": "aes-256-gcm", | ||
"kdf": "argon2.IDKey", | ||
"nonce": "0x86d6b27ba67a72238af12958" | ||
}, | ||
"timestamp": 1707418422, | ||
"version": 1 | ||
} | ||
'''; | ||
var keyStoreStringWithMeta = ''' | ||
{ | ||
"baseAddress": "z1qqjnwjjpnue8xmmpanz6csze6tcmtzzdtfsww7", | ||
"walletType": "keystore", | ||
"crypto": { | ||
"argon2Params": { | ||
"salt": "0x5b85100f186953332faddeaf2b6d68de" | ||
}, | ||
"cipherData": "0xcfe2e1aa498229aaf78ab9634592a19c1f45ad5178ed4d530fdeef8fe528e4b78955a389e0d1e832fd0c21346b3a45cd", | ||
"cipherName": "aes-256-gcm", | ||
"kdf": "argon2.IDKey", | ||
"nonce": "0x86d6b27ba67a72238af12958" | ||
}, | ||
"timestamp": 1707418422, | ||
"version": 1 | ||
} | ||
'''; | ||
var encryptedFile = EncryptedFile.fromJson(jsonDecode(keyStoreString)); | ||
test('same json', () { | ||
expect(encryptedFile.toJson(), jsonDecode(keyStoreString)); | ||
}); | ||
test('same metadata', () { | ||
expect(encryptedFile.metadata, null); | ||
}); | ||
|
||
var encryptedFileWithMeta = | ||
EncryptedFile.fromJson(jsonDecode(keyStoreStringWithMeta)); | ||
test('same json', () { | ||
expect(encryptedFileWithMeta.toJson(), jsonDecode(keyStoreStringWithMeta)); | ||
}); | ||
test('same metadata', () { | ||
expect(encryptedFileWithMeta.metadata, { | ||
"baseAddress": "z1qqjnwjjpnue8xmmpanz6csze6tcmtzzdtfsww7", | ||
"walletType": "keystore", | ||
}); | ||
}); | ||
} |