Safer tweaking API #1017

issue real-or-random opened this issue on November 16, 2021
  1. real-or-random commented at 11:32 AM on November 16, 2021: contributor

    We should have "safer" tweak functions that do the hashing automatically and include the inner point in the hash. See #1015

  2. sipa commented at 8:50 PM on December 7, 2021: contributor

    These would be BIP341-specifiek tweaking functions then that take the merkle_root as input? I believe that's sufficient to make the construction safe.

    If we had a way to have callers provide their own SHA512 functions to a context, we could also add BIP32-specific tweak functions (or if we had SHA512 hashing to the library, which feels like scope creep, but I'm also not strongly against it).

  3. real-or-random commented at 10:17 AM on January 25, 2022: contributor

    What I had in mind were rather "generic" tweak functions that for example take tag, tweak, and pk and then output pk + SHA256(tag || pk || tweak). This are safe because pk is included and my hope was that this should cover all current uses because tag and tweak are simply prefixes and suffixes to pk. But I don't think it's that simple, BIP341 hashes xonly keys and I guess some other applications hash the 33-byte pk. We could still have tweak and xonly_tweak functions, we'll need them anyway.

    And then we could provide convenience wrappers, e.g., for BIP341.

    Unfortunately BIP32 needs a different interface because HMAC-SHA512 is not a hash function but takes two inputs... We could have an abstract H(tag, pk, tweak) with implementations H(tag, pk, tweak) = SHA256(tag || pk || tweak) and H(tag, pk, tweak) = HMAC-SHA512(tag, pk || tweak).

    I don't know. If all of this is too complex in an API, we could still implement it this way under the hood.

  4. real-or-random cross-referenced this on Jul 2, 2022 from issue Expose Generator and Point at Infinity as Constants by ProofOfKeags

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-14 21:15 UTC

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