diff --git a/lib/src/models/data_item.dart b/lib/src/models/data_item.dart index bb796cd..9cc731c 100644 --- a/lib/src/models/data_item.dart +++ b/lib/src/models/data_item.dart @@ -138,9 +138,8 @@ class DataItem implements TransactionBase { /// Signs the [DataItem] using the specified wallet and sets the `id` and `signature` appropriately. @override Future sign(Wallet wallet) async { - final rawSignature = await wallet.sign(this); - - _signature = encodeBytesToBase64(rawSignature); + _signature = await wallet.sign(this); + final rawSignature = decodeBase64ToBytes(_signature); final idHash = await sha256.hash(rawSignature); _id = encodeBytesToBase64(idHash.bytes); diff --git a/lib/src/models/transaction.dart b/lib/src/models/transaction.dart index 485edd6..8f86b9d 100644 --- a/lib/src/models/transaction.dart +++ b/lib/src/models/transaction.dart @@ -277,9 +277,8 @@ class Transaction implements TransactionBase { @override Future sign(Wallet wallet) async { - final rawSignature = await wallet.sign(this); - - _signature = encodeBytesToBase64(rawSignature); + _signature = await wallet.sign(this); + final rawSignature = decodeBase64ToBytes(_signature); final idHash = await sha256.hash(rawSignature); _id = encodeBytesToBase64(idHash.bytes); diff --git a/lib/src/models/wallet.dart b/lib/src/models/wallet.dart index b5a9ea8..a2ac548 100644 --- a/lib/src/models/wallet.dart +++ b/lib/src/models/wallet.dart @@ -55,8 +55,14 @@ class Wallet { await _keyPair!.extractPublicKey().then((res) => res.n)); Future getAddress() async => ownerToAddress(await getOwner()); - Future sign(TransactionBase transaction) async => rsaPssSign( - message: await transaction.getSignatureData(), keyPair: _keyPair!); + Future sign(TransactionBase transaction) async { + return encodeBytesToBase64( + await rsaPssSign( + message: await transaction.getSignatureData(), + keyPair: _keyPair!, + ), + ); + } Future signMessage(Uint8List message) async => rsaPssSign(message: message, keyPair: _keyPair!);