summaryrefslogtreecommitdiff
path: root/53/078da2568e93a70d05c6be71ec0951c3a5786f
blob: 259e7ce866cc5f0309316d3a61314243524aae26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
Delivery-date: Thu, 14 Nov 2024 16:03:08 -0800
Received: from mail-qt1-f186.google.com ([209.85.160.186])
	by mail.fairlystable.org with esmtps  (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
	(Exim 4.94.2)
	(envelope-from <bitcoindev+bncBAABBM473K4QMGQE6HWVOBA@googlegroups.com>)
	id 1tBjnn-0004fl-Rk
	for bitcoindev@gnusha.org; Thu, 14 Nov 2024 16:03:08 -0800
Received: by mail-qt1-f186.google.com with SMTP id d75a77b69052e-460a85907b7sf16071521cf.0
        for <bitcoindev@gnusha.org>; Thu, 14 Nov 2024 16:03:07 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1731628982; cv=pass;
        d=google.com; s=arc-20240605;
        b=aKdsw2T9Fuel3KM1YhmEtnn5V0Pl4ZI0KGVWQ1vUCbuL1FNkyx1GR8K0Ru2npNKfYo
         ojS/CtLS5U3qZe46v+5m4FgwvJwis4XmU1HdE8ejXrDW9N/SzpVeL3GYQL28Oi1s6tgB
         8iQE0lI/am2HfzQKE9zAtcUPfJR5WqBtx9gK2Xnr8A2ebqsECvEpIJtIj0E+EA+uUxU4
         NPb1YQrj6yVP5QaqfP5AQbtz4WopYAHQCIGyGZac/58kHQfsrgMcTJJpk6caG9L2K9UX
         mKyZ/QrEkgllVtD89N/4xVS1y5hjGaSzq3bfL/m0SjD9s0u1zyuBsefuaHEe2BVpEm9R
         ayXA==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:mime-version:feedback-id
         :message-id:subject:from:to:date:dkim-signature;
        bh=aFAEMHzVFLh7U9SB5pf85jX5A0D2eRlD03ejGAFNZ4M=;
        fh=vMjKr0jRIlQ2VgrqoX+i3qY86SO2sx/45ecreRaMsfs=;
        b=jBX4LPSoqcnOQONSnW7JA/mAHKUBLHguDYDjUkMD/0LlQnGwJBAPtxpwOMXrJpwhsu
         7uBgQ9ioBRhRAMOWKZ78tlX4oZuwHO3sD9JPUFs8SzaJjaxPE+wjO5HD83zES3GSOiEs
         y+RurDBtc/scRbWGVQ8WDdJ+/LH7daTe9y6t/3TC1y6lcDc4gzU3Xl/WQccK7S/i7AJB
         4jftlKdZcpiZyqaxCMAR9rnQeym8yvF74At5NkQpX3rHtbSb2dMfuNK+VAHAQ+ZQ2hta
         7LzXjvmxRTmOaC/poHuT1Os3/L0MuQYRD/9lTryuT0/pZkaU4Yz3FVxJ/e/fRBATjNAN
         q4cA==;
        darn=gnusha.org
ARC-Authentication-Results: i=2; gmr-mx.google.com;
       dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=ngZ6sVS2;
       spf=pass (google.com: domain of moonsettler@protonmail.com designates 185.70.43.167 as permitted sender) smtp.mailfrom=moonsettler@protonmail.com;
       dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlegroups.com; s=20230601; t=1731628982; x=1732233782; darn=gnusha.org;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to
         :x-original-authentication-results:x-original-sender:mime-version
         :feedback-id:message-id:subject:from:to:date:from:to:cc:subject:date
         :message-id:reply-to;
        bh=aFAEMHzVFLh7U9SB5pf85jX5A0D2eRlD03ejGAFNZ4M=;
        b=P3zAgmiX6nt9Aobq4NPIOvQPo4uthiXkJ72MXocwSm+FR4iyGp2jNYw4dzMZH+qrLS
         cjhB1HtAyNQdF441i8TkWISVHhTT7Shsm1KCmQHixGy3WChhoDT1lhpZkFpT7wKuMSnT
         B4Ec9IlYBh+6a7O8e0os5KLW6wKUn1feRTdOvCkofIhLu+LZIzGI28579Gz+IBuLnh8a
         w2CVeeXYY1XTe7L/x359uEzRdglZ3fe4Uelglab9LkVtMEmx0gQ6Mkv5EOLHsKJxyoG7
         jIMGM3ooWib7T/W8iR9uArGc8sRtSy2IyA5nUU6hPlsEgUiznIou9MKUox1ZAf4Y65oS
         NwPw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1731628982; x=1732233782;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to
         :x-original-authentication-results:x-original-sender:mime-version
         :feedback-id:message-id:subject:from:to:date:x-beenthere
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
        bh=aFAEMHzVFLh7U9SB5pf85jX5A0D2eRlD03ejGAFNZ4M=;
        b=ZWbezAhuVrDN+4a6JyYYTdPtJXfJh6ozGu+clLdFSTe3w1gEWRSx7VsAk7oMHtF9wR
         4KGtkGivCDzY1V/xgWIh3/M4N+YD4RYvkmJsuy5UqE/c3nNErl9czWeUEQwvuwKH2YZ2
         rySLOofBPnCg+ANNJOzsVnLa/bWH5r9+k4PJevgBu476AS+vVHntbmFNltij1+liUbLc
         JvbaL/txBrPo4q7QPMVtGujmmQ70Zzl9uIy6Spf2ykOMuPsWjKV41gQ8P0TWtQN7B3bp
         X7hOuax3IjC4OnC417hraPG3vglNsQOz7Iv+uH0uCiARy7aQPBIXBkSA6rypo3GupLBp
         N5qg==
X-Forwarded-Encrypted: i=2; AJvYcCXFDqxx/oOEiM9t6G4yljCwmy6rtA2orOSfw6QJ+w5vz48156UImmgqGcR0JFMNjuGPv8n8o3IY5Ykt@gnusha.org
X-Gm-Message-State: AOJu0YyJRHshorB70/WnxfqGvgdoUPjL654U969DLis8MP/CRzzeEbIU
	EqB/aEw53PeXGyKUShqOIOUxUvB1z6dpnP27OqBl5gG9uySTSCrq
X-Google-Smtp-Source: AGHT+IEPXnPtKtJwsiicsrPwrJOKyRyBbpa9o9JneWGh4QUfltAcz/KouHfrupzXZkjRU9IIgs+54g==
X-Received: by 2002:ac8:7d82:0:b0:461:5770:cbd3 with SMTP id d75a77b69052e-46363e2db28mr8531691cf.30.1731628981645;
        Thu, 14 Nov 2024 16:03:01 -0800 (PST)
X-BeenThere: bitcoindev@googlegroups.com
Received: by 2002:a05:622a:903:b0:458:355c:362b with SMTP id
 d75a77b69052e-46356e73ee5ls14994021cf.0.-pod-prod-06-us; Thu, 14 Nov 2024
 16:02:59 -0800 (PST)
X-Received: by 2002:a05:620a:17a9:b0:79f:879:63ad with SMTP id af79cd13be357-7b36235b548mr95986485a.46.1731628979317;
        Thu, 14 Nov 2024 16:02:59 -0800 (PST)
Received: by 2002:ae9:c002:0:b0:7b1:4744:32d3 with SMTP id af79cd13be357-7b35b0a1848ms85a;
        Thu, 14 Nov 2024 16:00:41 -0800 (PST)
X-Received: by 2002:a05:600c:6990:b0:42c:b166:913 with SMTP id 5b1f17b1804b1-432df019070mr6707935e9.11.1731628838875;
        Thu, 14 Nov 2024 16:00:38 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1731628838; cv=none;
        d=google.com; s=arc-20240605;
        b=IflK87KzI7OxHPkvY397eQZuVGJfSR+RBXSTCF/DRkEbA6iB5NQL0lXxriAXWHEmSc
         EVwmtf2Juud/dr4ECi/Tczj91zjxPS5ayb+Ql6AA+mhAMkQZjZwB8qRoG+KjJaa80kZd
         vC7fb4Q1p2djlItWoArh9oVvo7ksJugi8M+REeTvRf+qHj8sGaMyAOcpbvVb/3tBHesX
         A+rJXLEu+VqyTj3+KoEvHsxZWZwSOXWZbgEzOXHtfBxDd4fTLPKjgq7unSSvy7j+BSTe
         DfLRAt7F7BuHjrRF2ryC1pH8s5VihY7pSVHgim2ImuPhKbxURi67+D2ASKgrGiRd0b2R
         Ks1g==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605;
        h=mime-version:feedback-id:message-id:subject:from:to:date
         :dkim-signature;
        bh=erKmMRR1nwTAqjcsyznj6+i6tVkP8NQvmiQKHC+w5CU=;
        fh=lhFSo2W/mHC0QoJ9oNg3A35n0DTltt3CQl1/0RggJlk=;
        b=BsfWka6HhbL2zgCnt3KK+TJA6HAmQ9FcrGMBrdt4SWJYIpdVFyl7e2oGzP/9lnVbpV
         VSWlxp8bcBV+Ip1P0OD5g570nSYPq4c4Um98XFwzI1hkDKaGj90sSOXRGsB0SQZVWEkD
         /o2st2IYb/lwpKxzU+IZPka/KM/CBlVd/+c4YQsDWTD8dyTbrxF4kQuDxhYphxREPRED
         pJZwniOAK9UpD1517WF+p7/rgloJKHlEB3+eOd//yhgFRnyFlOQlwZC4C3aiNPpJGb3O
         Oa4uwfnLdbhOLQCJoC1BtbAcXbvnPvGijbhV7Q3Wkvnyi7hXYVGqgRJHChSyyF500SJw
         SXPg==;
        dara=google.com
ARC-Authentication-Results: i=1; gmr-mx.google.com;
       dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=ngZ6sVS2;
       spf=pass (google.com: domain of moonsettler@protonmail.com designates 185.70.43.167 as permitted sender) smtp.mailfrom=moonsettler@protonmail.com;
       dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com
Received: from mail-43167.protonmail.ch (mail-43167.protonmail.ch. [185.70.43.167])
        by gmr-mx.google.com with ESMTPS id 5b1f17b1804b1-432d478830csi2791125e9.0.2024.11.14.16.00.38
        for <bitcoindev@googlegroups.com>
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 14 Nov 2024 16:00:38 -0800 (PST)
Received-SPF: pass (google.com: domain of moonsettler@protonmail.com designates 185.70.43.167 as permitted sender) client-ip=185.70.43.167;
Date: Fri, 15 Nov 2024 00:00:32 +0000
To: "bitcoindev@googlegroups.com" <bitcoindev@googlegroups.com>
From: "'moonsettler' via Bitcoin Development Mailing List" <bitcoindev@googlegroups.com>
Subject: [bitcoindev] OP_PAIRCOMMIT
Message-ID: <xyv6XTAFIPmbG1yvB0l2N3c9sWAt6lDTG-xjIbogOZ-lc9RfsFeJ-JPuXuXKzVea8T9TztlCvSrxZOWXKCwogCy9tqa49l3LXjF5K2cLtP4=@protonmail.com>
Feedback-ID: 38540639:user:proton
X-Pm-Message-ID: 5ac6f399528b8132c5c46c0843c146fc39b1c03d
MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="b1=_zaqQvmDDQHbTdw1KU4fVuG8d0QUJBATmaaN0eNsbl0"
X-Original-Sender: moonsettler@protonmail.com
X-Original-Authentication-Results: gmr-mx.google.com;       dkim=pass
 header.i=@protonmail.com header.s=protonmail3 header.b=ngZ6sVS2;
       spf=pass (google.com: domain of moonsettler@protonmail.com designates
 185.70.43.167 as permitted sender) smtp.mailfrom=moonsettler@protonmail.com;
       dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com
X-Original-From: moonsettler <moonsettler@protonmail.com>
Reply-To: moonsettler <moonsettler@protonmail.com>
Precedence: list
Mailing-list: list bitcoindev@googlegroups.com; contact bitcoindev+owners@googlegroups.com
List-ID: <bitcoindev.googlegroups.com>
X-Google-Group-Id: 786775582512
List-Post: <https://groups.google.com/group/bitcoindev/post>, <mailto:bitcoindev@googlegroups.com>
List-Help: <https://groups.google.com/support/>, <mailto:bitcoindev+help@googlegroups.com>
List-Archive: <https://groups.google.com/group/bitcoindev
List-Subscribe: <https://groups.google.com/group/bitcoindev/subscribe>, <mailto:bitcoindev+subscribe@googlegroups.com>
List-Unsubscribe: <mailto:googlegroups-manage+786775582512+unsubscribe@googlegroups.com>,
 <https://groups.google.com/group/bitcoindev/subscribe>
X-Spam-Score: -1.0 (-)

--b1=_zaqQvmDDQHbTdw1KU4fVuG8d0QUJBATmaaN0eNsbl0
Content-Type: text/plain; charset="UTF-8"

Hi All,

We propose to add a new opcode to tapscript, the newest member of the LNhance
opcode family, OP_PAIRCOMMIT.

LNhance is a package deal of CTV + CSFS + IKEY + PC specifically designed to
enable efficient rebindable channels, that can be grafted to a variety ofcovenant tree / channel factory constructions.

When evaluated, the `OP_PAIRCOMMIT` instruction:
* Pops the top two values off the stack,
* takes the "PairCommit" tagged SHA256 hash of the stack elements,
* pushes the resulting commitment on the top of the stack.

https://gist.github.com/moonsettler/d7f1fb88e3e54ee7ecb6d69ff126433b

PR: 1699 to https://github.com/bitcoin/bips

Q: Why not CAT?

A: OP_PAIRCOMMIT was specifically introduced so that we don't have a dependency
on CAT for efficient LN-Symmetry construction. If we already had CAT or had
reasonable assurances that CAT will be activated soon, the balance of tradeoffs
might have tipped against a late introduction of a new opcode to a concept that
was already floating out there.

Q: What is the difference between PAIRCOMMIT and CAT?

A: PAIRCOMMIT is domain separated from other implicit uses of hashing pieces of
data together. CAT allows for reconstructing and therefore inspecting sighashes
on the stack. And not only it allows for fine grained introspection, it also
allows for inspecting ancestor transactions. This makes CAT with the Poelstra
trick a way to implement state carrying covenants.
* If CAT has consensus, PAIRCOMMIT is an optimization of which we already have
plenty examples of in script
* If CAT has no consensus, PAIRCOMMIT gets the job done in regards to a veryspecific subset of behaviors, that explicitly do not include introspection.

BR.
moonsettler

--------------------------------------------------------------------------------

<pre>

BIP: ?

Layer: Consensus (soft fork)

Title: OP_PAIRCOMMIT

Author: moonsettler <

moonsettler@protonmail.com

>

Comments-Summary: No comments yet.

Comments-URI: <links to wiki page for comments>

Status: Draft

Type: Standards Track

Created: 2024-11-08

License: BSD-3-CLAUSE

</pre>

## Abstract

This BIP describes a new tapscript opcode `OP_PAIRCOMMIT` which

provide limited vector commitment functionality in tapscript.

When evaluated, the `OP_PAIRCOMMIT` instruction:

* Pops the top two values off the stack,

* takes the "PairCommit" tagged SHA256 hash of the stack elements,

* pushes the resulting commitment on the top of the stack.

## Motivation

To do LN-Symmetry contracts that don't require the nodes to keep old states,

we need to solve the data availability problem presented by unilateral closes.

Channel peers must be able to reconstruct the script that spends an

intermediate state.

Using in sequence `OP_CHECKTEMPLATEVERIFY`, `OP_PAIRCOMMIT`, `OP_INTERNALKEY`

and `OP_CHECKSIGFROMSTACK` we can construct a rebindable channel that is also

optimal.

If `OP_CAT` was available, it could be used to combine multiple stack elements,

that get verified with `OP_CHECKSIGFROMSTACK` as a valid state update.

`OP_PAIRCOMMIT` solves this specific problem without introducing a wide range

of potentially controversial new behaviors, such as novel 2-way peg mechanisms.

The number of SHA256 iterations is minimized in the primary use case we

can optimize for, which is LN-Symmetry. Since the Tag can be pre-computed as

mid-state, it would only take 1 or 2 hash cycles in validation for the

unilateral close scenario.

## Specification

Repurpose opcode 205 (currently `OP_SUCCESS`) as follows:

`OP_PAIRCOMMIT` pops two elements off the stack, then concatenates them along

with their size commitments and takes the tagged SHA256 hash of that

concatenated string, then pushes the resulting hash back on the stack.

Given the stack `[x1, x2]`, where `x2` is at the top of the stack:

`OP_PAIRCOMMIT` will push `SHA256(tagPC|cs(x1)|x1|cs(x2)|x2)` onto the stack.

Where `|` denotes concatenation and `tagPC` is calculated according to BIP-340

tagged hash as `SHA256("PairCommit")|SHA256("PairCommit")` and `cs(x)` means

`CompactSize(x)`.

### Implementation

```c++

case OP_PAIRCOMMIT: {

// OP_PAIRCOMMIT is only available in Tapscript

// ...

// x1 x2 -- hash

if (stack.size() < 2) {

return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);

}

const valtype& vch1 = stacktop(-2);

const valtype& vch2 = stacktop(-1);

uint256 hash = PairCommitHash(vch1, vch2);

popstack(stack);

popstack(stack);

stack.emplace_back(hash.begin(), hash.end());

break;

}

```

```c++

const HashWriter HASHER_PAIRCOMMIT{TaggedHash("PairCommit")};

uint256 PairCommitHash(const std::vector<unsigned char>& x1, const std::vector<unsigned char>& x2)

{

return (HashWriter{HASHER_PAIRCOMMIT} << x1 << x2).GetSHA256();

}

```

### Use in script

`OP_PAIRCOMMIT` can be used to commit to a vector of stack elements in a way

that is not vulnerable to various forms of witness malleability. It is however,

highly optimized for just 2 stack elements.

```text

# pc-hash = PC(a, PC(b, c))

<a> <b> <c> | PC PC <pc-hash> OP_EQUALVERIFY

```

### Use in LN-Symmetry

The following assembly-like pseudo-code shows a possible LN-Symmetry channel

construction, that provides data availability to spend to the latest state from

an earlier state pushed on-chain with a forced close by channel partner.

```text

# S = 500000000

# IK -> A+B

<sig> <state-n-recovery-data> <state-n-hash> | CTV PC IK CSFS <S+1> CLTV DROP

```

before funding sign first state template:

```text

# state-n-hash { nLockTime(S+n), out(contract, amount(A)+amount(B)) }

# settlement-n-hash { nSequence(2w), out(A, amount(A)), out(B, amount(B)) }

# state-n-recovery-data { settlement-n-hash or state-n-balance }

# contract for state n < m

IF

<sig> <state-m-recovery-data> <state-m-hash> | CTV PC IK CSFS <S+n+1> CLTV DROP

ELSE

<settlement-n-hash> CTV

ENDIF

```

## Reference Implementation

A reference implementation is provided here:

https://github.com/lnhance/bitcoin/pull/6/files

## Backward Compatibility

By constraining the behavior of OP_SUCCESS opcodes, deployment of the BIP

can be done in a backwards compatible, soft-fork manner. If anyone were to

rely on the OP_SUCCESS behavior of `OP_SUCCESS205`, `OP_PAIRCOMMIT` would

invalidate their spend.

## Deployment

TBD

## Credits

Jeremy Rubin, Brandon Black, Salvatore Ingala, Anthony Towns

## Copyright

This document is licensed under the 3-clause BSD license.

## References

1. LNhance bitcoin repository, [lnhance](

https://github.com/lnhance/bitcoin

)

2. LN-Symmetry, [eltoo](

https://github.com/instagibbs/bolts/blob/eltoo_draft/XX-eltoo-transactions.md

)

3. OP_CAT, [BIN-2024-0001](

https://github.com/bitcoin-inquisition/binana/blob/master/2024/BIN-2024-0001.md

)

4. OP_CHECKTEMPLATEVERIFY, [BIP-119](

https://github.com/bitcoin/bips/tree/master/bip-0119

)

5. OP_CHECKSIGFROMSTACK, [BIN-2024-0003](

https://github.com/bitcoin-inquisition/binana/blob/master/2024/BIN-2024-0003.md

)

6. OP_INTERNALKEY, [BIN-2024-0004](

https://github.com/bitcoin-inquisition/binana/blob/master/2024/BIN-2024-0004.md

)

7. Tagged hash, [BIP-340](

https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki

)

-- 
You received this message because you are subscribed to the Google Groups "Bitcoin Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bitcoindev+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bitcoindev/xyv6XTAFIPmbG1yvB0l2N3c9sWAt6lDTG-xjIbogOZ-lc9RfsFeJ-JPuXuXKzVea8T9TztlCvSrxZOWXKCwogCy9tqa49l3LXjF5K2cLtP4%3D%40protonmail.com.

--b1=_zaqQvmDDQHbTdw1KU4fVuG8d0QUJBATmaaN0eNsbl0
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div style=3D"font-family: Arial, sans-serif; font-size: 14px;"><span style=
=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: normal; f=
ont-weight: 400;"></span></div><span style=3D"font-family: Arial, sans-seri=
f; font-size: 14px; line-height: normal; font-weight: 400;">Hi All,</span><=
div><br></div><div><span style=3D"font-family: Arial, sans-serif; font-size=
: 14px; line-height: normal; font-weight: 400;">We propose to add a new opc=
ode to tapscript, the newest member of the LNhance</span></div><div><span s=
tyle=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: norma=
l; font-weight: 400;">opcode family, OP_PAIRCOMMIT.</span></div><div><br></=
div><div><span style=3D"font-family: Arial, sans-serif; font-size: 14px; li=
ne-height: normal; font-weight: 400;">LNhance is a package deal of CTV + CS=
FS + IKEY + PC specifically designed to</span></div><div><span style=3D"fon=
t-family: Arial, sans-serif; font-size: 14px; line-height: normal; font-wei=
ght: 400;">enable efficient rebindable channels, that can be grafted to a v=
ariety of</span></div><span style=3D"font-family: Arial, sans-serif; font-s=
ize: 14px; line-height: normal; font-weight: 400;">covenant tree / channel =
factory constructions.</span><div><br></div><div><span style=3D"font-family=
: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: 400=
;">When evaluated, the `OP_PAIRCOMMIT` instruction:</span></div><div><span =
style=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: norm=
al; font-weight: 400;">* Pops the top two values off the stack,</span></div=
><div><span style=3D"font-family: Arial, sans-serif; font-size: 14px; line-=
height: normal; font-weight: 400;">* takes the "PairCommit" tagged SHA256 h=
ash of the stack elements,</span></div><div><span style=3D"font-family: Ari=
al, sans-serif; font-size: 14px; line-height: normal; font-weight: 400;">* =
pushes the resulting commitment on the top of the stack.</span></div><div><=
br></div><div><span style=3D"font-family: Arial, sans-serif; font-size: 14p=
x; line-height: normal; font-weight: 400;"><a href=3D"https://gist.github.c=
om/moonsettler/d7f1fb88e3e54ee7ecb6d69ff126433b" title=3D"https://gist.gith=
ub.com/moonsettler/d7f1fb88e3e54ee7ecb6d69ff126433b">https://gist.github.co=
m/moonsettler/d7f1fb88e3e54ee7ecb6d69ff126433b</a></span></div><div><br></d=
iv><div><span style=3D"font-family: Arial, sans-serif; font-size: 14px; lin=
e-height: normal; font-weight: 400;">PR: 1699 to <a href=3D"https://github.=
com/bitcoin/bips" title=3D"https://github.com/bitcoin/bips">https://github.=
com/bitcoin/bips</a><br></span></div><div><br></div><span style=3D"font-fam=
ily: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: =
400;">Q: Why not CAT?</span><div><br></div><div><span style=3D"font-family:=
 Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: 400;=
">A: OP_PAIRCOMMIT was specifically introduced so that we don't have a depe=
ndency</span></div><div><span style=3D"font-family: Arial, sans-serif; font=
-size: 14px; line-height: normal; font-weight: 400;">on CAT for efficient L=
N-Symmetry construction. If we already had CAT or had</span></div><div><spa=
n style=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: no=
rmal; font-weight: 400;">reasonable assurances that CAT will be activated s=
oon, the balance of tradeoffs</span></div><div><span style=3D"font-family: =
Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: 400;"=
>might have tipped against a late introduction of a new opcode to a concept=
 that</span></div><div><span style=3D"font-family: Arial, sans-serif; font-=
size: 14px; line-height: normal; font-weight: 400;">was already floating ou=
t there.</span></div><div><br></div><div><span style=3D"font-family: Arial,=
 sans-serif; font-size: 14px; line-height: normal; font-weight: 400;">Q: Wh=
at is the difference between PAIRCOMMIT and CAT?</span></div><div><br></div=
><div><span style=3D"font-family: Arial, sans-serif; font-size: 14px; line-=
height: normal; font-weight: 400;">A: PAIRCOMMIT is domain separated from o=
ther implicit uses of hashing pieces of</span></div><div><span style=3D"fon=
t-family: Arial, sans-serif; font-size: 14px; line-height: normal; font-wei=
ght: 400;">data together. CAT allows for reconstructing and therefore inspe=
cting sighashes</span></div><div><span style=3D"font-family: Arial, sans-se=
rif; font-size: 14px; line-height: normal; font-weight: 400;">on the stack.=
 And not only it allows for fine grained introspection, it also</span></div=
><div><span style=3D"font-family: Arial, sans-serif; font-size: 14px; line-=
height: normal; font-weight: 400;">allows for inspecting ancestor transacti=
ons. This makes CAT with the Poelstra</span></div><div><span style=3D"font-=
family: Arial, sans-serif; font-size: 14px; line-height: normal; font-weigh=
t: 400;">trick a way to implement state carrying covenants.</span></div><di=
v><span style=3D"font-family: Arial, sans-serif; font-size: 14px; line-heig=
ht: normal; font-weight: 400;">* If CAT has consensus, PAIRCOMMIT is an opt=
imization of which we already have</span></div><div><span style=3D"font-fam=
ily: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: =
400;">plenty examples of in script</span></div><div><span style=3D"font-fam=
ily: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: =
400;">* If CAT has no consensus, PAIRCOMMIT gets the job done in regards to=
 a very</span></div><span style=3D"font-family: Arial, sans-serif; font-siz=
e: 14px; line-height: normal; font-weight: 400;">specific subset of behavio=
rs, that explicitly do not include introspection.</span><div style=3D""><di=
v></div><br></div><div style=3D""><span style=3D"font-family: Arial, sans-s=
erif; font-size: 14px; line-height: normal; font-weight: 400;">BR.</span></=
div><div style=3D""><span style=3D"font-family: Arial, sans-serif; font-siz=
e: 14px; line-height: normal; font-weight: 400;">moonsettler</span></div><d=
iv style=3D""><br></div><div style=3D""><span style=3D"font-family: Arial, =
sans-serif; font-size: 14px; line-height: normal; font-weight: 400;">------=
--------------------------------------------------------------------------<=
/span><br></div><pre><span style=3D"font-family: Arial, sans-serif; font-si=
ze: 14px; line-height: normal; font-weight: 400;">&lt;pre&gt;</span><div><s=
pan style=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: =
normal; font-weight: 400;">&nbsp; BIP: ?</span></div><div><span style=3D"fo=
nt-family: Arial, sans-serif; font-size: 14px; line-height: normal; font-we=
ight: 400;">&nbsp; Layer: Consensus (soft fork)</span></div><div><span styl=
e=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: normal; =
font-weight: 400;">&nbsp; Title: OP_PAIRCOMMIT</span></div><div><span style=
=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: normal; f=
ont-weight: 400;">&nbsp; Author: moonsettler &lt;</span><span style=3D"font=
-family: Arial, sans-serif; font-size: 14px; line-height: normal; font-weig=
ht: 400;">moonsettler@protonmail.com</span><span style=3D"font-family: Aria=
l, sans-serif; font-size: 14px; line-height: normal; font-weight: 400;">&gt=
;</span></div><div><span style=3D"font-family: Arial, sans-serif; font-size=
: 14px; line-height: normal; font-weight: 400;">&nbsp; Comments-Summary: No=
 comments yet.</span></div><div><span style=3D"font-family: Arial, sans-ser=
if; font-size: 14px; line-height: normal; font-weight: 400;">&nbsp; Comment=
s-URI: &lt;links to wiki page for comments&gt;</span></div><div><span style=
=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: normal; f=
ont-weight: 400;">&nbsp; Status: Draft</span></div><div><span style=3D"font=
-family: Arial, sans-serif; font-size: 14px; line-height: normal; font-weig=
ht: 400;">&nbsp; Type: Standards Track</span></div><div><span style=3D"font=
-family: Arial, sans-serif; font-size: 14px; line-height: normal; font-weig=
ht: 400;">&nbsp; Created: 2024-11-08</span></div><div><span style=3D"font-f=
amily: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight=
: 400;">&nbsp; License: BSD-3-CLAUSE</span></div><div><span style=3D"font-f=
amily: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight=
: 400;">&lt;/pre&gt;</span></div><div><br></div><div><span style=3D"font-fa=
mily: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight:=
 400;">## Abstract</span></div><div><br></div><div><span style=3D"font-fami=
ly: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: 4=
00;">This BIP describes a new tapscript opcode `OP_PAIRCOMMIT` which</span>=
</div><div><span style=3D"font-family: Arial, sans-serif; font-size: 14px; =
line-height: normal; font-weight: 400;">provide limited vector commitment f=
unctionality in tapscript.</span></div><div><br></div><div><span style=3D"f=
ont-family: Arial, sans-serif; font-size: 14px; line-height: normal; font-w=
eight: 400;">When evaluated, the `OP_PAIRCOMMIT` instruction:</span></div><=
div><span style=3D"font-family: Arial, sans-serif; font-size: 14px; line-he=
ight: normal; font-weight: 400;">* Pops the top two values off the stack,</=
span></div><div><span style=3D"font-family: Arial, sans-serif; font-size: 1=
4px; line-height: normal; font-weight: 400;">* takes the "PairCommit" tagge=
d SHA256 hash of the stack elements,</span></div><div><span style=3D"font-f=
amily: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight=
: 400;">* pushes the resulting commitment on the top of the stack.</span></=
div><div><br></div><div><span style=3D"font-family: Arial, sans-serif; font=
-size: 14px; line-height: normal; font-weight: 400;">## Motivation</span></=
div><div><br></div><div><span style=3D"font-family: Arial, sans-serif; font=
-size: 14px; line-height: normal; font-weight: 400;">To do LN-Symmetry cont=
racts that don't require the nodes to keep old states,</span></div><div><sp=
an style=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: n=
ormal; font-weight: 400;">we need to solve the data availability problem pr=
esented by unilateral closes.</span></div><div><span style=3D"font-family: =
Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: 400;"=
>Channel peers must be able to reconstruct the script that spends an</span>=
</div><div><span style=3D"font-family: Arial, sans-serif; font-size: 14px; =
line-height: normal; font-weight: 400;">intermediate state.</span></div><di=
v><br></div><div><span style=3D"font-family: Arial, sans-serif; font-size: =
14px; line-height: normal; font-weight: 400;">Using in sequence `OP_CHECKTE=
MPLATEVERIFY`, `OP_PAIRCOMMIT`, `OP_INTERNALKEY`</span></div><div><span sty=
le=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: normal;=
 font-weight: 400;">and `OP_CHECKSIGFROMSTACK` we can construct a rebindabl=
e channel that is also</span></div><div><span style=3D"font-family: Arial, =
sans-serif; font-size: 14px; line-height: normal; font-weight: 400;">optima=
l.</span></div><div><br></div><div><span style=3D"font-family: Arial, sans-=
serif; font-size: 14px; line-height: normal; font-weight: 400;">If `OP_CAT`=
 was available, it could be used to combine multiple stack elements,</span>=
</div><div><span style=3D"font-family: Arial, sans-serif; font-size: 14px; =
line-height: normal; font-weight: 400;">that get verified with `OP_CHECKSIG=
FROMSTACK` as a valid state update.</span></div><div><br></div><div><span s=
tyle=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: norma=
l; font-weight: 400;">`OP_PAIRCOMMIT` solves this specific problem without =
introducing a wide range</span></div><div><span style=3D"font-family: Arial=
, sans-serif; font-size: 14px; line-height: normal; font-weight: 400;">of p=
otentially controversial new behaviors, such as novel 2-way peg mechanisms.=
</span></div><div><br></div><div><span style=3D"font-family: Arial, sans-se=
rif; font-size: 14px; line-height: normal; font-weight: 400;">The number of=
 SHA256 iterations is minimized in the primary use case we</span></div><div=
><span style=3D"font-family: Arial, sans-serif; font-size: 14px; line-heigh=
t: normal; font-weight: 400;">can optimize for, which is LN-Symmetry. Since=
 the Tag can be pre-computed as</span></div><div><span style=3D"font-family=
: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: 400=
;">mid-state, it would only take 1 or 2 hash cycles in validation for the</=
span></div><div><span style=3D"font-family: Arial, sans-serif; font-size: 1=
4px; line-height: normal; font-weight: 400;">unilateral close scenario.</sp=
an></div><div><br></div><div><span style=3D"font-family: Arial, sans-serif;=
 font-size: 14px; line-height: normal; font-weight: 400;">## Specification<=
/span></div><div><br></div><div><span style=3D"font-family: Arial, sans-ser=
if; font-size: 14px; line-height: normal; font-weight: 400;">Repurpose opco=
de 205 (currently `OP_SUCCESS`) as follows:</span></div><div><br></div><div=
><span style=3D"font-family: Arial, sans-serif; font-size: 14px; line-heigh=
t: normal; font-weight: 400;">`OP_PAIRCOMMIT` pops two elements off the sta=
ck, then concatenates them along</span></div><div><span style=3D"font-famil=
y: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: 40=
0;">with their size commitments and takes the tagged SHA256 hash of that</s=
pan></div><div><span style=3D"font-family: Arial, sans-serif; font-size: 14=
px; line-height: normal; font-weight: 400;">concatenated string, then pushe=
s the resulting hash back on the stack.</span></div><div><br></div><div><sp=
an style=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: n=
ormal; font-weight: 400;">Given the stack `[x1, x2]`, where `x2` is at the =
top of the stack:</span></div><div><br></div><div><span style=3D"font-famil=
y: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: 40=
0;">`OP_PAIRCOMMIT` will push `SHA256(tagPC|cs(x1)|x1|cs(x2)|x2)` onto the =
stack.</span></div><div><br></div><div><span style=3D"font-family: Arial, s=
ans-serif; font-size: 14px; line-height: normal; font-weight: 400;">Where `=
|` denotes concatenation and `tagPC` is calculated according to BIP-340</sp=
an></div><div><span style=3D"font-family: Arial, sans-serif; font-size: 14p=
x; line-height: normal; font-weight: 400;">tagged hash as `SHA256("PairComm=
it")|SHA256("PairCommit")` and `cs(x)` means</span></div><div><span style=
=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: normal; f=
ont-weight: 400;">`CompactSize(x)`.</span></div><div><br></div><div><span s=
tyle=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: norma=
l; font-weight: 400;">### Implementation</span></div><div><br></div><div><s=
pan style=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: =
normal; font-weight: 400;">```c++</span></div><div><span style=3D"font-fami=
ly: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: 4=
00;">case OP_PAIRCOMMIT: {</span></div><div><span style=3D"font-family: Ari=
al, sans-serif; font-size: 14px; line-height: normal; font-weight: 400;">&n=
bsp; &nbsp; // OP_PAIRCOMMIT is only available in Tapscript</span></div><di=
v><span style=3D"font-family: Arial, sans-serif; font-size: 14px; line-heig=
ht: normal; font-weight: 400;">&nbsp; &nbsp; // ...</span></div><div><span =
style=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: norm=
al; font-weight: 400;">&nbsp; &nbsp; // x1 x2 -- hash</span></div><div><spa=
n style=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: no=
rmal; font-weight: 400;">&nbsp; &nbsp; if (stack.size() &lt; 2) {</span></d=
iv><div><span style=3D"font-family: Arial, sans-serif; font-size: 14px; lin=
e-height: normal; font-weight: 400;">&nbsp; &nbsp; &nbsp; &nbsp; return set=
_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);</span></div><div><span =
style=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: norm=
al; font-weight: 400;">&nbsp; &nbsp; }</span></div><div><span style=3D"font=
-family: Arial, sans-serif; font-size: 14px; line-height: normal; font-weig=
ht: 400;">&nbsp; &nbsp; const valtype&amp; vch1 =3D stacktop(-2);</span></d=
iv><div><span style=3D"font-family: Arial, sans-serif; font-size: 14px; lin=
e-height: normal; font-weight: 400;">&nbsp; &nbsp; const valtype&amp; vch2 =
=3D stacktop(-1);</span></div><div><br></div><div><span style=3D"font-famil=
y: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: 40=
0;">&nbsp; &nbsp; uint256 hash =3D PairCommitHash(vch1, vch2);</span></div>=
<div><br></div><div><span style=3D"font-family: Arial, sans-serif; font-siz=
e: 14px; line-height: normal; font-weight: 400;">&nbsp; &nbsp; popstack(sta=
ck);</span></div><div><span style=3D"font-family: Arial, sans-serif; font-s=
ize: 14px; line-height: normal; font-weight: 400;">&nbsp; &nbsp; popstack(s=
tack);</span></div><div><span style=3D"font-family: Arial, sans-serif; font=
-size: 14px; line-height: normal; font-weight: 400;">&nbsp; &nbsp; stack.em=
place_back(hash.begin(), hash.end());</span></div><div><span style=3D"font-=
family: Arial, sans-serif; font-size: 14px; line-height: normal; font-weigh=
t: 400;">&nbsp; &nbsp; break;</span></div><div><span style=3D"font-family: =
Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: 400;"=
>}</span></div><div><span style=3D"font-family: Arial, sans-serif; font-siz=
e: 14px; line-height: normal; font-weight: 400;">```</span></div><div><span=
 style=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: nor=
