From e681ec8739b8ed155bba64229201711b9205b975 Mon Sep 17 00:00:00 2001 From: Ethan Heilman Date: Fri, 23 Jan 2026 19:33:38 -0500 Subject: [PATCH 1/6] OP_CAT to BIP 0003 format, add usecase --- bip-0347.mediawiki | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bip-0347.mediawiki b/bip-0347.mediawiki index 12a1a08e1f..2f7e0a39f0 100644 --- a/bip-0347.mediawiki +++ b/bip-0347.mediawiki @@ -9,6 +9,8 @@ Assigned: 2023-12-11 License: BSD-3-Clause Discussion: 2023-10-21: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2023-October/022049.html [bitcoin-dev] Proposed BIP for OP_CAT + Version: 0.3.1 + Requires: 340, 341, 342 ==Abstract== @@ -42,6 +44,8 @@ OP_CAT aims to expand the toolbox of the tapscript developer with a simple, modu * Non-equivocation contracts T. Ruffing, A. Kate, D. Schröder, "Liar, Liar, Coins on Fire: Penalizing Equivocation by Loss of Bitcoins", 2015, https://web.archive.org/web/20221023121048/https://publications.cispa.saarland/565/1/penalizing.pdf in tapscript provide a mechanism to punish equivocation/double spending in Bitcoin payment channels. OP_CAT enables this by enforcing rules on the spending transaction's nonce. The capability is a useful building block for payment channels and other Bitcoin protocols. * Vaults M. Moser, I. Eyal, and E. G. Sirer, Bitcoin Covenants, https://web.archive.org/web/20220203124718/https://fc16.ifca.ai/bitcoin/papers/MES16.pdf which are a specialized covenant that allows a user to block a malicious party who has compromised the user's secret key from stealing the funds in that output. As shown in A. Poelstra, "CAT and Schnorr Tricks II", 2021, https://www.wpsoftware.net/andrew/blog/cat-and-schnorr-tricks-ii.html OP_CAT is sufficient to build vaults in Bitcoin. * Replicating CheckSigFromStack A. Poelstra, "CAT and Schnorr Tricks I", 2021, https://www.wpsoftware.net/andrew/blog/cat-and-schnorr-tricks-i.html which would allow the creation of simple covenants and other advanced contracts without having to presign spending transactions, possibly reducing complexity and the amount of data that needs to be stored. Originally shown to work with Schnorr signatures, this result has been extended to ECDSA signatures R. Linus, "Covenants with CAT and ECDSA", 2023, https://gist.github.com/RobinLinus/9a69f5552be94d13170ec79bf34d5e85#file-covenants_cat_ecdsa-md. +* OP_CAT would allow tapscript to perform arbitrary computation on stack elements larger than 32-bits such as signatures and public keys. While Collider Script E. Heilman, V. I. Kolobov, A. M. Levy, A. Poelstra, "ColliderScript: Covenants in Bitcoin via 160-bit hash collisions", 2024, https://eprint.iacr.org/2024/1802 showed that even without OP_CAT tapscript can perform arbitrary computation on stack elements larger than 32-bits, this approach is extremely computationally expensive. In practice, today's tapscript can only perform arbitrary computation on 32-bit stack elements. OP_CAT was not designed with this usecase in mind and OP_CAT an inefficient way to perform this task. +* BitVMR. Linus, L. Aumayr, A. Zamyatin, A. Pelosi, Z. Avarikioti, M. Maffei "BitVM2: Bridging Bitcoin to Second Layers", 2025, https://bitvm.org/bitvm_bridge.pdf improvements. OP_CAT would enable BitVM2 to eliminating the trusted setup from its proof system allow BitVM2 to reduce the size of transactions it uses. OP_CAT was available in early versions of Bitcoin. In 2010, a single commit disabled OP_CAT, along with another 15 opcodes. @@ -106,6 +110,16 @@ An alternative implementation of OP_CAT can be found in Elements Roose S., +==Changelog== + +* __0.3.1 (2026-01-23) - Made compliant with BIP 003, use cases added. +* __0.3.0__ (2024-05-06) - Merged to BIP repo +* __0.2.0__ (2024-04-24) - Assigned BIP number +* __0.1.0__ (2023-12-11) - Initial draft posted + + +May 6, 2024 + ==Acknowledgements== We wish to acknowledge Dan Gould for encouraging and helping review this effort. We also want to thank Madars Virza, Jeremy Rubin, Andrew Poelstra, Bob Summerwill, From 440bcf7c9de699b05ec5e7e6dc8888fe1511a9fc Mon Sep 17 00:00:00 2001 From: Ethan Heilman Date: Mon, 2 Feb 2026 15:39:56 -0500 Subject: [PATCH 2/6] draft --> complete --- bip-0347.mediawiki | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bip-0347.mediawiki b/bip-0347.mediawiki index 2f7e0a39f0..2220914716 100644 --- a/bip-0347.mediawiki +++ b/bip-0347.mediawiki @@ -4,7 +4,7 @@ Title: OP_CAT in Tapscript Authors: Ethan Heilman Armin Sabouri - Status: Draft + Status: Complete Type: Specification Assigned: 2023-12-11 License: BSD-3-Clause @@ -112,7 +112,8 @@ An alternative implementation of OP_CAT can be found in Elements Roose S., ==Changelog== -* __0.3.1 (2026-01-23) - Made compliant with BIP 003, use cases added. +* __1.0.0__ (2026-02-02) - Marked as complete. +* __0.3.1__ (2026-01-23) - Made compliant with BIP 003, use cases added. * __0.3.0__ (2024-05-06) - Merged to BIP repo * __0.2.0__ (2024-04-24) - Assigned BIP number * __0.1.0__ (2023-12-11) - Initial draft posted From 2bdb6b2aefb293d1bcd9bee1b623d79237c53824 Mon Sep 17 00:00:00 2001 From: Ethan Heilman Date: Mon, 2 Feb 2026 19:12:57 -0500 Subject: [PATCH 3/6] Update bip-0347.mediawiki Co-authored-by: Mark "Murch" Erhardt --- bip-0347.mediawiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bip-0347.mediawiki b/bip-0347.mediawiki index 2220914716..93ec299bde 100644 --- a/bip-0347.mediawiki +++ b/bip-0347.mediawiki @@ -9,7 +9,7 @@ Assigned: 2023-12-11 License: BSD-3-Clause Discussion: 2023-10-21: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2023-October/022049.html [bitcoin-dev] Proposed BIP for OP_CAT - Version: 0.3.1 + Version: 1.0.0 Requires: 340, 341, 342 From db1e7c3de025d5167ecc6faed21b518b1cbce6d5 Mon Sep 17 00:00:00 2001 From: Murch Date: Fri, 27 Feb 2026 14:34:39 -0800 Subject: [PATCH 4/6] BIP347: Update table entry to complete --- README.mediawiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.mediawiki b/README.mediawiki index ed4e1dd24a..2fae0ae1c6 100644 --- a/README.mediawiki +++ b/README.mediawiki @@ -1176,7 +1176,7 @@ users (see also: [https://en.bitcoin.it/wiki/Economic_majority economic majority | OP_CAT in Tapscript | Ethan Heilman, Armin Sabouri | Specification -| Draft +| Complete |- | [[bip-0348.md|348]] | Consensus (soft fork) From afe6b73f550b5d2d4212e19d338c7f6fe565dfa3 Mon Sep 17 00:00:00 2001 From: Ethan Heilman Date: Sun, 1 Mar 2026 23:24:57 -0500 Subject: [PATCH 5/6] Fix breaking test --- README.mediawiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.mediawiki b/README.mediawiki index dc8f1f167e..11bca2e383 100644 --- a/README.mediawiki +++ b/README.mediawiki @@ -1198,7 +1198,7 @@ users (see also: [https://en.bitcoin.it/wiki/Economic_majority economic majority | Steven Roose, Brandon Black | Specification | Draft -|- +|- style="background-color: #ffffcf" | [[bip-0347.mediawiki|347]] | Consensus (soft fork) | OP_CAT in Tapscript From b6959a3e2e898ab5a4f004020c8bf2b496c55ab5 Mon Sep 17 00:00:00 2001 From: Ethan Heilman Date: Sun, 1 Mar 2026 23:45:27 -0500 Subject: [PATCH 6/6] Add test vectors --- bip-0347.mediawiki | 56 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/bip-0347.mediawiki b/bip-0347.mediawiki index 93ec299bde..319f75b8d6 100644 --- a/bip-0347.mediawiki +++ b/bip-0347.mediawiki @@ -106,13 +106,67 @@ break; An alternative implementation of OP_CAT can be found in Elements Roose S., Elements Project, "Re-enable several disabled opcodes", 2019, https://github.com/ElementsProject/elements/commit/13e1103abe3e328c5a4e2039b51a546f8be6c60a#diff-a0337ffd7259e8c7c9a7786d6dbd420c80abfa1afdb34ebae3261109d9ae3c19R740-R759. + +==Test Vectors== + +The following test vectors use Bitcoin-core JSON script-test format. + +
+[
+    [
+        "78a11a1260c1101260",
+        "78a11a1260",
+        "c1101260",
+        "#SCRIPT# CAT EQUAL",
+        "#CONTROLBLOCK#",
+        0.00000001
+    ],
+    "",
+    "0x51 0x20 #TAPROOTOUTPUT#",
+    "P2SH,WITNESS,TAPROOT,OP_CAT",
+    "OK",
+    "TAPSCRIPT CATs 78a11a1260 and c1101260 together and checks it is EQUAL to stack element 78a11a1260c1101260"
+],
+[
+    [
+        "51",
+        "bbbb",
+        "01",
+        "#SCRIPT# IF CAT ELSE DROP ENDIF",
+        "#CONTROLBLOCK#",
+        0.00000001
+    ],
+    "",
+    "0x51 0x20 #TAPROOTOUTPUT#",
+    "P2SH,WITNESS,TAPROOT,OP_CAT",
+    "OK",
+    "TAPSCRIPT Tests CAT inside of an IF ELSE conditional (true IF)"
+],
+[
+    [
+        "",
+        "09ca7009ca7009ca7009ca7009ca70",
+        "#SCRIPT# CAT",
+        "#CONTROLBLOCK#",
+        0.00000001
+    ],
+    "",
+    "0x51 0x20 #TAPROOTOUTPUT#",
+    "P2SH,WITNESS,TAPROOT,OP_CAT",
+    "OK",
+    "TAPSCRIPT (['', 09ca7009ca7009ca7009ca7009ca70], CAT) Tests CAT succeeds when one of the two values to concatenate is of size zero"
+],
+
+ +A full test suite with additional vectors can be found at the Bitcoin [https://github.com/bitcoin/bitcoin/pull/29247 OP_CAT PR]. + ==References== ==Changelog== -* __1.0.0__ (2026-02-02) - Marked as complete. +* __1.0.0__ (2026-03-01) - Marked as complete. * __0.3.1__ (2026-01-23) - Made compliant with BIP 003, use cases added. * __0.3.0__ (2024-05-06) - Merged to BIP repo * __0.2.0__ (2024-04-24) - Assigned BIP number