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
Constructors for compressed and uncompressed ECDSA keys #592
Conversation
src/util/key.rs
Outdated
@@ -78,6 +78,23 @@ pub struct PublicKey { | |||
} | |||
|
|||
impl PublicKey { | |||
/// Constructs compressed ECDSA PublicKey from the provided generic Secp256k1 public key | |||
pub fn compressed(pk: secp256k1::PublicKey) -> PublicKey { |
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 would prefer just new
for a compressed key (same for private)
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.
Agree. May be also legacy
for uncompressed
?
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.
For uncompressed I personally haven't a preference both uncompressed or legacy are ok
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'd prefer new
and new_uncompressed
@apoelstra done |
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.
@dr-orlovsky, I think you probably forgot to push the changes 😛
@sanket1729 yeah, also needed rebase baeause of #589 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.
utACK 6e9d549
I think this can be merged if you have a good use case for it as-is. I wonder though if we shouldn't take a look at where these new functions could already be used in our library.
src/util/ecdsa.rs
Outdated
@@ -37,6 +37,23 @@ pub struct PublicKey { | |||
} | |||
|
|||
impl PublicKey { | |||
/// Constructs compressed ECDSA PublicKey from the provided generic Secp256k1 public key |
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.
Very minor nit: if it's not code, i.e. a type, I wouldn't write public key in camel case. If it's code/a type it should be formatted as such.
src/util/ecdsa.rs
Outdated
pub fn new(pk: secp256k1::PublicKey) -> PublicKey { | ||
PublicKey { | ||
compressed: true, | ||
key: pk, |
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.
Minor nit, pk
could be renamed to key which would allow to write key,
instead of key: pk,
.
@sgeisler I checked the library, updated all places (including tests and docs) where the new API can be used. Next, as a separate commit 187eae8 I added |
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.
utACK 187eae8
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 187eae8
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 187eae8
No description provided.