BIP174: add hash preimage fields to inputs #955

pull apoelstra wants to merge 1 commits into bitcoin:master from apoelstra:2020-07-hash-preimages-to-174 changing 1 files +24 −0
  1. apoelstra commented at 9:20 PM on July 29, 2020: contributor

    These fields are needed to solve miniscripts, which may have hash preimage challenges.

    See https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-March/016720.html for some earlier (very short) discussion.

  2. in bip-0174.mediawiki:207 in 503bfc272d outdated
     199 | @@ -200,6 +200,30 @@ The currently defined per-input types are defined as follows:
     200 |  ** Value: The UTF-8 encoded commitment message string for the proof-of-reserves.  See [[bip-0127.mediawiki|BIP 127]] for more information.
     201 |  *** <tt>{porCommitment}</tt>
     202 |  
     203 | +* Type: RIPEMD160 preimage <tt>PSBT_RIPEMD160 = 0x0a</tt>
     204 | +** Key: The hash which the preimage must hash to
     205 | +*** <tt>{0x0a}|{20-byte hash}</tt>
     206 | +** Value: The hash preimage, encoded as a byte vector, which must equal the key when run through the `RIPEMD160` algorithm
     207 | +*** <tt>{porCommitment}</tt>
    


    achow101 commented at 9:27 PM on July 29, 2020:

    Should be preimage. same in the others.

  3. in bip-0174.mediawiki:211 in 503bfc272d outdated
     206 | +** Value: The hash preimage, encoded as a byte vector, which must equal the key when run through the `RIPEMD160` algorithm
     207 | +*** <tt>{porCommitment}</tt>
     208 | +
     209 | +* Type: SHA256 preimage <tt>PSBT_SHA256 = 0x0b</tt>
     210 | +** Key: The hash which the preimage must hash to
     211 | +*** <tt>{0x0b}|{20-byte hash}</tt>
    


    achow101 commented at 9:27 PM on July 29, 2020:

    Surely you mean 32 bytes

  4. apoelstra force-pushed on Jul 29, 2020
  5. in bip-0174.mediawiki:218 in 41c987fc00 outdated
     214 | +*** <tt>{preimage}</tt>
     215 | +
     216 | +* Type: HASH160 preimage <tt>PSBT_HASH160 = 0x0c</tt>
     217 | +** Key: The hash which the preimage must hash to
     218 | +*** <tt>{0x0c}|{20-byte hash}</tt>
     219 | +** Value: The hash preimage, encoded as a byte vector, which must equal the key when run through the `SHA256` algorithm followed by the RIPEMD160 algorithm
    


    benthecarman commented at 11:30 PM on July 30, 2020:

    followed by the RIPEMD160 algorithm

    followed by the RIPEMD160 algorithm

    need the `s

  6. in bip-0174.mediawiki:204 in 41c987fc00 outdated
     197 | @@ -198,7 +198,31 @@ The currently defined per-input types are defined as follows:
     198 |  ** Key: None. The key must only contain the 1 byte type.
     199 |  *** <tt>{0x09}</tt>
     200 |  ** Value: The UTF-8 encoded commitment message string for the proof-of-reserves.  See [[bip-0127.mediawiki|BIP 127]] for more information.
     201 | -*** <tt>{porCommitment}</tt>
     202 | +*** <tt>{preimage}</tt>
     203 | +
     204 | +* Type: RIPEMD160 preimage <tt>PSBT_RIPEMD160 = 0x0a</tt>
     205 | +** Key: The hash which the preimage must hash to
    


    benthecarman commented at 11:33 PM on July 30, 2020:

    The hash which the preimage must hash to

    imo, "The resulting hash of the preimage" suffices


    apoelstra commented at 6:30 PM on July 31, 2020:

    Nice, I like this better. Fixed

  7. apoelstra force-pushed on Jul 31, 2020
  8. in bip-0174.mediawiki:201 in 2bc26060e8 outdated
     197 | @@ -198,7 +198,31 @@ The currently defined per-input types are defined as follows:
     198 |  ** Key: None. The key must only contain the 1 byte type.
     199 |  *** <tt>{0x09}</tt>
     200 |  ** Value: The UTF-8 encoded commitment message string for the proof-of-reserves.  See [[bip-0127.mediawiki|BIP 127]] for more information.
     201 | -*** <tt>{porCommitment}</tt>
     202 | +*** <tt>{preimage}</tt>
    


    achow101 commented at 6:32 PM on July 31, 2020:

    unintended change? This is an existing type.


    apoelstra commented at 5:31 PM on August 11, 2020:

    Yes. Fixed.

  9. luke-jr added the label Proposed BIP modification on Aug 1, 2020
  10. sanket1729 cross-referenced this on Aug 5, 2020 from issue Psbt: Add finalizer and extractor by sanket1729
  11. BIP174: add hash preimage fields to inputs 277be22357
  12. apoelstra force-pushed on Aug 11, 2020
  13. achow101 commented at 5:39 PM on August 11, 2020: member

    ACK 277be22357a0b51fa77113277a6cc057484a6507

  14. benthecarman approved
  15. benthecarman commented at 4:02 AM on August 12, 2020: contributor

    ACK

  16. luke-jr merged this on Aug 20, 2020
  17. luke-jr closed this on Aug 20, 2020

  18. benthecarman cross-referenced this on Aug 25, 2020 from issue Add new hash preimage PSBTInput types by benthecarman
  19. dgpv commented at 12:46 PM on August 26, 2020: contributor

    All the per-input fields have _IN_ in their names, but these new fields do not. Why ?

  20. dgpv commented at 1:03 PM on August 26, 2020: contributor

    I regret not having a watch turned on the bip repo, so I'm late with my comments, this is already merged.

    But IMO it would be better to have one new field, PSBT_IN_UNLOCKDATA, and a byte that specifies the type of unlock, PSBT_UNLOCKDATA_PREIMAGE_SHA256, etc. Or PSBT_IN_HASH_PREIMAGE and four types of hashes.

    As I understand, there's no reason to have several preimages of different type for a single input. Thus having them in different fields creates ambiguity. Should having both SHA256 and RIPEMD160 preimages be treated as error ?

  21. apoelstra commented at 1:48 PM on August 26, 2020: contributor

    @dgpv you can certainly have different kinds of preimages in one input (or multiple of a single kind of preimage)

    As for the names missing _IN_, I think we should fix this. Good catch. I will open another PR.

  22. apoelstra cross-referenced this on Aug 26, 2020 from issue BIP174: add `_IN_` to names of new hash preimage fields by apoelstra
  23. dgpv cross-referenced this on Aug 26, 2020 from issue Need to add support for new per-input PSBT fields for hash preimages by dgpv
  24. sanket1729 cross-referenced this on Aug 31, 2020 from issue Added hash Preimages to psbt by sanket1729
  25. dr-orlovsky commented at 1:41 PM on September 7, 2020: contributor

    @apoelstra, what happened to the (c) part from https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-March/016720.html ?

    (c) a map from public keys to 32-byte "tweaks" that are used in the pay-to-contract construction

    I also see no PR for it being opened...

  26. t-bast cross-referenced this on May 12, 2021 from issue Update PSBT v0 support by t-bast

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-04-14 11:10 UTC

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