mal; font-weight: 400;">```c++</span></div><div><span style=3D"font-family:=
 Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: 400;=
">const HashWriter HASHER_PAIRCOMMIT{TaggedHash("PairCommit")};</span></div=
><div><br></div><div><span style=3D"font-family: Arial, sans-serif; font-si=
ze: 14px; line-height: normal; font-weight: 400;">uint256 PairCommitHash(co=
nst std::vector&lt;unsigned char&gt;&amp; x1, const std::vector&lt;unsigned=
 char&gt;&amp; x2)</span></div><div><span style=3D"font-family: Arial, sans=
-serif; font-size: 14px; line-height: normal; font-weight: 400;">{</span></=
div><div><span style=3D"font-family: Arial, sans-serif; font-size: 14px; li=
ne-height: normal; font-weight: 400;">&nbsp; &nbsp; return (HashWriter{HASH=
ER_PAIRCOMMIT} &lt;&lt; x1 &lt;&lt; x2).GetSHA256();</span></div><div><span=
 style=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: nor=
mal; font-weight: 400;">}</span></div><div><span style=3D"font-family: Aria=
l, sans-serif; font-size: 14px; line-height: normal; font-weight: 400;">```=
</span></div><div><span style=3D"font-family: Arial, sans-serif; font-size:=
 14px; line-height: normal; font-weight: 400;">### Use in script</span></di=
