You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the deserialize-transanction example, we demonstrate how to verify the signature for a transaction
constsignedByAddress='ED1WqT2hWJLSZtj4TtTdoovmpMrr7zpkUdbfxmcJR1Fq'asAddress;constsignedBySignature=decodedTransaction.signatures[signedByAddress]!;// We encode the source address to bytesconstsourceAddressBytes=getAddressEncoder().encode(signedByAddress);// Then we create a public Ed25519 key with those bytesconstsignedByPublicKey=awaitcrypto.subtle.importKey('raw',sourceAddressBytes,'Ed25519',true,['verify']);// Now we can verify the signature using that keyconstverifiedSignature=awaitverifySignature(signedByPublicKey,signedBySignature,decodedTransaction.messageBytes);
We could write a helper function that takes as input the bytes purported to have been signed, signature to verify and address, and performs the verification for you.
This should just be the code from my example - address to bytes, verify-only public key from bytes, verifySignature call
We may want to note in documentation that you shouldn't do this if you're going to re-use the key for multiple verifications since it'll re-create the same key multiple times
Alternatively, perhaps we could create a function eg createVerifyPublicKeyForAddress that just gives you the public key for an address, to avoid that potential performance issue?
The text was updated successfully, but these errors were encountered:
I agree that we shouldn't create a method that internally constructs the public key only to throw it out, lest that be called more than once for the same address. Creating an address-to-public key helper sounds fine though. No need to use ‘verify’ in that function name, since all Ed25519 CryptoKeys have only ['verify'] usage.
Motivation
In the
deserialize-transanction
example, we demonstrate how to verify the signature for a transactionWe could write a helper function that takes as input the bytes purported to have been signed, signature to verify and address, and performs the verification for you.
Example use case
Details
verifySignature
callAlternatively, perhaps we could create a function eg
createVerifyPublicKeyForAddress
that just gives you the public key for an address, to avoid that potential performance issue?The text was updated successfully, but these errors were encountered: