Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 9885A728 for ; 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 ; 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 ; 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 Date: Tue, 27 Jun 2017 19:37:13 -0500 X-Gmail-Original-Message-ID: Message-ID: To: Bitcoin Protocol Discussion 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jun 2017 00:37:17 -0000 --001a1143f65aacaff00552fa62f8 Content-Type: text/plain; charset="UTF-8"
  BIP: 
  Layer: Consensus (Soft fork)
  Title: OP_BRIBEVERIFY
  Author: Chris Stewart 
  Status: Draft
  Type: Standards Track
  Created: 2017-06-27
==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 scriptPubKey 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
<pre>=C2=A0
=C2=A0 BIP: <BIP number><= br>=C2=A0 Layer: Consensus (Soft fork)
=C2=A0 Title: OP_BRIBEVERIFY
= =C2=A0 Author: Chris Stewart <chr= is@suredbits.com>
=C2=A0 Status: Draft
=C2=A0 Type: Standards = Track
=C2=A0 Created: 2017-06-27
</pre>


=3D=3DAbstra= ct=3D=3D

This BIP describes a new opcode, OP_BRIBEVERIFY, for the Bi= tcoin
scripting system that allows for a user to bribe a miner to includ= e a hash
in the coinbase transaction's output.


=3D=3DSumm= ary=3D=3D

BRIBEVERIFY redefines the existing NOP4 opcode. When execu= ted, if the given
critical hash is included at the given vout index in t= he coinbase transaction
the script evaluates to true. Otherwise, the scr= ipt will fail.

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

=3D=3DMotivation=3D=3D

The current political climate of bitc= oin is extremely contentious. Many community members
have different visi= ons of what bitcoin is. This op code is meant to
enable [http://www.truthcoin.info= /blog/blind-merged-mining/ Blind Merge Mining].
This enables sidech= ains in Bitcoin. With OP_BRIBEVERIFY, sidechains miners can
bribe bitco= in miners to to include their block hash in the bitcoin blockchain. If thei= r 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 o= wn separate
blockchain that is interoperable with the bitcoin blockchain= . This allows those factions to use
bitcoin as a 'reserve currency&#= 39; for their own network.


=3D=3D=3DCommitment Structure=3D=3D= =3D

A new block rule is added which requires that the miner's co= inbase 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 th= e 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 output= s on the coinbase transaction.

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

the 35th byte and onward have no consensus meaning.
=3D=3D=3DOP_BRIBEVERIFY op code=3D=3D=3D

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.
The next element on = the stack is expected to be a block hash. This op code looks into the coinb= ase transaction's output vector at the given index (which is derived fr= om 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_BR= IBEVERIFY acts as an OP_NOP. If the
comparison between the two hashes f= ail, the script fails.

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

Refer to the reference implem= entation, reproduced below, for the precise
semantics and detailed ratio= nale for those semantics.

=C2=A0
=C2=A0case OP_NOP4:
=C2=A0{=C2=A0=C2=A0=C2=A0 //format: block_hash sidechain_id OP_BRIBEVERIFY
= =C2=A0=C2=A0=C2=A0 if (!(flags & SCRIPT_VERIFY_BRIBEVERIFY)) {
=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // not enabled; treat as a NOP4
= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (flags & SCRIPT_VERIFY_DI= SCOURAGE_UPGRADABLE_NOPS) {
=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);
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break;
=C2=A0=C2=A0=C2=A0 }
=C2=A0= =C2=A0=C2=A0
=C2=A0=C2=A0=C2=A0 if (stack.size() < 2)
=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return set_error(serror, SCRIPT_ERR_INVAL= ID_STACK_OPERATION);
=C2=A0
=C2=A0=C2=A0=C2=A0 const CScriptNum scrip= tNumSidechainId(stacktop(-1),fRequireMinimal);
=C2=A0=C2=A0=C2=A0 uint8_= t nSidechainId;=C2=A0
=C2=A0=C2=A0=C2=A0 if (!checker.CheckSidechainId(= scriptNumSidechainId,nSidechainId)) {
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 return set_error(serror, SCRIPT_ERR_UNKNOWN_SIDECHAIN);
=C2= =A0=C2=A0=C2=A0 }
=C2=A0
=C2=A0=C2=A0=C2=A0 // Check block hash
= =C2=A0=C2=A0=C2=A0 bool fHashCritical =3D checker.CheckCriticalHash(stackto= p(-2),nSidechainId);
=C2=A0=C2=A0=C2=A0 if (!fHashCritical) {
=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return set_error(serror, SCRIPT_ERR_UN= SATISFIED_BRIBE);
=C2=A0=C2=A0=C2=A0 }
=C2=A0=C2=A0=C2=A0 break;
= =C2=A0}



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

=3D=3DDeployment=3D=3D

TODO
<= br>=3D=3DCredits=3D=3D

Credit to Paul Sztorc for the original idea o= f Blind Merge Mined sidechains.

Credit to CryptAxe for writing the f= oundational layer of software for drivechains so I could implement OP_BRIBE= VERIFY.


=3D=3DReferences=3D=3D

Blind Merge Mined Sidechai= ns - http:/= /www.truthcoin.info/blog/blind-merged-mining/


=3D=3DCopyright=3D= =3D

This document is placed in the public domain.
--001a1143f65aacaff00552fa62f8--