-
Notifications
You must be signed in to change notification settings - Fork 907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 2978: Verify signature for address helper #3703
Issue 2978: Verify signature for address helper #3703
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking a look at this, but I agree with Steve's comment on the issue here: https://github.com/solana-labs/solana-web3.js/issues/2978#issuecomment-2436528156
I don't think we want to implement this like this, because constructing the public key is relatively expensive and we don't want to encourage code that does that repeatedly. Eg if you verify 100 signatures then you should construct the public key once and then call crypto.subtle.verify
100 times, rather than calling this function 100 times.
Could you change this to just take address: Address
and return Promise<CryptoKey>
? The actual verification would live outside. So this could just be createPublicKeyForAddress
or something like that.
In addition to land this PR we would need unit tests for the new function
It'd also be nice to update the deserialize-transaction
example to use this function since that motivated the issue and it'd demonstrate its usage nicely.
): Promise<boolean> { | ||
try { | ||
// Encode the address to bytes | ||
const addressBytes: ReadonlyUint8Array = new Uint8Array(getBase58Encoder().encode(address)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const addressBytes: ReadonlyUint8Array = new Uint8Array(getBase58Encoder().encode(address)); | |
const addressBytes = getAddressEncoder().encode(address); |
The 2.x line has moved. Can you reopen this PR at https://github.com/anza-xyz/solana-web3.js so that you get credit for the change? |
Closes solana-labs/web3.js-issue-conveyer#11
Added documentation for the verifySignatureForAddress helper function, which simplifies the process of verifying digital signatures for a given address. The function internally converts the address to a public key and verifies the signature for the associated data.