BIP 371: Taproot Fields for PSBT #1139

pull achow101 wants to merge 1 commits into bitcoin:master from achow101:taproot-psbt changing 3 files +296 −0
  1. achow101 commented at 5:21 pm on July 6, 2021: member
    Specifies new field types and UTXO type semantics for Taproot PSBT fields.
  2. achow101 force-pushed on Jul 12, 2021
  3. achow101 force-pushed on Jul 12, 2021
  4. NicolasDorier commented at 1:07 am on July 15, 2021: contributor

    Seems good to me.

    I don’t think there is a need for separate field, PSBT_IN_TAP_BIP32_DERIVATION as we can stuff it in current fields. Current parser would fail, but anyway nothing can be expected to be done properly if the parser does not know PSBT_IN_TAP_BIP32_DERIVATION either. But don’t care enough to fight over that. :p

  5. NicolasDorier commented at 1:22 am on July 15, 2021: contributor
    Need to mention some fields that need to go during finalize. PSBT_IN_TAP_INTERNAL_KEY and PSBT_IN_TAP_KEY_SIG need to be emptied when finalize is called. (maybe there are others)
  6. NicolasDorier commented at 1:38 am on July 15, 2021: contributor
    isn’t PSBT_OUT_TAP_MERKLE_ROOT needed?
  7. in bip-0174.mediawiki:445 in 68e1d8b16a outdated
    440+| bip-taproot-psbt
    441+|-
    442+| Taproot Script Spend Signature
    443+| <tt>PSBT_IN_TAP_SCRIPT_SIG = 0x14</tt>
    444+| <tt><xonlypubkey> <leafhash></tt>
    445+| The 32 byte X-only public key concatenated with the 32 byte hash of the leaf it is part of.
    


    NicolasDorier commented at 1:46 am on July 15, 2021:
    the internal key or the output key?

    achow101 commented at 2:01 am on July 15, 2021:

    Neither. This field is for any key that appears in a leaf script in the taproot tree.

    I’ve added a clarification for this.

  8. achow101 commented at 2:00 am on July 15, 2021: member

    isn’t PSBT_OUT_TAP_MERKLE_ROOT needed?

    I don’t think so. I thought it might be, but could not see any situation where it would be needed but that the signer wouldn’t already be able to get it from PSBT_OUT_TAP_TREE. These output fields are really for verifying that a change output is actually change. That would require checking that the scripts the signer cares about are in the taproot tree (hence PSBT_OUT_TAP_TREE), and then compute the merkle root from the tree, combine it with the internal key, and calculate the output key. If the merkle root were available, they still couldn’t skip the steps to compute the merkle root from the tree to double check it as otherwise a merkle root could be provided that does not match the tree. So I don’t see how providing the merkle root would necessarily help.

  9. achow101 force-pushed on Jul 15, 2021
  10. achow101 commented at 2:05 am on July 15, 2021: member

    Need to mention some fields that need to go during finalize. PSBT_IN_TAP_INTERNAL_KEY and PSBT_IN_TAP_KEY_SIG need to be emptied when finalize is called. (maybe there are others)

    I believe all of the input fields can be removed after finalizing. I have mentioned this for each one.

  11. achow101 force-pushed on Jul 15, 2021
  12. in bip-0174.mediawiki:616 in 1e0712b59f outdated
    611+| bip-taproot-psbt
    612+|-
    613+| Taproot Key BIP 32 Derivation Path
    614+| <tt>PSBT_OUT_TAP_BIP32_DERIVATION = 0x07</tt>
    615+| <tt><xonlypubkey></tt>
    616+| The 32 byte X-only public key
    


    NicolasDorier commented at 2:55 am on July 15, 2021:
    output or internal?

    NicolasDorier commented at 3:05 am on July 15, 2021:
  13. NicolasDorier commented at 3:09 am on July 15, 2021: contributor
    For PSBT_IN_TAP_BIP32_DERIVATION what do we put there for a key spend? I can’t find where to put the keypath of the key spend. I guess just empty leaf?
  14. in bip-taproot-psbt.mediawiki:82 in 1e0712b59f outdated
    77+|-
    78+| Taproot Key BIP 32 Derivation Path
    79+| <tt>PSBT_IN_TAP_BIP32_DERIVATION = 0x16</tt>
    80+| <tt><xonlypubkey></tt>
    81+| A 32 byte X-only public key involved in this input. It may be the internal key, or a key present in a leaf script.
    82+| <tt><hashes len> <leaf hash>* <32-bit uint> <32-bit uint>*</tt>
    


    NicolasDorier commented at 3:25 am on July 15, 2021:
    for an internal key, I suppose hashes len is 0

    achow101 commented at 3:39 am on July 15, 2021:
    Yes. I’ve written that in.

    NicolasDorier commented at 4:42 am on July 15, 2021:
    For key spend, do you need to put the internal key with 0, or the output key with 0?

    achow101 commented at 4:46 am on July 15, 2021:

    The internal key.

    The output key is basically irrelevant for these fields.

  15. achow101 force-pushed on Jul 15, 2021
  16. NicolasDorier cross-referenced this on Jul 15, 2021 from issue Implement the new taproot specific fields in PSBT by NicolasDorier
  17. NicolasDorier commented at 10:37 am on July 15, 2021: contributor

    I created one, should be OK.

    0cHNidP8BAFUBAAAAAeDVt3US5q29vUNZcRX3LEdkDhgziyJ99ikJw2/8Dn7aAQAAAAD/////AZng9QUAAAAAGXapFHrYwgL4Q4eR3dKl1LYsqM39kgFhiKwAAAAAAAEBKwDh9QUAAAAAIlEg1iv7bdF2yzf4CpjhDnVXLsIfNrt5+1jrtX/uL1EgulwBGCAOu6VEp72Zgvt0Llb+yL7hR/3UAFTVdjZ8OO41pIs0WwEXIFMl9e2ZwmDOoNae5zPxtJO+bHS2kdFJeO3BVG6nFgeWARNACj/rUgWiFLb9ZWOdt03rW1sjiGDBiVKORiTD8CIA99SwCwkbA5/2TW/HAxKpSgISzX+B+WhQ/MHYSbete4IqBCEW1iv7bdF2yzf4CpjhDnVXLsIfNrt5+1jrtX/uL1Egulw5ASfq5OMcd3GONPFnf3KVRgqurQ8fvNI+EMf01mCCAHmxEjRWeFYAAIAAAACAAAAAgAAAAAAAAAAAAAA=
    
     0{
     1  "fee": "0.00000103 BTC",
     2  "feeRate": "1 Sat/B",
     3  "tx": {
     4    "hash": "0ffc6c3faeef6228485290b60068803bd5d46f2c44d0d3aaaff833b3f313066e",
     5    "ver": 1,
     6    "vin_sz": 1,
     7    "vout_sz": 1,
     8    "lock_time": 0,
     9    "size": 85,
    10    "in": [
    11      {
    12        "prev_out": {
    13          "hash": "da7e0efc6fc30929f67d228b33180e64472cf715715943bdbdade61275b7d5e0",
    14          "n": 1
    15        },
    16        "scriptSig": ""
    17      }
    18    ],
    19    "out": [
    20      {
    21        "value": "0.99999897",
    22        "scriptPubKey": "OP_DUP OP_HASH160 7ad8c202f8438791ddd2a5d4b62ca8cdfd920161 OP_EQUALVERIFY OP_CHECKSIG"
    23      }
    24    ]
    25  },
    26  "inputs": [
    27    {
    28      "index": 0,
    29      "taproot_internal_key": "5325f5ed99c260cea0d69ee733f1b493be6c74b691d14978edc1546ea7160796",
    30      "taproot_merkle_root": "5b348ba435ee387c3676d55400d4fd47e1bec8fe562e74fb8299bda744a5bb0e",
    31      "taproot_key_signature": "0a3feb5205a214b6fd65639db74deb5b5b238860c189528e4624c3f02200f7d4b00b091b039ff64d6fc70312a94a0212cd7f81f96850fcc1d849b7ad7b822a04",
    32      "partial_signatures": {},
    33      "witness_utxo": {
    34        "value": "1.00000000",
    35        "scriptPubKey": "1 d62bfb6dd176cb37f80a98e10e75572ec21f36bb79fb58ebb57fee2f5120ba5c"
    36      },
    37      "bip32_derivs": [],
    38      "bip32_taproot_derivs": [
    39        {
    40          "pubkey": "d62bfb6dd176cb37f80a98e10e75572ec21f36bb79fb58ebb57fee2f5120ba5c",
    41          "master_fingerprint": "12345678",
    42          "path": "86'/0'/0'/0/0",
    43          "leaf_hashes": [
    44            "b179008260d6f4c7103ed2bc1f0fadae0a4695727f67f1348e71771ce3e4ea27"
    45          ]
    46        }
    47      ]
    48    }
    49  ],
    50  "outputs": [
    51    {
    52      "bip32_derivs": [],
    53      "bip32_taproot_derivs": []
    54    }
    55  ]
    56}
    
  18. achow101 commented at 10:18 pm on July 19, 2021: member

    I created one, should be OK.

    Looks correct to me.


    I’ve been working on a reference implementation and first draft of it is at https://github.com/achow101/bitcoin/tree/taproot-psbt. It still needs some testing, but once that is done, I’ll list it in the BIP and add test vectors.

  19. luke-jr added the label New BIP on Jul 20, 2021
  20. luke-jr renamed this:
    [New BIP] Taproot Fields for PSBT
    BIP 371: Taproot Fields for PSBT
    on Jul 20, 2021
  21. luke-jr commented at 6:50 pm on July 20, 2021: member
    Assigned BIP number 371
  22. achow101 force-pushed on Jul 20, 2021
  23. Specify BIP 371 Taproot Fields for PSBT
    Add bip-0371.mediawiki, update readme, and update BIP 174 with
    new field types.
    c583f4dcbe
  24. achow101 force-pushed on Jul 20, 2021
  25. luke-jr merged this on Jul 20, 2021
  26. luke-jr closed this on Jul 20, 2021


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: 2024-11-21 12:10 UTC

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