|
| 1 | +--- |
| 2 | +title: OP_CAT |
| 3 | + |
| 4 | +## Optional. Shorter name to use for reference style links e.g., "foo" |
| 5 | +## will allow using the link [topic foo][]. Not case sensitive |
| 6 | +# shortname: foo |
| 7 | + |
| 8 | +## Optional. An entry will be added to the topics index for each alias |
| 9 | +#aliases: |
| 10 | +# - Foo |
| 11 | + |
| 12 | +## Required. At least one category to which this topic belongs. See |
| 13 | +## schema for options |
| 14 | +categories: |
| 15 | + - Scripts and Addresses |
| 16 | + - Soft Forks |
| 17 | + |
| 18 | +## Optional. Produces a Markdown link with either "[title][]" or |
| 19 | +## "[title](link)" |
| 20 | +primary_sources: |
| 21 | + - title: "BIN24-1: `OP_CAT`" |
| 22 | + link: https://github.com/bitcoin-inquisition/binana/blob/master/2024/BIN-2024-0001.md |
| 23 | + |
| 24 | +## Optional. Each entry requires "title" and "url". May also use "feature: |
| 25 | +## true" to bold entry and "date" |
| 26 | +optech_mentions: |
| 27 | + - title: "Replicating `OP_CHECKSIGFROMSTACK` with schnorr signatures and `OP_CAT`" |
| 28 | + url: /en/newsletters/2021/02/03/#replicating-op-checksigfromstack-with-bip340-and-op-cat |
| 29 | + |
| 30 | + - title: "Example of using the MATT proposal plus OP_CAT to manage joinpools" |
| 31 | + url: /en/newsletters/2023/06/07/#using-matt-to-replicate-ctv-and-manage-joinpools |
| 32 | + |
| 33 | + - title: "Alternative to COSHV (CTV) and SIGHASH_ANYPREVOUT: OP_CAT and OP_CHECKSIGFROMSTACK" |
| 34 | + url: /en/newsletters/2019/05/29/#not-generic-enough |
| 35 | + |
| 36 | + - title: "Discussion about `SIGHASH_ANYPREVOUT` spins off into discussion about `OP_CAT`" |
| 37 | + url: /en/newsletters/2019/10/09/#continued-discussion-about-noinput-anyprevout |
| 38 | + |
| 39 | + - title: "Discussion about `OP_CHECKSIGFROMSTACK` branches off into discussion about `OP_CAT`" |
| 40 | + url: /en/newsletters/2021/07/14/#request-for-op-checksigfromstack-design-suggestions |
| 41 | + |
| 42 | + - title: "Examination of the minimal set of features added to `OP_CAT` that would create recursive covenants" |
| 43 | + url: /en/newsletters/2022/05/18/#when-would-enabling-op-cat-allow-recursive-covenants |
| 44 | + |
| 45 | + - title: "Ark proposal would benefit from `OP_CAT` and `OP_CHECKSIGFROMSTACK`" |
| 46 | + url: /en/newsletters/2023/05/31/#proposal-for-a-managed-joinpool-protocol |
| 47 | + |
| 48 | + - title: "Proposed BIP for `OP_CAT`" |
| 49 | + url: /en/newsletters/2023/10/25/#proposed-bip-for-op-cat |
| 50 | + |
| 51 | + - title: "Comments on draft BIP for `OP_CAT`" |
| 52 | + url: /en/newsletters/2023/11/01/#op-cat-proposal |
| 53 | + |
| 54 | +## Optional. Same format as "primary_sources" above |
| 55 | +see_also: |
| 56 | + - title: OP_CHECKSIGFROMSTACK |
| 57 | + link: topic op_checksigfromstack |
| 58 | + |
| 59 | + - title: OP_CHECKTEMPLATEVERIFY |
| 60 | + link: topic op_checktemplateverify |
| 61 | + |
| 62 | + - title: MATT |
| 63 | + link: topic matt |
| 64 | + |
| 65 | +## Optional. Force the display (true) or non-display (false) of stub |
| 66 | +## topic notice. Default is to display if the page.content is below a |
| 67 | +## threshold word count |
| 68 | +#stub: false |
| 69 | + |
| 70 | +## Required. Use Markdown formatting. Only one paragraph. No links allowed. |
| 71 | +## Should be less than 500 characters |
| 72 | +excerpt: > |
| 73 | + **OP_CAT** was originally an opcode in Bitcoin. It was disabled in |
| 74 | + 2010 but slight variations on it are frequently proposed to be |
| 75 | + added to Bitcoin using a soft fork. |
| 76 | +
|
| 77 | +--- |
| 78 | +Both the original `OP_CAT` and the new proposals for it |
| 79 | +concatenate two elements on the stack into a single element. For |
| 80 | +example, the following script: |
| 81 | + |
| 82 | + <0xB10C> <0xCAFE> OP_CAT |
| 83 | + |
| 84 | +Would become: |
| 85 | + |
| 86 | + <0xB10CCAFE> |
| 87 | + |
| 88 | +The primary expected use for `OP_CAT` is for data provided by the |
| 89 | +creator of a script to be concatenated with data provided by someone |
| 90 | +spending from that script. For example, Alice wants to create an |
| 91 | +equivocation bond that she can't create competing spends for without |
| 92 | +putting her funds at risk. She generates a private key in the normal |
| 93 | +way, derives a public key from it in the normal way, chooses a |
| 94 | +random private nonce the same way she usually would for a [schnorr |
| 95 | +signature][topic schnorr signatures], and derives the public nonce also |
| 96 | +in the normal way. She then pays to the following script: |
| 97 | + |
| 98 | + <public nonce> OP_CAT <pubkey> OP_CHECKSIG |
| 99 | + |
| 100 | +Later, when she signs, instead of providing a complete schnorr |
| 101 | +signature---which includes both a public nonce and a scalar---she's |
| 102 | +forced to use the public nonce from her script. In her witness field, |
| 103 | +she only provides the scalar. The scalar and the public nonce are |
| 104 | +concatenated together to produce a [BIP340][] schnorr signature, which |
| 105 | +is then verified against Alice's public key like normal using the |
| 106 | +`OP_CHECKSIG` opcode. |
| 107 | + |
| 108 | +If Alice later tries to sign a different version of the transaction, |
| 109 | +she's forced to reuse the same public nonce but must (because of the |
| 110 | +BIP340 equation) generate a different scalar. This reuse of the same |
| 111 | +nonce in different signatures from the same private key allows anyone to |
| 112 | +derive her private key. They can then create their own signatures for |
| 113 | +Alice's private key, potentially spending her funds if they haven't been |
| 114 | +spent already. |
| 115 | + |
| 116 | +There are many other proposed applications of `OP_CAT`, see [BIN24-1][] |
| 117 | +for one list. Some applications, such as the example above, are |
| 118 | +possible with just `OP_CAT` and other features that are already part of |
| 119 | +Bitcoin script; other applications require additional new opcodes or |
| 120 | +other changes to Bitcoin. |
| 121 | + |
| 122 | +{% include references.md %} |
| 123 | +{% include linkers/issues.md issues="" %} |
0 commit comments