summaryrefslogtreecommitdiff
path: root/f9/596f963a38fda3565b2c041b4d52594a8c4ffb
blob: 7b22a74b90a25b0726935a9e4a102f87d9b02368 (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
Return-Path: <bounce+33760e.2c141-bitcoin-dev=lists.linuxfoundation.org@suredbits.com>
Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org
	[172.17.192.35])
	by mail.linuxfoundation.org (Postfix) with ESMTPS id 9885A728
	for <bitcoin-dev@lists.linuxfoundation.org>;
	Wed, 28 Jun 2017 00:37:17 +0000 (UTC)
X-Greylist: from auto-whitelisted by SQLgrey-1.7.6
Received: from so254-16.mailgun.net (so254-16.mailgun.net [198.61.254.16])
	by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 951BF1BB
	for <bitcoin-dev@lists.linuxfoundation.org>;
	Wed, 28 Jun 2017 00:37:16 +0000 (UTC)
DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=suredbits.com;
	q=dns/txt; 
	s=mailo; t=1498610235; h=Content-Type: To: Subject: Message-ID: Date:
	From: MIME-Version: Sender;
	bh=WanQjJsFrwfBvfy/4i/PrHJNXzNHKxGS9Lne6OqLHKg=;
	b=mgxX8946LFDPp7wSvL0D+JATECYjMoX9ucgKq5RRPDqYYnjJPC6+S/U4vNG5abUAIp4XsPUE
	dsDFTX+U8pNFUmXvWjUvwII09Y1kwVr2PCPPm/oSg85mo5iZRO0vCGJibmOGR8rJsK7GBplV
	hBgTnHhS5GFq9HuTVbyWXFm/QU8=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=suredbits.com; s=mailo;
	q=dns; h=Sender: MIME-Version: From: Date: Message-ID: Subject: To:
	Content-Type;
	b=EwBSr+5JjmOqn2vWmxQBkVlK9uv0BheEtUrB4NnnawDdI1r6HioTfpEFpKb4QRqgpF7nMR
	PyrPG83/ilWtmcNDaQmueW5ngT28h3DQLvcF6NQJKodqOSSJ4fNopGGKIRk9oG03vm/FxNoS
	v7mG7koXRdfdaZ9TZKoqE8c/Z4/KE=
Sender: chris@suredbits.com
X-Mailgun-Sending-Ip: 198.61.254.16
X-Mailgun-Sid: WyI5MGYzNyIsICJiaXRjb2luLWRldkBsaXN0cy5saW51eGZvdW5kYXRpb24ub3JnIiwgIjJjMTQxIl0=
Received: from mail-it0-f48.google.com (mail-it0-f48.google.com
	[209.85.214.48])
	by mxa.mailgun.org with ESMTP id 5952fa3b.7fc7c06f99b0-smtp-out-n02;
	Wed, 28 Jun 2017 00:37:15 -0000 (UTC)
Received: by mail-it0-f48.google.com with SMTP id v202so22314976itb.0
	for <bitcoin-dev@lists.linuxfoundation.org>;
	Tue, 27 Jun 2017 17:37:14 -0700 (PDT)
X-Gm-Message-State: AKS2vOybmixqWQf4bfwlpAgksFY5tGuK1iwI+mW2uUjLLWoJ+Kq2iEBe
	93iZ/LWKWTgTB1gEt0i4mP9zZ2O8Bg==
X-Received: by 10.36.40.196 with SMTP id h187mr3773562ith.43.1498610234335;
	Tue, 27 Jun 2017 17:37:14 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.107.185.3 with HTTP; Tue, 27 Jun 2017 17:37:13 -0700 (PDT)
From: Chris Stewart <chris@suredbits.com>
Date: Tue, 27 Jun 2017 19:37:13 -0500
X-Gmail-Original-Message-ID: <CAGL6+mHQ_vMc2JYVqwfP89WOZdUF2WDtWfh7ccL1PQve=nC+zQ@mail.gmail.com>
Message-ID: <CAGL6+mHQ_vMc2JYVqwfP89WOZdUF2WDtWfh7ccL1PQve=nC+zQ@mail.gmail.com>
To: Bitcoin Protocol Discussion <bitcoin-dev@lists.linuxfoundation.org>
Content-Type: multipart/alternative; boundary="001a1143f65aacaff00552fa62f8"
X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,
	DKIM_VALID, DKIM_VALID_AU, HTML_MESSAGE, MPART_ALT_DIFF,
	RCVD_IN_DNSWL_NONE, 
	RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on
	smtp1.linux-foundation.org
X-Mailman-Approved-At: Wed, 28 Jun 2017 02:32:11 +0000
Subject: [bitcoin-dev] BIP: OP_BRIBVERIFY - the op code needed for Blind
	Merge Mined drivechains
