From df9df43ff69e3a2d026616835d58f846dcdb1698 Mon Sep 17 00:00:00 2001 From: Earl Grant Reyes Date: Mon, 24 Feb 2025 20:09:09 +0800 Subject: [PATCH] chore: renamed to SeedCryptography --- libs/dart/seed_cryptography/README.md | 4 ++-- .../example/seed_cryptography_example.dart | 6 ++--- .../lib/affinidi_tdk_seed_cryptography.dart | 2 +- ...hy_service.dart => seed_cryptography.dart} | 6 ++--- .../test/seed_cryptography_test.dart | 22 +++++++++---------- 5 files changed, 20 insertions(+), 20 deletions(-) rename libs/dart/seed_cryptography/lib/src/{seed_cryptography_service.dart => seed_cryptography.dart} (96%) diff --git a/libs/dart/seed_cryptography/README.md b/libs/dart/seed_cryptography/README.md index 28b7ab3e..fd764018 100644 --- a/libs/dart/seed_cryptography/README.md +++ b/libs/dart/seed_cryptography/README.md @@ -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, ); diff --git a/libs/dart/seed_cryptography/example/seed_cryptography_example.dart b/libs/dart/seed_cryptography/example/seed_cryptography_example.dart index a86cfc1e..ca02aaf8 100644 --- a/libs/dart/seed_cryptography/example/seed_cryptography_example.dart +++ b/libs/dart/seed_cryptography/example/seed_cryptography_example.dart @@ -16,19 +16,19 @@ Future 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, ); diff --git a/libs/dart/seed_cryptography/lib/affinidi_tdk_seed_cryptography.dart b/libs/dart/seed_cryptography/lib/affinidi_tdk_seed_cryptography.dart index 285ac676..cfd55320 100644 --- a/libs/dart/seed_cryptography/lib/affinidi_tdk_seed_cryptography.dart +++ b/libs/dart/seed_cryptography/lib/affinidi_tdk_seed_cryptography.dart @@ -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'; diff --git a/libs/dart/seed_cryptography/lib/src/seed_cryptography_service.dart b/libs/dart/seed_cryptography/lib/src/seed_cryptography.dart similarity index 96% rename from libs/dart/seed_cryptography/lib/src/seed_cryptography_service.dart rename to libs/dart/seed_cryptography/lib/src/seed_cryptography.dart index cec8972f..c0a27b3a 100644 --- a/libs/dart/seed_cryptography/lib/src/seed_cryptography_service.dart +++ b/libs/dart/seed_cryptography/lib/src/seed_cryptography.dart @@ -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; diff --git a/libs/dart/seed_cryptography/test/seed_cryptography_test.dart b/libs/dart/seed_cryptography/test/seed_cryptography_test.dart index 197f96c8..342cd59b 100644 --- a/libs/dart/seed_cryptography/test/seed_cryptography_test.dart +++ b/libs/dart/seed_cryptography/test/seed_cryptography_test.dart @@ -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, ); @@ -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, ); @@ -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, ); @@ -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', ),