v><div><br></div><div><span style=3D"font-family: Arial, sans-serif; font-s=
ize: 14px; line-height: normal; font-weight: 400;">`OP_PAIRCOMMIT` can be u=
sed to commit to a vector of stack elements in a way</span></div><div><span=
 style=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: nor=
mal; font-weight: 400;">that is not vulnerable to various forms of witness =
malleability. It is however,</span></div><div><span style=3D"font-family: A=
rial, sans-serif; font-size: 14px; line-height: normal; font-weight: 400;">=
highly optimized for just 2 stack elements.</span></div><div><br></div><div=
><span style=3D"font-family: Arial, sans-serif; font-size: 14px; line-heigh=
t: normal; font-weight: 400;">```text</span></div><div><span style=3D"font-=
family: Arial, sans-serif; font-size: 14px; line-height: normal; font-weigh=
t: 400;"># pc-hash =3D PC(a, PC(b, c))</span></div><div><br></div><div><spa=
n style=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: no=
rmal; font-weight: 400;">&lt;a&gt; &lt;b&gt; &lt;c&gt; | PC PC &lt;pc-hash&=
gt; OP_EQUALVERIFY</span></div><div><span style=3D"font-family: Arial, sans=
-serif; font-size: 14px; line-height: normal; font-weight: 400;">```</span>=
</div><div><br></div><div><span style=3D"font-family: Arial, sans-serif; fo=
nt-size: 14px; line-height: normal; font-weight: 400;">### Use in LN-Symmet=
ry</span></div><div><br></div><div><span style=3D"font-family: Arial, sans-=
serif; font-size: 14px; line-height: normal; font-weight: 400;">The followi=
ng assembly-like pseudo-code shows a possible LN-Symmetry channel</span></d=
iv><div><span style=3D"font-family: Arial, sans-serif; font-size: 14px; lin=
e-height: normal; font-weight: 400;">construction, that provides data avail=
ability to spend to the latest state from</span></div><div><span style=3D"f=
ont-family: Arial, sans-serif; font-size: 14px; line-height: normal; font-w=
eight: 400;">an earlier state pushed on-chain with a forced close by channe=
l partner.</span></div><div><br></div><div><br></div><div><span style=3D"fo=
nt-family: Arial, sans-serif; font-size: 14px; line-height: normal; font-we=
ight: 400;">```text</span></div><div><span style=3D"font-family: Arial, san=
s-serif; font-size: 14px; line-height: normal; font-weight: 400;"># S =3D 5=
00000000</span></div><div><span style=3D"font-family: Arial, sans-serif; fo=
nt-size: 14px; line-height: normal; font-weight: 400;"># IK -&gt; A+B</span=
></div><div><span style=3D"font-family: Arial, sans-serif; font-size: 14px;=
 line-height: normal; font-weight: 400;">&lt;sig&gt; &lt;state-n-recovery-d=