X-BeenThere: bitcoin-dev@lists.linuxfoundation.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: Bitcoin Protocol Discussion <bitcoin-dev.lists.linuxfoundation.org>
List-Unsubscribe: <https://lists.linuxfoundation.org/mailman/options/bitcoin-dev>,
	<mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=unsubscribe>
List-Archive: <http://lists.linuxfoundation.org/pipermail/bitcoin-dev/>
List-Post: <mailto:bitcoin-dev@lists.linuxfoundation.org>
List-Help: <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=help>
List-Subscribe: <https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev>,
	<mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=subscribe>
X-List-Received-Date: Wed, 28 Jun 2017 00:37:17 -0000

--001a1143f65aacaff00552fa62f8
Content-Type: text/plain; charset="UTF-8"

<pre>
  BIP: <BIP number>
  Layer: Consensus (Soft fork)
  Title: OP_BRIBEVERIFY
  Author: Chris Stewart <chris@suredbits.com>
  Status: Draft
  Type: Standards Track
  Created: 2017-06-27
</pre>


==Abstract==

This BIP describes a new opcode, OP_BRIBEVERIFY, for the Bitcoin
scripting system that allows for a user to bribe a miner to include a hash
in the coinbase transaction's output.


==Summary==

BRIBEVERIFY redefines the existing NOP4 opcode. When executed, if the given
critical hash is included at the given vout index in the coinbase
transaction
the script evaluates to true. Otherwise, the script will fail.

This allows sidechains to be merged mined against
bitcoin without burdening bitcoin miners with extra resource requirements.

==Motivation==

The current political climate of bitcoin is extremely contentious. Many
community members
have different visions of what bitcoin is. This op code is meant to
enable [http://www.truthcoin.info/blog/blind-merged-mining/ Blind Merge
Mining].
This enables sidechains in Bitcoin. With OP_BRIBEVERIFY, sidechains miners
can
bribe bitcoin miners to to include their block hash in the bitcoin
blockchain. If their block
is included in the coinbase transaction's vout, it is assumed that block is
a mined block on the sidechain.

This will allow various factions of the community to realize their vision
on their own separate
blockchain that is interoperable with the bitcoin blockchain. This allows
those factions to use
bitcoin as a 'reserve currency' for their own network.


===Commitment Structure===

A new block rule is added which requires that the miner's coinbase reward
be at index 0 in the coinbase transaction's output vector.

It also fixes the witness commitment output to be at index 1 of the
coinbase transaction's output vector.

This is needed so we can reliably tell what vout corresponds to what
drivechain. For instance, the mimblewimble sidechain
could correspond to index 2 of the vector outputs on the coinbase
transaction.

The commitment is recorded in a <code>scriptPubKey</code> of the coinbase
transaction. It must be at least 34 bytes in size
   1-byte - OP_RETURN (0x6a)
   1-byte - Push the following 32 bytes (0x20)
  32-byte - block hash

the 35th byte and onward have no consensus meaning.

===OP_BRIBEVERIFY op code===

This op code reads two arguments from the stack. The stack top is expected
to be a sidechain id for which this user attempting to blind merge mine for.
The next element on the stack is expected to be a block hash. This op code
looks into the coinbase transaction's output vector at the given index
(which is derived from the sidechain id) and checks
to see if the hash in the block matches the hash inside of the BRIBEVERIFY
program. If the hashes match, the OP_BRIBEVERIFY acts as an OP_NOP. If the
comparison between the two hashes fail, the script fails.

===BRIBEVERIFY program===

A standard BRIBEVERIFY program has the format:
  1-byte - Push the following 32 bytes (0x20)
 32-byte - block hash
  1 byte - Push operation? (needed if number can't be encoded as OP_0 -
OP_16)
  1 byte - sidechain id
  1 byte - OP_BRIBEVERIFY op code

==Detailed Specification==

Refer to the reference implementation, reproduced below, for the precise
semantics and detailed rationale for those semantics.


 case OP_NOP4:
 {
    //format: block_hash sidechain_id OP_BRIBEVERIFY
    if (!(flags & SCRIPT_VERIFY_BRIBEVERIFY)) {
        // not enabled; treat as a NOP4
        if (flags & SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS) {
            return set_error(serror, SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS);
        }
        break;
    }

    if (stack.size() < 2)
        return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);

    const CScriptNum scriptNumSidechainId(stacktop(-1),fRequireMinimal);
    uint8_t nSidechainId;
    if (!checker.CheckSidechainId(scriptNumSidechainId,nSidechainId)) {
        return set_error(serror, SCRIPT_ERR_UNKNOWN_SIDECHAIN);
    }

    // Check block hash
    bool fHashCritical =
