feat: add VerifyDER, test vector generator, and snap planning docs#176
Merged
feat: add VerifyDER, test vector generator, and snap planning docs#176
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive implementation plan for non-custodial signing via MetaMask Snaps, alongside a new utility for generating deterministic crypto test vectors to ensure cross-platform compatibility with TypeScript. The changes also include the addition of a VerifyDER function in the keys package to validate DER-encoded ECDSA signatures. Review feedback suggests improving the VerifyDER implementation by using standard library constants for the secp256k1 curve order and adopting more efficient, idiomatic signature verification methods instead of public key recovery.
3b19432 to
d2060f8
Compare
Add VerifyDER to pkg/keys for server-side validation of client-provided DER signatures before forwarding to Canton. This is needed for the non-custodial transfer execute endpoint. Add cmd/generate-test-vectors to produce deterministic crypto test vectors (SPKI DER, fingerprints, DER signatures) for cross-validation with the canton-snap TypeScript implementation. Add planning docs for the MetaMask Snap non-custodial signing approach.
Integration test that proves Canton accepts signatures from test vector keys — the same keys validated by canton-snap TypeScript cross-validation tests (T3). Test flow: register external party with test vector key → mint → prepare transfer → sign with test vector key → execute → verify balances. Run with: go run scripts/testing/test-snap-crypto.go Requires local Canton environment (bootstrap-local.sh).
71e473b to
6bea609
Compare
… verification Address review feedback: - Use crypto.S256().Params().N instead of hardcoded secp256k1 curve order - Replace recovery-based verification loop with crypto.VerifySignature for direct, more efficient public key verification
sadiq1971
approved these changes
Apr 17, 2026
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.
Summary
Phase 1 of the MetaMask Snap non-custodial signing effort (see
docs/non-custodial-snap-plan.md):VerifyDER(pkg/keys/canton_keys.go) — Server-side verification of DER-encoded ECDSA signatures against a compressed public key and pre-hashed digest. Validates DER structure, low-S normalization, and signature correctness. Needed by the transfer execute endpoint to validate client-provided signatures before forwarding to Canton.cmd/generate-test-vectors— Generates deterministic crypto test vectors (SPKI DER, fingerprints, DER signatures) from hardcoded private keys. Output is a JSON file for cross-validation with thecanton-snapTypeScript implementation. Run viamake test-vectors.docs/non-custodial-snap-plan.md(full hybrid architecture plan) anddocs/phase1-crypto-compatibility.md(detailed Phase 1 task breakdown).Test plan
TestVerifyDER— valid sig, wrong hash, wrong pubkey, malformed DER, wrong hash length, trailing bytesTestVerifyDERWithKnownVector— deterministic key produces verifiable signaturecmd/generate-test-vectorsself-verifies all generated signatures viaVerifyDERmake lintpassesgo test ./pkg/keys/passes