ata&gt; &lt;state-n-hash&gt; | CTV PC IK CSFS &lt;S+1&gt; CLTV DROP</span><=
/div><div><span style=3D"font-family: Arial, sans-serif; font-size: 14px; l=
ine-height: normal; font-weight: 400;">```</span></div><div><span style=3D"=
font-family: Arial, sans-serif; font-size: 14px; line-height: normal; font-=
weight: 400;">before funding sign first state template:</span></div><div><s=
pan style=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: =
normal; font-weight: 400;">```text</span></div><div><span style=3D"font-fam=
ily: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: =
400;"># state-n-hash { nLockTime(S+n), out(contract, amount(A)+amount(B)) }=
</span></div><div><span style=3D"font-family: Arial, sans-serif; font-size:=
 14px; line-height: normal; font-weight: 400;"># settlement-n-hash { nSeque=
nce(2w), out(A, amount(A)), out(B, amount(B)) }</span></div><div><span styl=
e=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: normal; =
font-weight: 400;"># state-n-recovery-data { settlement-n-hash or state-n-b=
alance }</span></div><div><br></div><div><span style=3D"font-family: Arial,=
 sans-serif; font-size: 14px; line-height: normal; font-weight: 400;"># con=
tract for state n &lt; m</span></div><div><span style=3D"font-family: Arial=
, sans-serif; font-size: 14px; line-height: normal; font-weight: 400;">IF</=
span></div><div><span style=3D"font-family: Arial, sans-serif; font-size: 1=
4px; line-height: normal; font-weight: 400;">&nbsp; &lt;sig&gt; &lt;state-m=
-recovery-data&gt; &lt;state-m-hash&gt; | CTV PC IK CSFS &lt;S+n+1&gt; CLTV=
 DROP</span></div><div><span style=3D"font-family: Arial, sans-serif; font-=
