feat: add standalone verifySignature and verifySignatureAsync utility functions#860
Draft
gregnazario wants to merge 1 commit intomainfrom
Draft
feat: add standalone verifySignature and verifySignatureAsync utility functions#860gregnazario wants to merge 1 commit intomainfrom
gregnazario wants to merge 1 commit intomainfrom
Conversation
… functions Add unified signature verification functions that work with any supported public key type (Ed25519, Secp256k1, MultiEd25519, MultiKey) without requiring callers to know the key type in advance. - verifySignature(): synchronous verification for all non-Keyless types - verifySignatureAsync(): async verification supporting all types including Keyless - Automatically wraps raw signatures in AnySignature when needed for AnyPublicKey - Throws clear error message when Keyless key is used with sync function - 12 unit tests covering all key types, auto-wrapping, and failure cases Closes #641 Co-authored-by: Greg Nazario <greg@gnazar.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds unified
verifySignatureandverifySignatureAsyncutility functions that verify a digital signature against any supported public key type without requiring callers to know the key type in advance.Motivation: During user login flows, API services rely on wallet signatures to verify address ownership. Currently, developers must know the wallet's key type (Ed25519, Secp256k1, Keyless, etc.) to instantiate the correct
PublicKeyclass and call itsverifySignaturemethod. This creates unnecessary complexity, especially when handling multiple wallet types.What this PR adds:
verifySignature({ message, signature, publicKey })— Synchronous verification for all non-Keyless key types (Ed25519, Secp256k1, MultiEd25519, MultiKey). Throws a clear error if a Keyless key is passed.verifySignatureAsync({ aptosConfig, message, signature, publicKey })— Async verification that supports all key types including Keyless and FederatedKeyless.AnySignaturewhen anAnyPublicKeyis used, so callers don't need to manually wrap.VerifyMessageSignatureArgsandVerifyMessageSignatureAsyncArgstype interfaces.Usage:
Test Plan
Added 12 unit tests covering:
All 12 tests pass:
Build passes (
pnpm build), lint passes (pnpm check).Related Links
Closes #641
Checklist
pnpm fmt?CHANGELOG.md?