Open azbuky opened 3 years ago
Unhandled exception: Invalid argument(s): Invalid digest length (required: 1 - 64) #0 new Blake2bDigest (package:pointycastle/digests/blake2b.dart:47:7) #1 TweetNaclFast.cryptoHashOff (package:nanodart/src/crypto/tweetnacl_blake2b.dart:1576:29) #2 TweetNaclFast.cryptoSignOpen (package:nanodart/src/crypto/tweetnacl_blake2b.dart:1916:5) #3 Signature.detachedVerify (package:nanodart/src/crypto/tweetnacl_blake2b.dart:68:27) ...
Sample code
String seed = NanoSeeds.generateSeed(); // Getting private key at index-0 of this seed String privateKey = NanoKeys.seedToPrivate(seed, 0); // Getting public key from this private key String pubKey = NanoKeys.createPublicKey(privateKey); // Getting address (nano_, ban_) from this pubkey String address = NanoAccounts.createAccount(NanoAccountType.NANO, pubKey); // Validating address NanoAccounts.isValid(NanoAccountType.NANO, address); // Creating a block int accountType = NanoAccountType.NANO; String account = 'xrb_3igf8hd4sjshoibbbkeitmgkp1o6ug4xads43j6e4gqkj5xk5o83j8ja9php'; String previous = '0'; String representative = 'xrb_3p1asma84n8k84joneka776q4egm5wwru3suho9wjsfyuem8j95b3c78nw8j'; BigInt balance = BigInt.parse('1'); String link = '1EF0AD02257987B48030CC8D38511D3B2511672F33AF115AD09E18A86A8355A8'; String calculatedHash = NanoBlocks.computeStateHash( accountType, account, previous, representative, balance, link); // Signing a block final signature = NanoSignatures.signBlock(calculatedHash, privateKey); // Check signature Signature.detachedVerify( NanoHelpers.hexToBytes(calculatedHash), NanoHelpers.hexToBytes(signature), NanoHelpers.hexToBytes(pubKey), );
Sample code