-
Notifications
You must be signed in to change notification settings - Fork 20
Feat: admin subprotocol hardware wallet compatibility. #1163
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?
Feat: admin subprotocol hardware wallet compatibility. #1163
Conversation
|
Does the admin spec represent this change? |
|
I'm not sure at the moment, but I'll make sure to update the spec accordingly before marking this PR as ready for merge. |
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.
Good work! Looks clean! I just have some minor nits and feedbacks. As part of the PR, the spec docs also needs to be updated.
crates/crypto/src/threshold_signing/indexed_signatures/errors.rs
Outdated
Show resolved
Hide resolved
crates/crypto/src/threshold_signing/indexed_signatures/verification.rs
Outdated
Show resolved
Hide resolved
barakshani
left a comment
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.
Using threshold for naming is welcome!
crates/crypto/src/threshold_signing/indexed_signatures/verification.rs
Outdated
Show resolved
Hide resolved
crates/crypto/src/threshold_signing/indexed_signatures/verification.rs
Outdated
Show resolved
Hide resolved
crates/crypto/src/threshold_signing/indexed_signatures/verification.rs
Outdated
Show resolved
Hide resolved
storopoli
left a comment
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 really don't like having threshold as an u8 since it can include 0. We should use NonZero<u8> from Rust's standard library.
crates/crypto/src/threshold_signing/indexed_signatures/errors.rs
Outdated
Show resolved
Hide resolved
crates/crypto/src/threshold_signing/indexed_signatures/verification.rs
Outdated
Show resolved
Hide resolved
crates/crypto/src/threshold_signing/indexed_signatures/verification.rs
Outdated
Show resolved
Hide resolved
2d9915d to
b08f24d
Compare
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## main #1163 +/- ##
==========================================
+ Coverage 75.90% 76.17% +0.27%
==========================================
Files 528 546 +18
Lines 43905 45087 +1182
==========================================
+ Hits 33325 34345 +1020
- Misses 10580 10742 +162
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 122 files with indirect coverage changes 🚀 New features to boost your workflow:
|
…lds, and fix zkvm serde
|
Commit: b691a8e SP1 Execution Results
|
|
@prajwolrg @barakshani @storopoli Thanks for the review! For reference, here’s the signature format I used while verifying the fix: I’ll do another review pass to ensure everything is fully addressed. |
storopoli
left a comment
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.
ACK 5cf0e39
From my side OK. Note that we have other review comments. Especially the trait-based one from @barakshani.
|
|
Ooops removed from the queue. @AaronFeickert can you please take a look at the cryptographic functions in |
| /// Verifies each ECDSA signature in the set against the corresponding public key. | ||
| /// | ||
| /// This function performs the actual ECDSA signature recovery and verification. | ||
| /// It assumes the SignatureSet has already been validated for duplicates. |
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 comment seems a bit off. Is it not the case that a SignatureSet is already guaranteed not to contain duplicates? If so, this function's caller does not need to concern itself with this.
| // Check for duplicate indices | ||
| for window in signatures.windows(2) { | ||
| if window[0].index == window[1].index { | ||
| return Err(ThresholdSignatureError::DuplicateSignerIndex( | ||
| window[0].index, | ||
| )); | ||
| } | ||
| } |
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.
Recommend using an internal hash set to check for duplicates instead. It's a very clean approach.
|
|
||
| /// A set of indexed ECDSA signatures for threshold verification. | ||
| /// | ||
| /// Signatures are sorted by index and must not contain duplicates. |
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 comment seems a bit wonky. Since the constructor enforces uniqueness, why not change to indicate that a SignatureSet will not contain duplicates?
|
|
||
| /// Verifies each ECDSA signature in the set against the corresponding public key. | ||
| /// | ||
| /// This function performs the actual ECDSA signature recovery and verification. |
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 function performs the actual ECDSA signature recovery and verification. | |
| /// This function performs pk extraction from the ECDSA signature, and matches with the config. |
| RecoverableSignature::from_compact(&indexed_sig.compact(), recovery_id) | ||
| .map_err(|_| ThresholdSignatureError::InvalidSignatureFormat)?; | ||
|
|
||
| // Hardware wallets emit recoverable signatures (with a header). Recover first so we |
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.
| // Hardware wallets emit recoverable signatures (with a header). Recover first so we | |
| // Hardware wallets support recoverable public key from signatures. Recover first so we |
| /// seqno. | ||
| #[derive(Clone, Debug, Eq, PartialEq, Arbitrary, BorshDeserialize, BorshSerialize)] | ||
| /// Manages threshold signature operations for a given role and key set, with replay protection via | ||
| /// a seqno. |
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.
| /// a seqno. | |
| /// a sequence number. |
| /// This function is intentionally ECDSA-specific as part of the hardware wallet | ||
| /// compatibility design (BIP-137 format support). A trait-based abstraction | ||
| /// could be added in the future if multiple signature schemes are needed. |
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.
Convert to a comment rather than a docstring.
| actions::MultisigAction, constants::ADMINISTRATION_SUBPROTOCOL_ID, parser::SignedPayload, | ||
| }; | ||
|
|
||
| /// Creates an ECDSA recoverable signature for a message hash. |
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.
| /// Creates an ECDSA recoverable signature for a message hash. | |
| /// Creates an ECDSA signature with recoverable pk for a message hash. |
| @@ -0,0 +1,17 @@ | |||
| //! Individual ECDSA signature set for threshold signatures (M-of-N). | |||
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.
What does "individual" mean here? I think we can omit this word.
| @@ -0,0 +1,17 @@ | |||
| //! Individual ECDSA signature set for threshold signatures (M-of-N). | |||
| //! | |||
| //! This module provides types and functions for verifying a set of individual | |||
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.
ditto
|
|
||
| use super::ThresholdSignatureError; | ||
|
|
||
| /// An individual ECDSA signature with its signer index. |
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.
| /// An individual ECDSA signature with its signer index. | |
| /// An ECDSA signature with its signer index. |
Description
the admin subprotocol now uses individual
ECDSAsignatures instead ofMuSig2 aggregated Schnorrsignatures for hardware wallet compatibility.Type of Change
Notes to Reviewers
Checklist
Related Issues