checker.CheckCriticalHash(stacktop(-2),nSidechainId);
    if (!fHashCritical) {
        return set_error(serror, SCRIPT_ERR_UNSATISFIED_BRIBE);
    }
    break;
 }



https://github.com/Christewart/bitcoin/blob/94b6f33f2278c42d4d8758a3c8ffe2078e4ec933/src/script/interpreter.cpp#L427

https://github.com/drivechain-project/bitcoin/pull/13

==Deployment==

TODO

==Credits==

Credit to Paul Sztorc for the original idea of Blind Merge Mined sidechains.

Credit to CryptAxe for writing the foundational layer of software for
drivechains so I could implement OP_BRIBEVERIFY.


==References==

Blind Merge Mined Sidechains -
http://www.truthcoin.info/blog/blind-merged-mining/

Mailing list discussion -
https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-May/014408.html

==Copyright==

This document is placed in the public domain.

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

<div dir=3D"ltr"><div>&lt;pre&gt;=C2=A0 <br>=C2=A0 BIP: &lt;BIP number&gt;<=
br>=C2=A0 Layer: Consensus (Soft fork)<br>=C2=A0 Title: OP_BRIBEVERIFY<br>=
=C2=A0 Author: Chris Stewart &lt;<a href=3D"mailto:chris@suredbits.com">chr=
is@suredbits.com</a>&gt;<br>=C2=A0 Status: Draft<br>=C2=A0 Type: Standards =
Track<br>=C2=A0 Created: 2017-06-27<br>&lt;/pre&gt;<br><br><br>=3D=3DAbstra=
ct=3D=3D<br><br>This BIP describes a new opcode, OP_BRIBEVERIFY, for the Bi=
tcoin<br>scripting system that allows for a user to bribe a miner to includ=
e a hash<br>in the coinbase transaction&#39;s output.<br><br><br>=3D=3DSumm=
ary=3D=3D<br><br>BRIBEVERIFY redefines the existing NOP4 opcode. When execu=
ted, if the given<br>critical hash is included at the given vout index in t=
he coinbase transaction<br>the script evaluates to true. Otherwise, the scr=
ipt will fail.<br><br>This allows sidechains to be merged mined against <br=
>bitcoin without burdening bitcoin miners with extra resource requirements.=
<br><br>=3D=3DMotivation=3D=3D<br><br>The current political climate of bitc=
oin is extremely contentious. Many community members<br>have different visi=
ons of what bitcoin is. This op code is meant to <br>enable [<a href=3D"htt=
p://www.truthcoin.info/blog/blind-merged-mining/">http://www.truthcoin.info=
/blog/blind-merged-mining/</a> Blind Merge Mining]. <br>This enables sidech=
ains in Bitcoin. With OP_BRIBEVERIFY, sidechains miners can <br>bribe bitco=
in miners to to include their block hash in the bitcoin blockchain. If thei=
r block<br></div>is included in the coinbase transaction&#39;s vout, it is =
assumed that block is a mined block on the sidechain.<br><div><br>This will=
 allow various factions of the community to realize their vision on their o=
wn separate<br>blockchain that is interoperable with the bitcoin blockchain=
. This allows those factions to use<br>bitcoin as a &#39;reserve currency&#=
39; for their own network. <br><br><br>=3D=3D=3DCommitment Structure=3D=3D=
=3D<br><br>A new block rule is added which requires that the miner&#39;s co=
inbase reward be at index 0 in the coinbase transaction&#39;s output vector=
.<br><br>It also fixes the witness commitment output to be at index 1 of th=
e coinbase transaction&#39;s output vector.<br><br>This is needed so we can=
 reliably tell what vout corresponds to what drivechain. For instance, the =
mimblewimble sidechain <br>could correspond to index 2 of the vector output=
s on the coinbase transaction. <br><br>The commitment is recorded in a &lt;=
code&gt;scriptPubKey&lt;/code&gt; of the coinbase transaction. It must be a=
t least 34 bytes in size <br>=C2=A0=C2=A0 1-byte - OP_RETURN (0x6a)<br>=C2=
=A0=C2=A0 1-byte - Push the following 32 bytes (0x20)<br>=C2=A0 32-byte - b=
lock hash<br><br>the 35th byte and onward have no consensus meaning. <br><b=
r>=3D=3D=3DOP_BRIBEVERIFY op code=3D=3D=3D<br><br>This op code reads two ar=
guments from the stack. The stack top is expected to be a sidechain id for =
which this user attempting to blind merge mine for.<br>The next element on =
the stack is expected to be a block hash. This op code looks into the coinb=
ase transaction&#39;s output vector at the given index (which is derived fr=
om the sidechain id) and checks <br>to see if the hash in the block matches=
 the hash inside of the BRIBEVERIFY program. If the hashes match, the OP_BR=
