-
Notifications
You must be signed in to change notification settings - Fork 138
feat!: Ed25519 expanded signing key #978
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: main
Are you sure you want to change the base?
Conversation
|
@tarcieri I can put it behind a feature flag if needed. |
|
hey! just chiming it to say thank you for taking the time to develop this feature. it's greatly appreciated and we've found it useful when dealing with yubihsm-exported keys |
| #[derive(Clone, Debug)] | ||
| pub struct SigningKey(ed25519_consensus::SigningKey); | ||
| #[allow(clippy::large_enum_variant)] | ||
| #[derive(Debug)] | ||
| pub enum SigningKey { | ||
| /// Ed25519 signing key. | ||
| Ed25519(ed25519_consensus::SigningKey), | ||
| /// Ed25519 expanded signing key. | ||
| Ed25519Expanded(ExpandedSecretKey), | ||
| } |
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.
If we're going this route, I think I'd like to just migrate wholesale to ExpandedSecretKey as the internal type, rather than using an enum
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.
I migrated (back) completely to ed25519-dalek in #991.
You should now be able to implement this entirely in terms of ExpandedSecretKey rather than using this enum.
We've had many requests to leverage `ed25519-dalek`'s `ExpandedSecretKey` functionality in order to support keys exported from YubiHSMs. See #978, #891, and #742. I have been a bit wary of the implementation though, because it has always involved having both `ed25519-consensus` and `ed25519-dalek`, often with enums over multiple key types, which seems incredibly overcomplicated just to implement this feature. We originally switched to `ed25519-consensus` because `tendermint-rs` did, and it makes sense there where ZIP-215 provides consensus-critical signature verification rules that don't diverge between implementations. However that's a bit irrelevant for our purposes as this is a signing service, and ZIP-215 allows us to use whatever signing implementation we want. Now that we've vendored `tendermint-p2p` as `tmkms-p2p` we can unilaterally switch the Ed25519 implementation (back) to `ed25519-dalek`, which should make adding `ExpandedSecretKey` support much easier and avoid having to worry about two implementations. This additionally switches (back) to upstream `curve25519-dalek` so as to support X25519 as part of the SecretConnection protocol.
We've had many requests to leverage `ed25519-dalek`'s `ExpandedSecretKey` functionality in order to support keys exported from YubiHSMs. See #978, #891, and #742. I have been a bit wary of the implementation though, because it has always involved having both `ed25519-consensus` and `ed25519-dalek`, often with enums over multiple key types, which seems incredibly overcomplicated just to implement this feature. We originally switched to `ed25519-consensus` because `tendermint-rs` did, and it makes sense there where ZIP-215 provides consensus-critical signature verification rules that don't diverge between implementations. However that's a bit irrelevant for our purposes as this is a signing service, and ZIP-215 allows us to use whatever signing implementation we want. Now that we've vendored `tendermint-p2p` as `tmkms-p2p` we can unilaterally switch the Ed25519 implementation (back) to `ed25519-dalek`, which should make adding `ExpandedSecretKey` support much easier and avoid having to worry about two implementations. This additionally switches (back) to upstream `curve25519-dalek` so as to support X25519 as part of the SecretConnection protocol.
We've had many requests to leverage `ed25519-dalek`'s `ExpandedSecretKey` functionality in order to support keys exported from YubiHSMs. See #978, #891, and #742. I have been a bit wary of the implementation though, because it has always involved having both `ed25519-consensus` and `ed25519-dalek`, often with enums over multiple key types, which seems incredibly overcomplicated just to implement this feature. We originally switched to `ed25519-consensus` because `tendermint-rs` did, and it makes sense there where ZIP-215 provides consensus-critical signature verification rules that don't diverge between implementations. However that's a bit irrelevant for our purposes as this is a signing service, and ZIP-215 allows us to use whatever signing implementation we want. Now that we've vendored `tendermint-p2p` as `tmkms-p2p` we can unilaterally switch the Ed25519 implementation (back) to `ed25519-dalek`, which should make adding `ExpandedSecretKey` support much easier and avoid having to worry about two implementations. This additionally switches (back) to upstream `curve25519-dalek` so as to support X25519 as part of the SecretConnection protocol.
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.
Please update the PR to use ed25519-dalek exclusively
This PR adds support for expanded
ed25519keys, enabling compatibility with different key formats (including those exported from YubiHSM).Copilot Summary
This pull request introduces support for expanded Ed25519 signing keys in the keyring, enabling compatibility with different key formats (including those exported from YubiHSM) and providing more flexible signing capabilities. The changes refactor the
SigningKeytype to handle both standard and expanded keys.Expanded Ed25519 key support and refactoring:
SigningKeytype from a struct to an enum, allowing it to represent either a standard Ed25519 signing key (Ed25519) or an expanded Ed25519 signing key (Ed25519Expanded). This enables handling multiple key formats.SigningKeyto correctly process both key types for serialization (as_bytes), verification key conversion (verifying_key), and external key conversions (e.g., totendermint_p2p::secret_connection::PublicKey).TryFrom<&[u8]> for SigningKeyimplementation to support parsing seed keys, big-endian expanded keys, and little-endian expanded keys (such as those exported from YubiHSM), improving compatibility with external hardware and key sources.Signer<Signature>implementation to use the appropriate signing method for expanded keys (raw_sign), ensuring correct signature generation for both key types.Dependency addition:
ed25519-dalekcrate with thehazmatfeature toCargo.toml, providing the necessary cryptographic primitives for expanded Ed25519 key support.