<oembed><type>rich</type><version>1.0</version><author_name>npub1u03cz099kt69z9awg232rjvlt34azukpzkkvy5uqv64dj9j5fqtshdnn03</author_name><author_url>https://nostr.ae/npub1u03cz099kt69z9awg232rjvlt34azukpzkkvy5uqv64dj9j5fqtshdnn03</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2017-06-27&#xA;📝 Original message:&lt;pre&gt;&#xA;  BIP: &lt;BIP number&gt;&#xA;  Layer: Consensus (Soft fork)&#xA;  Title: OP_BRIBEVERIFY&#xA;  Author: Chris Stewart &lt;chris at suredbits.com&gt;&#xA;  Status: Draft&#xA;  Type: Standards Track&#xA;  Created: 2017-06-27&#xA;&lt;/pre&gt;&#xA;&#xA;&#xA;==Abstract==&#xA;&#xA;This BIP describes a new opcode, OP_BRIBEVERIFY, for the Bitcoin&#xA;scripting system that allows for a user to bribe a miner to include a hash&#xA;in the coinbase transaction&#39;s output.&#xA;&#xA;&#xA;==Summary==&#xA;&#xA;BRIBEVERIFY redefines the existing NOP4 opcode. When executed, if the given&#xA;critical hash is included at the given vout index in the coinbase&#xA;transaction&#xA;the script evaluates to true. Otherwise, the script will fail.&#xA;&#xA;This allows sidechains to be merged mined against&#xA;bitcoin without burdening bitcoin miners with extra resource requirements.&#xA;&#xA;==Motivation==&#xA;&#xA;The current political climate of bitcoin is extremely contentious. Many&#xA;community members&#xA;have different visions of what bitcoin is. This op code is meant to&#xA;enable [http://www.truthcoin.info/blog/blind-merged-mining/ Blind Merge&#xA;Mining].&#xA;This enables sidechains in Bitcoin. With OP_BRIBEVERIFY, sidechains miners&#xA;can&#xA;bribe bitcoin miners to to include their block hash in the bitcoin&#xA;blockchain. If their block&#xA;is included in the coinbase transaction&#39;s vout, it is assumed that block is&#xA;a mined block on the sidechain.&#xA;&#xA;This will allow various factions of the community to realize their vision&#xA;on their own separate&#xA;blockchain that is interoperable with the bitcoin blockchain. This allows&#xA;those factions to use&#xA;bitcoin as a &#39;reserve currency&#39; for their own network.&#xA;&#xA;&#xA;===Commitment Structure===&#xA;&#xA;A new block rule is added which requires that the miner&#39;s coinbase reward&#xA;be at index 0 in the coinbase transaction&#39;s output vector.&#xA;&#xA;It also fixes the witness commitment output to be at index 1 of the&#xA;coinbase transaction&#39;s output vector.&#xA;&#xA;This is needed so we can reliably tell what vout corresponds to what&#xA;drivechain. For instance, the mimblewimble sidechain&#xA;could correspond to index 2 of the vector outputs on the coinbase&#xA;transaction.&#xA;&#xA;The commitment is recorded in a &lt;code&gt;scriptPubKey&lt;/code&gt; of the coinbase&#xA;transaction. It must be at least 34 bytes in size&#xA;   1-byte - OP_RETURN (0x6a)&#xA;   1-byte - Push the following 32 bytes (0x20)&#xA;  32-byte - block hash&#xA;&#xA;the 35th byte and onward have no consensus meaning.&#xA;&#xA;===OP_BRIBEVERIFY op code===&#xA;&#xA;This op code reads two arguments from the stack. The stack top is expected&#xA;to be a sidechain id for which this user attempting to blind merge mine for.&#xA;The next element on the stack is expected to be a block hash. This op code&#xA;looks into the coinbase transaction&#39;s output vector at the given index&#xA;(which is derived from the sidechain id) and checks&#xA;to see if the hash in the block matches the hash inside of the BRIBEVERIFY&#xA;program. If the hashes match, the OP_BRIBEVERIFY acts as an OP_NOP. If the&#xA;comparison between the two hashes fail, the script fails.&#xA;&#xA;===BRIBEVERIFY program===&#xA;&#xA;A standard BRIBEVERIFY program has the format:&#xA;  1-byte - Push the following 32 bytes (0x20)&#xA; 32-byte - block hash&#xA;  1 byte - Push operation? (needed if number can&#39;t be encoded as OP_0 -&#xA;OP_16)&#xA;  1 byte - sidechain id&#xA;  1 byte - OP_BRIBEVERIFY op code&#xA;&#xA;==Detailed Specification==&#xA;&#xA;Refer to the reference implementation, reproduced below, for the precise&#xA;semantics and detailed rationale for those semantics.&#xA;&#xA;&#xA; case OP_NOP4:&#xA; {&#xA;    //format: block_hash sidechain_id OP_BRIBEVERIFY&#xA;    if (!(flags &amp; SCRIPT_VERIFY_BRIBEVERIFY)) {&#xA;        // not enabled; treat as a NOP4&#xA;        if (flags &amp; SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS) {&#xA;            return set_error(serror, SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS);&#xA;        }&#xA;        break;&#xA;    }&#xA;&#xA;    if (stack.size() &lt; 2)&#xA;        return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);&#xA;&#xA;    const CScriptNum scriptNumSidechainId(stacktop(-1),fRequireMinimal);&#xA;    uint8_t nSidechainId;&#xA;    if (!checker.CheckSidechainId(scriptNumSidechainId,nSidechainId)) {&#xA;        return set_error(serror, SCRIPT_ERR_UNKNOWN_SIDECHAIN);&#xA;    }&#xA;&#xA;    // Check block hash&#xA;    bool fHashCritical =&#xA;checker.CheckCriticalHash(stacktop(-2),nSidechainId);&#xA;    if (!fHashCritical) {&#xA;        return set_error(serror, SCRIPT_ERR_UNSATISFIED_BRIBE);&#xA;    }&#xA;    break;&#xA; }&#xA;&#xA;&#xA;&#xA;https://github.com/Christewart/bitcoin/blob/94b6f33f2278c42d4d8758a3c8ffe2078e4ec933/src/script/interpreter.cpp#L427&#xA;&#xA;https://github.com/drivechain-project/bitcoin/pull/13&#xA;&#xA;==Deployment==&#xA;&#xA;TODO&#xA;&#xA;==Credits==&#xA;&#xA;Credit to Paul Sztorc for the original idea of Blind Merge Mined sidechains.&#xA;&#xA;Credit to CryptAxe for writing the foundational layer of software for&#xA;drivechains so I could implement OP_BRIBEVERIFY.&#xA;&#xA;&#xA;==References==&#xA;&#xA;Blind Merge Mined Sidechains -&#xA;http://www.truthcoin.info/blog/blind-merged-mining/&#xA;&#xA;Mailing list discussion -&#xA;https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-May/014408.html&#xA;&#xA;==Copyright==&#xA;&#xA;This document is placed in the public domain.&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20170627/bd5730bf/attachment.html&gt;</html></oembed>