-
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
[ECDH API change] Support custom hash function #354
Conversation
I think that |
124cf05
to
d78377a
Compare
d78377a
to
750782f
Compare
Yes please :) For me it does not matter which variant it will be, but I need access to raw point coordinates (precisely only x). Actually, this variant is a bit better than mine, because the serialized point is not useful for me directly. |
src/modules/ecdh/tests_impl.h
Outdated
int ecdh_hash_function_test_fail(unsigned char *output, const unsigned char *x, const unsigned char *y) { | ||
if (1) { | ||
return 0; | ||
} |
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.
is this meant to be here?
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.
removed
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.
Concept ACK
include/secp256k1_ecdh.h
Outdated
@@ -7,21 +7,41 @@ | |||
extern "C" { | |||
# endif | |||
|
|||
/** A pointer to a function that apply hash function to a point |
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.
applies
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.
fixed
750782f
to
f35568b
Compare
How is this going on? |
Ping. |
I'll rebase and review it. |
@fanatid I'm not able to rebase your PR it seems. Can you do it? If you want, my version of the commit is at https://github.com/apoelstra/secp256k1/tree/custom-ecdh-hash-function |
ab09836
to
1dedb7b
Compare
@apoelstra rebased |
include/secp256k1_ecdh.h
Outdated
* In: x: pointer to a 32-byte x coordinate | ||
* y: pointer to a 32-byte y coordinate | ||
*/ | ||
typedef int (*secp256k1_ecdh_hash_function)( |
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'm not sure it's not a bit too much to return bool from hash function. Not very practical to have a hash function that can fail.
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 think it's reasonable. Imagine a hash function that returns the x coordinate, but only if y is odd (or has Jacobi symbol 1, or whatever the parity is).
include/secp256k1_ecdh.h
Outdated
* In: pubkey: a pointer to a secp256k1_pubkey containing an | ||
* initialized public key | ||
* privkey: a 32-byte scalar with which to multiply the point | ||
* hashfp: pointer to a hash function. If NULL, secp256k1_ecdh_hash_function_sha256 is used |
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.
awkward spacing
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.
fixed
ACK aside from spacing nit |
1dedb7b
to
59b4894
Compare
What more is required to get it merged? |
cc @sipa |
Hmm, is there no need for a data parameter that gets passed to the hashing function? This way the hash function cannot access any application dependent data, unless through a global (which is not threadsafe)? |
Is this a recommended change in this PR? |
@chfast Yeah, I think so. Our other custom hash functions take an arbitrary data parameter. |
I can add it then if @fanatid does not have time. |
59b4894
to
e96318e
Compare
e96318e
to
c8fbc3c
Compare
Pointer to arbitrary data added to hash function. |
Is this ready to be merged? |
utACK c8fbc3c |
ACK |
Can this be merged finally? |
Can it? |
c8fbc3c [ECDH API change] Allow pass arbitrary data to hash function (Kirill Fomichev) b00be65 [ECDH API change] Support custom hash function (Kirill Fomichev) Pull request description: Solve #352 Tree-SHA512: f5985874d03e976cdb3d59036af7720636ad1488da40fd3bd7881b1fb71b05036a952013d519baa84c4ce4b558bdef25c4ce76b384b297e4d0aece9e37e78a01
Solve #352