size: 14px; line-height: normal; font-weight: 400;">ELSE</span></div><div><=
span style=3D"font-family: Arial, sans-serif; font-size: 14px; line-height:=
 normal; font-weight: 400;">&nbsp; &lt;settlement-n-hash&gt; CTV</span></di=
v><div><span style=3D"font-family: Arial, sans-serif; font-size: 14px; line=
-height: normal; font-weight: 400;">ENDIF</span></div><div><span style=3D"f=
ont-family: Arial, sans-serif; font-size: 14px; line-height: normal; font-w=
eight: 400;">```</span></div><div><br></div><div><span style=3D"font-family=
: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: 400=
;">## Reference Implementation</span></div><div><br></div><div><span style=
=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: normal; f=
ont-weight: 400;">A reference implementation is provided here:</span></div>=
<div><br></div><div><span style=3D"font-family: Arial, sans-serif; font-siz=
e: 14px; line-height: normal; font-weight: 400;">https://github.com/lnhance=
/bitcoin/pull/6/files</span></div><div><br></div><div><span style=3D"font-f=
amily: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight=
: 400;">## Backward Compatibility</span></div><div><br></div><div><span sty=
le=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: normal;=
 font-weight: 400;">By constraining the behavior of OP_SUCCESS opcodes, dep=
