Skip to content

Commit

Permalink
fix: schema constructor and recovery id
Browse files Browse the repository at this point in the history
  • Loading branch information
parodyBit committed Jun 4, 2024
1 parent f5e9916 commit 1365970
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions lib/src/schema/keyed_signature.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,17 @@ class KeyedSignature extends GeneratedMessage {
factory KeyedSignature.fromAuthorization(
String authorization, String withdrawerAddress) {
PublicKeyHash pkh = PublicKeyHash.fromAddress(withdrawerAddress);
pkh.hex.padRight(32, '0');

Uint8List authBytes = stringToBytes(authorization);
int recoveryId = authBytes[0];
BigInt r = bytesToBigInt(authBytes.sublist(1, 32));
BigInt s = bytesToBigInt(authBytes.sublist(32, 63));

WitSignature signature = WitSignature(r, s);
WitPublicKey validatorKey =
WitPublicKey.recover(signature, hexToBytes(pkh.hex.padRight(32, '0')));
WitPublicKey validatorKey = WitPublicKey.recover(
signature,
hexToBytes(pkh.hex.padRight(32, '0')),
recoveryId,
);

return KeyedSignature(
publicKey: PublicKey(bytes: validatorKey.encode()),
Expand Down
4 changes: 2 additions & 2 deletions lib/src/schema/transaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ class Transaction extends GeneratedMessage {
protoName: 'Tally', subBuilder: TallyTransaction.create)
..aOM<MintTransaction>(6, 'Mint',
protoName: 'Mint', subBuilder: MintTransaction.create)
..aOM<StakeTransaction>(6, 'Mint',
..aOM<StakeTransaction>(7, 'Stake',
protoName: 'Stake', subBuilder: StakeTransaction.create)
..aOM<UnstakeTransaction>(6, 'Mint',
..aOM<UnstakeTransaction>(8, 'Unstake',
protoName: 'Unstake', subBuilder: UnstakeTransaction.create)
..hasRequiredFields = false;

Expand Down

0 comments on commit 1365970

Please sign in to comment.