BIP-352: vendor secp256k1lab and use it for reference implementation#2087
Conversation
|
cc: @josibake, @RubenSomsen |
|
@theStack: Since you are an author of BIP 352, if this is ready to go, please let me know, so I can just merge it. |
Okay, I will give this another self-review within the next few days and then let you know. Also pinging some contributors who have previously reviewed a similar secp256k1lab vendoring PR for BIP-374, in case anyone wants to take a look: @nymius, @macgyver13, @stratospher, @real-or-random. |
|
Okay, marking it as in your court, please let me know when it’s back in mine. :) |
|
ACK 345f762 Tested: |
git-subtree-dir: bip-0352/secp256k1lab git-subtree-split: 44dc4bd893b8f03e621585e3bf255253e0e0fbfb
This allows to remove secp256k1.py and replace the secp256k1-specific
parts in the reference implementation. Replacement guide:
* ECKey -> Scalar
* ECKey.set(seckey_bytes) -> Scalar.from_bytes_checked(seckey_bytes)
* seckey.get_pubkey() -> seckey * G
* seckey.get_bytes() -> seckey.to_bytes()
* seckey.add(tweak_bytes) -> seckey + Scalar.from_bytes_checked(tweak_bytes)
* seckey.negate() -> seckey = -seckey
* seckey.sign_schnorr -> schnorr_sign(..., seckey.to_bytes(), ...)
* ECPubKey -> GE
* ECPubKey.set(pubkey_bytes) -> GE.from_bytes_{xonly,compressed}(pubkey_bytes)
* pubkey.get_y() % 2 == 0 -> pubkey.has_even_y()
* pubkey.get_bytes(False) -> pubkey.to_bytes_compressed()
* pubkey.get_bytes() -> pubkey.to_bytes_xonly()
* not pubkey.valid -> pubkey.infinity
* pubkey.verify_schnorr -> schnorr_verify(..., pubkey.to_bytes_xonly(), ...)
* TaggedHash -> tagged_hash
* hashlib.sha256(preimage).digest() -> hash_sha256(preimage)
345f762 to
c27b0a3
Compare
|
Rebased on master, due to a conflict after #2106 was merged. |
Did you also finish your self-review, or was this prep for the self-review? |
also fix a small grammar nit (s/are provided/is provided/)
c27b0a3 to
249bdef
Compare
Took another look today, and I consider it ready for merge. |
This PR adds secp256k1lab version 1.0.0 as subtree within the
bip-0352folder [1] and takes use of it in the reference implementation. In particular, the filesecp256k1.pyis removed and theGEandScalarclasses are used from the secp256k1lab.secp256k1, replacingECPubKeyandECKey, respectively. See the main commit message for a detailed table of replacement patterns for easier review. Usage of the library is mentioned in the BIP text to be license compliant (see #2004 (comment)).Can be tested via:
[1] added via the command
$ git subtree add --prefix=bip-0352/secp256k1lab --squash https://github.com/secp256k1lab/secp256k1lab v1.0.0