loyment of the BIP</span></div><div><span style=3D"font-family: Arial, sans=
-serif; font-size: 14px; line-height: normal; font-weight: 400;">can be don=
e in a backwards compatible, soft-fork manner. If anyone were to</span></di=
v><div><span style=3D"font-family: Arial, sans-serif; font-size: 14px; line=
-height: normal; font-weight: 400;">rely on the OP_SUCCESS behavior of `OP_=
SUCCESS205`, `OP_PAIRCOMMIT` would</span></div><div><span style=3D"font-fam=
ily: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: =
400;">invalidate their spend.</span></div><div><br></div><div><span style=
=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: normal; f=
ont-weight: 400;">## Deployment</span></div><div><br></div><div><span style=
=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: normal; f=
ont-weight: 400;">TBD</span></div><div><br></div><div><span style=3D"font-f=
amily: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight=
: 400;">## Credits</span></div><div><br></div><div><span style=3D"font-fami=
ly: Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: 4=
00;">Jeremy Rubin, Brandon Black, Salvatore Ingala, Anthony Towns</span></d=
iv><div><br></div><div><span style=3D"font-family: Arial, sans-serif; font-=
size: 14px; line-height: normal; font-weight: 400;">## Copyright</span></di=
v><div><br></div><div><span style=3D"font-family: Arial, sans-serif; font-s=
ize: 14px; line-height: normal; font-weight: 400;">This document is license=
d under the 3-clause BSD license.</span></div><div><br></div><div><span sty=
le=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: normal;=
 font-weight: 400;">## References</span></div><div><br></div><div><span sty=
le=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: normal;=
 font-weight: 400;">1. LNhance bitcoin repository, [lnhance](</span><span s=
tyle=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: norma=
l; font-weight: 400;">https://github.com/lnhance/bitcoin</span><span style=
=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: normal; f=
ont-weight: 400;">)</span></div><div><span style=3D"font-family: Arial, san=
s-serif; font-size: 14px; line-height: normal; font-weight: 400;">2. LN-Sym=
metry, [eltoo](</span><span style=3D"font-family: Arial, sans-serif; font-s=
ize: 14px; line-height: normal; font-weight: 400;">https://github.com/insta=
gibbs/bolts/blob/eltoo_draft/XX-eltoo-transactions.md</span><span style=3D"=
font-family: Arial, sans-serif; font-size: 14px; line-height: normal; font-=
weight: 400;">)</span></div><div><span style=3D"font-family: Arial, sans-se=
rif; font-size: 14px; line-height: normal; font-weight: 400;">3. OP_CAT, [B=
IN-2024-0001](</span><span style=3D"font-family: Arial, sans-serif; font-si=
ze: 14px; line-height: normal; font-weight: 400;">https://github.com/bitcoi=
n-inquisition/binana/blob/master/2024/BIN-2024-0001.md</span><span style=3D=
"font-family: Arial, sans-serif; font-size: 14px; line-height: normal; font=
-weight: 400;">)</span></div><div><span style=3D"font-family: Arial, sans-s=
erif; font-size: 14px; line-height: normal; font-weight: 400;">4. OP_CHECKT=
EMPLATEVERIFY, [BIP-119](</span><span style=3D"font-family: Arial, sans-ser=
if; font-size: 14px; line-height: normal; font-weight: 400;">https://github=
.com/bitcoin/bips/tree/master/bip-0119</span><span style=3D"font-family: Ar=
ial, sans-serif; font-size: 14px; line-height: normal; font-weight: 400;">)=
</span></div><div><span style=3D"font-family: Arial, sans-serif; font-size:=
 14px; line-height: normal; font-weight: 400;">5. OP_CHECKSIGFROMSTACK, [BI=
N-2024-0003](</span><span style=3D"font-family: Arial, sans-serif; font-siz=
e: 14px; line-height: normal; font-weight: 400;">https://github.com/bitcoin=
-inquisition/binana/blob/master/2024/BIN-2024-0003.md</span><span style=3D"=
font-family: Arial, sans-serif; font-size: 14px; line-height: normal; font-=
weight: 400;">)</span></div><div><span style=3D"font-family: Arial, sans-se=
rif; font-size: 14px; line-height: normal; font-weight: 400;">6. OP_INTERNA=
LKEY, [BIN-2024-0004](</span><span style=3D"font-family: Arial, sans-serif;=
 font-size: 14px; line-height: normal; font-weight: 400;">https://github.co=
m/bitcoin-inquisition/binana/blob/master/2024/BIN-2024-0004.md</span><span =
style=3D"font-family: Arial, sans-serif; font-size: 14px; line-height: norm=
al; font-weight: 400;">)</span></div><span style=3D"font-family: Arial, san=
s-serif; font-size: 14px; line-height: normal; font-weight: 400;">7. Tagged=
 hash, [BIP-340](</span><span style=3D"font-family: Arial, sans-serif; font=
-size: 14px; line-height: normal; font-weight: 400;">https://github.com/bit=
coin/bips/blob/master/bip-0340.mediawiki</span><span style=3D"font-family: =
Arial, sans-serif; font-size: 14px; line-height: normal; font-weight: 400;"=
>)</span></pre><div class=3D"protonmail_signature_block" style=3D"font-fami=
ly: Arial, sans-serif; font-size: 14px;"><div class=3D"protonmail_signature=
_block-proton"></div>
</div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;Bitcoin Development Mailing List&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:bitcoindev+unsubscribe@googlegroups.com">bitcoind=
ev+unsubscribe@googlegroups.com</a>.<br />
To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/=
bitcoindev/xyv6XTAFIPmbG1yvB0l2N3c9sWAt6lDTG-xjIbogOZ-lc9RfsFeJ-JPuXuXKzVea=
8T9TztlCvSrxZOWXKCwogCy9tqa49l3LXjF5K2cLtP4%3D%40protonmail.com?utm_medium=
=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid/bitcoindev/=
xyv6XTAFIPmbG1yvB0l2N3c9sWAt6lDTG-xjIbogOZ-lc9RfsFeJ-JPuXuXKzVea8T9TztlCvSr=
xZOWXKCwogCy9tqa49l3LXjF5K2cLtP4%3D%40protonmail.com</a>.<br />

--b1=_zaqQvmDDQHbTdw1KU4fVuG8d0QUJBATmaaN0eNsbl0--