Implement BIP-EC-OPS: Elliptic Curve Operations for Bitcoin Script#109
Implement BIP-EC-OPS: Elliptic Curve Operations for Bitcoin Script#109ViniciusCestarii wants to merge 6 commits intobitcoin-inquisition:29.xfrom
Conversation
Expose internal functions by incorporating changes from bitcoin-core/secp256k1#1635 to make them available.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
| std::memcpy(factor_be, factor.data, 32); | ||
| std::reverse(factor_be, factor_be + 32); |
There was a problem hiding this comment.
Note that the .data member of secp256k1_hazmat_scalar type (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 function secp256k1_hazmat_scalar_serialize should 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@d4c9c8c
It 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.
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?
This is an implementation of Roasbeef's BIP for Elliptic Curve Operations, adding four new opcodes that expose low-level secp256k1 elliptic curve primitives to Tapscript.
Links