forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 10
Implement BIP-EC-OPS: Elliptic Curve Operations for Bitcoin Script #109
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
Closed
ViniciusCestarii
wants to merge
6
commits into
bitcoin-inquisition:29.x
from
ViniciusCestarii:ec-ops-inq
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
847357a
feat: implement opcode OP_EC_POINT_ADD
ViniciusCestarii 385f45c
feat: export secp256k1 hazmat module
ViniciusCestarii 500d3ab
feat: implement opcode OP_EC_POINT_MUL
ViniciusCestarii 31a87dd
feat: implement opcode OP_EC_POINT_NEGATE
ViniciusCestarii 16a2a6f
feat: implement opcode OP_EC_POINT_X_COORD
ViniciusCestarii 0861f7b
feat: add ec ops test vectors
ViniciusCestarii 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "binana": [2026, 6, 0], | ||
| "deployment": "EC_OPS", | ||
| "scriptverify": true, | ||
| "scriptverify_discourage": true, | ||
| "opcodes": { | ||
| "EC_POINT_ADD": "0xbb", | ||
| "EC_POINT_MUL": "0xbc", | ||
| "EC_POINT_NEGATE": "0xbd", | ||
| "EC_POINT_X_COORD": "0xbe" | ||
| }, | ||
| "errors": { | ||
| "EC_POINT_ADD": "Using OP_EC_POINT_ADD to sum invalid points", | ||
| "EC_POINT_MUL": "Using OP_EC_POINT_MUL with invalid scalar or point", | ||
| "EC_POINT_NEGATE": "Using OP_EC_POINT_NEGATE with invalid point", | ||
| "EC_POINT_X_COORD": "Using OP_EC_POINT_X_COORD with invalid point" | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ ecdsa_example | |
| schnorr_example | ||
| ellswift_example | ||
| musig_example | ||
| hazmat_example | ||
| *.exe | ||
| *.so | ||
| *.a | ||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Note that the
.datamember ofsecp256k1_hazmat_scalartype (and any other types of the hazmat module) contains an internal representation and is thus not meant to be accessed directly by the user. The serialization API functionsecp256k1_hazmat_scalar_serializeshould be used instead (no blaming though, this should definitely be documented better in the API header in bitcoin-core/secp256k1#1635!).However, in this case it seems you don't need the hazmat API in the first place. You can simply pass
scalar.data()to the_ec_pubkey_{create,tweak}functions below, as this is already in the expected form. The following simplification seems to work fine: theStack/bitcoin-inquisition@d4c9c8cIt might still make sense to use a hazmat module consistently through for all operations (if there are notable gains in performance), but I wouldn't recommend bitcoin-core/secp256k1#1635 for that purpose currently, given its PoC state and lack of review.
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.
Hey, thank you for the feedback.
I used it specifically to satisfy the rule defined in the BIP: "Scalar values greater than or equal to the curve order n are automatically reduced modulo n." by using
secp256k1_hazmat_scalar_parse. I tried to find a way to handle this using the standard API, but I couldn't find one.Is there a recommended approach to perform this reduction modulo n using the standard secp256k1 API without relying on hazmat?