IBEVERIFY acts as an OP_NOP. If the <br>comparison between the two hashes f=
ail, the script fails. <br><br>=3D=3D=3DBRIBEVERIFY program=3D=3D=3D<br><br=
>A standard BRIBEVERIFY program has the format:<br>=C2=A0 1-byte - Push the=
 following 32 bytes (0x20)<br>=C2=A032-byte - block hash<br>=C2=A0 1 byte -=
 Push operation? (needed if number can&#39;t be encoded as OP_0 - OP_16)<br=
>=C2=A0 1 byte - sidechain id<br>=C2=A0 1 byte - OP_BRIBEVERIFY op code<br>=
<br>=3D=3DDetailed Specification=3D=3D<br><br>Refer to the reference implem=
entation, reproduced below, for the precise<br>semantics and detailed ratio=
nale for those semantics.<br><br>=C2=A0<br>=C2=A0case OP_NOP4:<br>=C2=A0{<b=
r>=C2=A0=C2=A0=C2=A0 //format: block_hash sidechain_id OP_BRIBEVERIFY <br>=
=C2=A0=C2=A0=C2=A0 if (!(flags &amp; SCRIPT_VERIFY_BRIBEVERIFY)) {<br>=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // not enabled; treat as a NOP4<br>=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (flags &amp; SCRIPT_VERIFY_DI=
SCOURAGE_UPGRADABLE_NOPS) {<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 return set_error(serror, SCRIPT_ERR_DISCOURAGE_UPG=
RADABLE_NOPS);<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }<br>=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break;<br>=C2=A0=C2=A0=C2=A0 }<br>=C2=A0=
=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2=A0 if (stack.size() &lt; 2)<br>=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return set_error(serror, SCRIPT_ERR_INVAL=
ID_STACK_OPERATION);<br>=C2=A0<br>=C2=A0=C2=A0=C2=A0 const CScriptNum scrip=
tNumSidechainId(stacktop(-1),fRequireMinimal);<br>=C2=A0=C2=A0=C2=A0 uint8_=
t nSidechainId;=C2=A0 <br>=C2=A0=C2=A0=C2=A0 if (!checker.CheckSidechainId(=
scriptNumSidechainId,nSidechainId)) {<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 return set_error(serror, SCRIPT_ERR_UNKNOWN_SIDECHAIN); <br>=C2=
=A0=C2=A0=C2=A0 }<br>=C2=A0<br>=C2=A0=C2=A0=C2=A0 // Check block hash<br>=
=C2=A0=C2=A0=C2=A0 bool fHashCritical =3D checker.CheckCriticalHash(stackto=
p(-2),nSidechainId);<br>=C2=A0=C2=A0=C2=A0 if (!fHashCritical) {<br>=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return set_error(serror, SCRIPT_ERR_UN=
SATISFIED_BRIBE); <br>=C2=A0=C2=A0=C2=A0 }<br>=C2=A0=C2=A0=C2=A0 break;<br>=
=C2=A0}<br><br><br><br><a href=3D"https://github.com/Christewart/bitcoin/bl=
ob/94b6f33f2278c42d4d8758a3c8ffe2078e4ec933/src/script/interpreter.cpp#L427=
">https://github.com/Christewart/bitcoin/blob/94b6f33f2278c42d4d8758a3c8ffe=
2078e4ec933/src/script/interpreter.cpp#L427</a><br><br><a href=3D"https://g=
ithub.com/drivechain-project/bitcoin/pull/13">https://github.com/drivechain=
-project/bitcoin/pull/13</a><br><br>=3D=3DDeployment=3D=3D<br><br>TODO<br><=
br>=3D=3DCredits=3D=3D<br><br>Credit to Paul Sztorc for the original idea o=
f Blind Merge Mined sidechains.<br><br>Credit to CryptAxe for writing the f=
oundational layer of software for drivechains so I could implement OP_BRIBE=
VERIFY.<br><br><br>=3D=3DReferences=3D=3D<br><br>Blind Merge Mined Sidechai=
ns - <a href=3D"http://www.truthcoin.info/blog/blind-merged-mining/">http:/=
/www.truthcoin.info/blog/blind-merged-mining/</a><br><br></div><div>Mailing=
 list discussion - <a href=3D"https://lists.linuxfoundation.org/pipermail/b=
itcoin-dev/2017-May/014408.html">https://lists.linuxfoundation.org/pipermai=
l/bitcoin-dev/2017-May/014408.html</a><br></div><div><br>=3D=3DCopyright=3D=
=3D<br><br>This document is placed in the public domain.<br></div></div>

--001a1143f65aacaff00552fa62f8--