-
-
Notifications
You must be signed in to change notification settings - Fork 3
Add sr25519 signature scheme #2
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
base: master
Are you sure you want to change the base?
Add sr25519 signature scheme #2
Conversation
5f442d9 to
a95101a
Compare
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.
Pull request overview
This PR adds support for the SR25519 (Schnorr-Ristretto) signature scheme, which is commonly used in the Substrate and Polkadot ecosystems. The implementation provides comprehensive support including key generation, signing, verification, and serialization.
Key Changes
- Implements
Sr25519PrivateKeyandSr25519PublicKeytypes with full signing and verification capabilities - Integrates SR25519 into the existing
SigningPrivateKey,SigningPublicKey, andSignatureenums - Adds SR25519 to
SignatureSchemeenum for consistent key pair generation - Updates feature flags, tests, and documentation across the codebase
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/sr25519/sr25519_public_key.rs | New file implementing SR25519 public key with verification and serialization |
| src/sr25519/sr25519_private_key.rs | New file implementing SR25519 private key with signing, key derivation, and seed management |
| src/sr25519/mod.rs | Module definition and documentation for SR25519 types |
| src/signing/signing_public_key.rs | Adds Sr25519 variant to SigningPublicKey enum with CBOR encoding support |
| src/signing/signing_private_key.rs | Adds Sr25519 variant to SigningPrivateKey enum with signing and encoding support |
| src/signing/signature.rs | Adds Sr25519 signature variant with CBOR encoding and scheme detection |
| src/signing/signature_scheme.rs | Adds Sr25519 scheme with keypair generation support |
| src/signing/mod.rs | Adds SR25519 signing tests and updates conditional compilation flags |
| src/lib.rs | Exports Sr25519PrivateKey and Sr25519PublicKey types |
| src/public_keys.rs | Updates feature flags to include sr25519 |
| src/private_keys.rs | Updates feature flags to include sr25519 |
| src/keypair.rs | Updates feature flags to include sr25519 |
| Cargo.toml | Adds schnorrkel and blake2 dependencies with sr25519 feature flag, includes in default features |
| run_tests.sh | Adds test configurations for sr25519 feature combinations |
| README.md | Documents new Sr25519PrivateKey and Sr25519PublicKey types |
| CODING.md | Updates documentation checklist to include SR25519 types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #[cfg(feature = "sr25519")] | ||
| SigningPrivateKey::Sr25519(key) => { | ||
| vec![(3).into(), CBOR::to_byte_string(key.to_seed())].into() | ||
| } |
Copilot
AI
Dec 8, 2025
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.
The conditional compilation in the subsequent not(any(...)) attribute (around line 904-909) is missing feature = "sr25519". This will cause a compilation error when sr25519 is the only feature enabled, since the wildcard pattern will be marked as unreachable but won't actually be unreachable. The encoder documentation should also be updated to mention SR25519 encoding (around line 866-877).
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.
This doesn't seem to be true:
cargo build --features=sr25519
Works without any compilation issues.
Hello @wolfmcnally ,
This PR aims to add sr25119 support. This is the default signature type used by Polkadot and any Substrate-compatible blockchain. More info here