-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Split secp256k1_ec_pubkey_decompress
into in-place and copy variants
#250
Conversation
@gmaxwell suggested I check the rest of the API for cases like this; I did, it is the only one that takes an in/out pointer to a byte buffer. |
ACK |
@@ -275,6 +275,24 @@ SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_decompress( | |||
int *pubkeylen | |||
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); | |||
|
|||
/** Decompress a 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.
Just replace the old function.
I'm largely ambivalent but I suggested otherwise because most people will not assume a writable parameter can alias. |
I certainly don't mind; just wanted sipa to be aware of that argument, if he wasn't in case it changed his thinking. |
Looks good (Tested ACK), I'll update my JNI PR relative to this once the API is finalized here, too (FWIW I was having trouble the other day with this due to not realizing the buffer had to be large enough to hold the expanded pubkey if the buffer is != 65 bytes going in, this makes the (somewhat obvious) assumption more apparent). |
10105fc
to
ba46488
Compare
Updated PR to just replace the function. |
ba46488
to
e007d6e
Compare
One might wonder how one can decompress uninitialized memory. :) I think that part of the comment is a bit weird and you can probably drop it; in C I've never worried that my output needed to be initialized. |
e007d6e
to
d8d2011
Compare
Sure, changed :) |
Right now `secp256k1_ec_pubkey_decompress` takes an in/out pointer to a public key and replaces the input key with its decompressed variant. This forces users who store compressed keys in small (<65 byte) fixed size buffers (for example, the Rust bindings do this) to explicitly and wastefully copy their key to a larger buffer. [API BREAK]
d8d2011
to
210ffed
Compare
utACK. |
210ffed Use separate in and out pointers in `secp256k1_ec_pubkey_decompress` (Andrew Poelstra)
Right now
secp256k1_ec_pubkey_decompress
takes an in/out pointer toa public key and replaces the input key with its decompressed variant.
This forces users who store compressed keys in small (<65 byte) fixed
size buffers (for example, the Rust bindings do this) to explicitly
and wastefully copy their key to a larger buffer.
Add a variant
secp256k1_ec_pubkey_decompress_copy
which takes anin-pointer and an out-pointer for the public key.