feat: verify Sr25519 wallet login signatures (ADR-014 §3 follow-up) - #84
Merged
Conversation
Closes the Sr25519 gap ADR-014 explicitly flagged as a tracked follow-up: most real Polkadot.js-generated accounts default to Sr25519, not Ed25519, so wallet login was only verifiable for a minority of real accounts until now. internal/walletlogin/sr25519.go: verifySr25519 checks a signature via github.com/ChainSafe/go-schnorrkel, using Substrate's own standard signing context (signing_context(b"substrate") -- the same constant sr25519::Pair::sign and every wallet built on that stack, Polkadot.js's extension signRaw included, already use for raw message signing, as opposed to extrinsic signing which uses a different transcript). This is not an OpenInfra-specific choice: it must match what a real wallet already produces. Login now accepts both SchemeEd25519 and SchemeSr25519, dispatching to the scheme-appropriate verifier; a scheme value that is neither still returns ErrSchemeNotSupported, unchanged for that genuinely-unknown case. Tests: sr25519_test.go proves round-trip correctness against go-schnorrkel's own sign/verify (accepts a genuine signature, rejects a wrong key, a tampered message, and malformed/undersized input). walletlogin_test.go gains a full Login() happy-path test with a real Schnorrkel-signed challenge. internal/dashboard/auth_test.go gains the same at the HTTP layer (challenge -> Sr25519-signed login -> session key), and its previous "unsupported scheme" test (which used to test Sr25519 specifically) now uses a genuinely unrecognized scheme value instead, since Sr25519 is no longer the unsupported case. Verified (control-plane/): gofmt -l .; go build ./...; go vet ./...; go test ./... -count=1 -- full workspace green against live Postgres/ Redis. Known gap, disclosed explicitly in ADR-014's implementation note: the signing-context constant is Substrate's well-established public convention and has been proven correct against go-schnorrkel's own round trip, but has not been cross-checked against a signature produced by a real wallet extension in this sandbox -- no such extension is reachable here. The browser UI doesn't offer Sr25519 login yet either way (it only has the Ed25519 local-key fallback); that needs wallet-extension integration, a separate, still-open piece of #76. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Closes the Sr25519 gap ADR-014 explicitly flagged as a tracked follow-up: most real Polkadot.js-generated accounts default to Sr25519, not Ed25519, so wallet login was only verifiable for a minority of real accounts until now. This is part of #76 — leaves the rest of #76's scope (wallet-extension client integration, operator/validator dashboard views, RBAC, pagination, accessibility, E2E tests) open.
internal/walletlogin/sr25519.goverifySr25519checks a signature viagithub.com/ChainSafe/go-schnorrkel, using Substrate's own standard signing context (signing_context(b"substrate")— the same constantsr25519::Pair::signand every wallet built on that stack, including Polkadot.js's extensionsignRaw, already use for raw message signing). Not an OpenInfra-specific choice — must match what a real wallet already produces.Loginnow accepts bothSchemeEd25519andSchemeSr25519; a genuinely unrecognized scheme value still returnsErrSchemeNotSupported.Tests
sr25519_test.goproves round-trip correctness againstgo-schnorrkel's own sign/verify.walletlogin_test.goandinternal/dashboard/auth_test.goboth gain full happy-path tests with a real Schnorrkel-signed challenge, at the service and HTTP layers respectively. The previous "unsupported scheme" HTTP test (which used to test Sr25519 specifically) now uses a genuinely unrecognized scheme value.Verified
gofmt -l .;go build ./...;go vet ./...;go test ./... -count=1— full workspace green against live Postgres/Redis.Known gap (disclosed in ADR-014's implementation note)
The signing-context constant is Substrate's well-established public convention, proven correct against
go-schnorrkel's own round trip, but not cross-checked against a signature from a real wallet extension — none reachable in this sandbox. The browser UI doesn't offer Sr25519 login yet either way (only the Ed25519 local-key fallback) — that needs wallet-extension integration, still open.🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com