-
Notifications
You must be signed in to change notification settings - Fork 275
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
key: don't use Hasher
to generate fingerprints; just use hashes
crate
#726
Conversation
85949c7
to
5e62ce4
Compare
conceptACK. You missed setting the PR title. |
5e62ce4
to
0dedcec
Compare
Hasher
to generate fingerprints; just use hashes
crate
There is no need to hash up the secret for Keypair. It already has a "fingerprint" in the form of its public key. We should just use that.
0dedcec
to
b8ac971
Compare
CI failure looks like some unrelated |
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 b8ac971
I agree with having Debug
tests in cases like this since failing to implement it correctly may lead to key leaks.
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { | ||
f.debug_struct("Keypair") | ||
.field("pubkey", &self.public_key()) | ||
.field("secret", &"<hidden>") |
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 idea.
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.
Successfully ran local tests on b8ac971.
In addition to changing
SecretKey
andSharedSecret
to usehashes
, we also unconditionally use the public half ofKeyPair
as a fingerprint, since that's always available and does not need extra deps.This patches the existing unit tests but doesn't add more. Maybe they should be removed; it's a bit weird to have unit tests for
Debug
output. But in this case we're doing some nontrivial logic and I guess we wanted to double-check that it was taking effect.I'd also like to change the manual tagged-hash implementation to use
bitcoin_hashes
methods but those are under construction rust-bitcoin/rust-bitcoin#3184 and the existing stuff is neither faster nor less code than what's currently done. So we'll live with it.Fixes #725