-
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
add secp256k1_ec_pubkey_cmp
method
#850
Merged
jonasnick
merged 2 commits into
bitcoin-core:master
from
apoelstra:2020-11--pubkey-comparisons
May 13, 2021
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,9 +15,9 @@ extern "C" { | |
* The exact representation of data inside is implementation defined and not | ||
* guaranteed to be portable between different platforms or versions. It is | ||
* however guaranteed to be 64 bytes in size, and can be safely copied/moved. | ||
* If you need to convert to a format suitable for storage, transmission, or | ||
* comparison, use secp256k1_xonly_pubkey_serialize and | ||
* secp256k1_xonly_pubkey_parse. | ||
* If you need to convert to a format suitable for storage, transmission, use | ||
* use secp256k1_xonly_pubkey_serialize and secp256k1_xonly_pubkey_parse. To | ||
* compare keys, use secp256k1_xonly_pubkey_cmp. | ||
*/ | ||
typedef struct { | ||
unsigned char data[64]; | ||
|
@@ -67,6 +67,21 @@ SECP256K1_API int secp256k1_xonly_pubkey_serialize( | |
const secp256k1_xonly_pubkey* pubkey | ||
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); | ||
|
||
/** Compare two x-only public keys using lexicographic order | ||
* | ||
* Returns: <0 if the first public key is less than the second | ||
* >0 if the first public key is greater than the second | ||
* 0 if the two public keys are equal | ||
* Args: ctx: a secp256k1 context object. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. non-null comments here too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary if #926 gets merged (needs more ACKs :] ) |
||
* In: pubkey1: first public key to compare | ||
* pubkey2: second public key to compare | ||
*/ | ||
SECP256K1_API int secp256k1_xonly_pubkey_cmp( | ||
const secp256k1_context* ctx, | ||
const secp256k1_xonly_pubkey* pk1, | ||
const secp256k1_xonly_pubkey* pk2 | ||
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3); | ||
|
||
/** Converts a secp256k1_pubkey into a secp256k1_xonly_pubkey. | ||
* | ||
* Returns: 1 if the public key was successfully converted | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We should add "(cannot be NULL)" here (and nit: full stops), same below
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 is implicit as per the discussion in #783 (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.
Okay, yes. Strictly speaking, we first need to add the line
Unless explicitly stated all pointer arguments must not be NULL.
in the header file (as done in #783) because currently we promise that theillegal_callback
is only called for violations explicitly mentioned in the header.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.
added that line in #926