Skip to content

Commit

Permalink
chore: renamed to SeedCryptography
Browse files Browse the repository at this point in the history
  • Loading branch information
hpelitebook745G2 committed Feb 24, 2025
1 parent d06b775 commit df9df43
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions libs/dart/seed_cryptography/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ void main() {
final seed = Uint8List.fromList([1, 2, 3, 4, 5, 6, 7, 8]);
final passphrase = 'passphrase';
final walletMaterials = await SeedCryptographyService.encryptSeed(
final walletMaterials = await SeedCryptography.encryptSeed(
seed: seed,
passphrase: passphrase,
);
print('encryptedSeed: {walletMaterials.encryptedSeed}');
print('encryptionKey: {walletMaterials.encryptionKey}');
final decryptedSeed = await SeedCryptographyService.decryptSeed(
final decryptedSeed = await SeedCryptography.decryptSeed(
encryptedSeedHex: walletMaterials.encryptedSeed,
encryptionKeyHex: walletMaterials.encryptionKey,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ Future<void> main() async {
encryptionKey: vaultSeedEncryptionKey,
);

final decryptedSeed = await SeedCryptographyService.decryptSeed(
final decryptedSeed = await SeedCryptography.decryptSeed(
encryptedSeedHex: walletMaterials.encryptedSeed,
encryptionKeyHex: walletMaterials.encryptionKey,
);
print('Decrypted Seed: ${hex.encode(decryptedSeed)}');

final walletMaterials2 = await SeedCryptographyService.encryptSeed(
final walletMaterials2 = await SeedCryptography.encryptSeed(
seed: decryptedSeed,
passphrase: passphrase,
);
print('Wallet materials vary everytime: ${walletMaterials2.toJson()}');

final decryptedSeed2 = await SeedCryptographyService.decryptSeed(
final decryptedSeed2 = await SeedCryptography.decryptSeed(
encryptedSeedHex: walletMaterials.encryptedSeed,
encryptionKeyHex: walletMaterials.encryptionKey,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
library;

export 'src/seed_cryptography_service.dart';
export 'src/seed_cryptography.dart';
export 'src/models/wallet_materials.dart';
export 'src/exceptions/seed_decryption_exception.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ import 'exceptions/seed_decryption_exception.dart';
/// final passphrase = 'mySecretPassphrase';
///
/// // Encrypt the seed
/// final walletMaterials = await SeedCryptographyService.encryptSeed(
/// final walletMaterials = await SeedCryptography.encryptSeed(
/// seed: seed,
/// passphrase: passphrase,
/// );
///
/// // Decrypt the seed
/// final decryptedSeed = await SeedCryptographyService.decryptSeed(
/// final decryptedSeed = await SeedCryptography.decryptSeed(
/// encryptedSeedHex: walletMaterials.encryptedSeed,
/// encryptionKeyHex: walletMaterials.encryptionKey,
/// );
/// ```
class SeedCryptographyService {
class SeedCryptography {
static const JS_ENCRYPTED_SEED_LENGTH = 192;
static const DART_ENCRYPTED_SEED_LENGTH = 384;

Expand Down
22 changes: 11 additions & 11 deletions libs/dart/seed_cryptography/test/seed_cryptography_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import 'package:test/test.dart';
import 'package:affinidi_tdk_seed_cryptography/affinidi_tdk_seed_cryptography.dart';

void main() {
group('SeedCryptographyService', () {
group('SeedCryptography', () {
test('encrypt then decrypt seed', () async {
final seed = Uint8List.fromList([1, 2, 3, 4, 5, 6, 7, 8]);
final passphrase = 'passphrase';

final walletMaterials = await SeedCryptographyService.encryptSeed(
final walletMaterials = await SeedCryptography.encryptSeed(
seed: seed,
passphrase: passphrase,
);

final decryptedSeed = await SeedCryptographyService.decryptSeed(
final decryptedSeed = await SeedCryptography.decryptSeed(
encryptedSeedHex: walletMaterials.encryptedSeed,
encryptionKeyHex: walletMaterials.encryptionKey,
);
Expand All @@ -30,15 +30,15 @@ void main() {
"685bec30c54bffcf54bf57f34876b4e103c6c93641f80a08a479e0e10eed6b18";
final passphrase = 'passphrase';

final decryptedSeed = await SeedCryptographyService.decryptSeed(
final decryptedSeed = await SeedCryptography.decryptSeed(
encryptedSeedHex: walletEncryptedSeed,
encryptionKeyHex: walletEncryptionKey,
);
final walletMaterials = await SeedCryptographyService.encryptSeed(
final walletMaterials = await SeedCryptography.encryptSeed(
seed: decryptedSeed,
passphrase: passphrase,
);
final decryptedSeed2 = await SeedCryptographyService.decryptSeed(
final decryptedSeed2 = await SeedCryptography.decryptSeed(
encryptedSeedHex: walletMaterials.encryptedSeed,
encryptionKeyHex: walletMaterials.encryptionKey,
);
Expand All @@ -53,15 +53,15 @@ void main() {
'6fbde8894959226724cefd4d7afd8d26c0de971afddb4f021f69a3e4badfc0ac';
final passphrase = 'passphrase';

final decryptedSeed = await SeedCryptographyService.decryptSeed(
final decryptedSeed = await SeedCryptography.decryptSeed(
encryptedSeedHex: vaultEncryptedSeed,
encryptionKeyHex: vaultSeedEncryptionKey,
);
final walletMaterials = await SeedCryptographyService.encryptSeed(
final walletMaterials = await SeedCryptography.encryptSeed(
seed: decryptedSeed,
passphrase: passphrase,
);
final decryptedSeed2 = await SeedCryptographyService.decryptSeed(
final decryptedSeed2 = await SeedCryptography.decryptSeed(
encryptedSeedHex: walletMaterials.encryptedSeed,
encryptionKeyHex: walletMaterials.encryptionKey,
);
Expand All @@ -73,13 +73,13 @@ void main() {
final seed = Uint8List.fromList([1, 2, 3, 4, 5, 6, 7, 8]);
final passphrase = 'passphrase';

final walletMaterials = await SeedCryptographyService.encryptSeed(
final walletMaterials = await SeedCryptography.encryptSeed(
seed: seed,
passphrase: passphrase,
);

expect(
() async => await SeedCryptographyService.decryptSeed(
() async => await SeedCryptography.decryptSeed(
encryptedSeedHex: walletMaterials.encryptedSeed,
encryptionKeyHex: 'wrong_key',
),
Expand Down

0 comments on commit df9df43

Please sign in to comment.