BIP-352: vendor secp256k1lab and use it for reference implementation #2087

pull theStack wants to merge 4 commits into bitcoin:master from theStack:bip352-vendor-secp256k1lab changing 17 files +791 −802
  1. theStack commented at 4:18 pm on January 16, 2026: contributor

    This PR adds secp256k1lab version 1.0.0 as subtree within the bip-0352 folder [1] and takes use of it in the reference implementation. In particular, the file secp256k1.py is removed and the GE and Scalar classes are used from the secp256k1lab.secp256k1, replacing ECPubKey and ECKey, 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:

    0$ ./bip-0352/reference.py ./bip-0352/send_and_receive_test_vectors.json
    1[ ..... ]
    2All tests passed
    

    [1] added via the command $ git subtree add --prefix=bip-0352/secp256k1lab --squash https://github.com/secp256k1lab/secp256k1lab v1.0.0

  2. Squashed 'bip-0352/secp256k1lab/' content from commit 44dc4bd
    git-subtree-dir: bip-0352/secp256k1lab
    git-subtree-split: 44dc4bd893b8f03e621585e3bf255253e0e0fbfb
    75f5c07bc8
  3. Merge commit '75f5c07bc8fedab2c9f8a78b8ded3fbcabfc3674' as 'bip-0352/secp256k1lab' 005fd5850b
  4. BIP-352: take use of vendored secp256k1lab for reference implementation
    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)
    e2b50af0a6
  5. BIP-352: mention secp256k1lab in BIP text 345f762496
  6. murchandamus added the label Proposed BIP modification on Jan 16, 2026
  7. murchandamus added the label Pending acceptance on Jan 16, 2026
  8. murchandamus commented at 10:10 pm on January 16, 2026: contributor

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bips. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-01-22 09:10 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me