Bitcoin Cash Innovation Continues with the First On-Chain Atomic Bet
A trustless betting protocol designed by Jonald Fyookball called Chainbet, a protocol that enables simple coin flip wagers using the Bitcoin Cash (BCH) blockchain. Since then the Openbazaar developer Chris Pacia performed the first atomic bet utilizing the BCH network’s re-enabled OP_Codes and Fyookball’s Chainbet concept.
The First Trustless Atomic Wager Utilizes Bitcoin Cash OP_Codes
This weekend the Openbazaar developer Chris Pacia has performed the first atomic bet using the BCH network’s OP_Codes in order to demonstrate a trustless wager. Pacia said he tried the idea using bitcoin cash after seeing Fyookball’s new protocol concept, and notes that this method of trustless betting is not possible using the Bitcoin Core (BTC) network. The reason for this is due to the re-enabled OP_Codes added to the BCH protocol this past May.
“The way the scheme works from a high level is that Alice and Bob are going to generate secret random numbers and commit the hashes of those numbers to the bet’s output script,” explain’s Pacia’s demonstration post. “To determine the winner they will both reveal their random numbers and the script will add them together. If the sum is even, Alice wins — Otherwise, Bob wins.”
256-bit Random Numbers Converted to 32-bit Integers Using the New OP_SPLIT and OP_BIN2NUM Codes.
Pacia details the challenge of this operation is doing it securely, and adds that Bitcoin arithmetic operations only accept signed 32-bit integers. This means that the process wouldn’t work if Alice and Bob commit to 32-bit random numbers. Pacia’s demo commits to the hash of 256-bit random numbers and then converted into signed 32-bit integers using the new OP_SPLIT and OP_BIN2NUM codes. The Openbazaar developer notes that the OP_MOD directive is used to determine odd and even.
“To make the scheme atomic, Alice first funds a special output with a redeem script of: OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG,” Pacia explains. “Alice and Bob then jointly build a transaction with two inputs ― Alice’s special output and a normal output from Bob’s wallet [edit: this will need to be a 2-of-2 to prevent bob from double spending].”
Bob signs the transaction first and sends his signature to Alice. Alice then signs her input and broadcasts the transaction to the blockchain. By signing the transaction Alice is revealing her secret number to Bob who can then use that number to determine if he won or lost the bet. If he won, Bob can immediately claim his winnings. If Alice won, Bob cannot do anything but Alice can claim the funds after a timelock (6 blocks) expires.
BCH Supporters Thrilled to See the Trustless Scheme in Action, and Some Are Quite Amused the Procedure Can’t be Done Using BTC
Many bitcoin cash supporters were thrilled to see that Pacia accomplished this procedure and shared his demonstration. BCH supporters believe this method of trustless wagers could further advance betting sites like Satoshi Dice. The creator of Chainbet, Jonald Fyookball, thanked Pacia for bringing his skills and adding life to his concept.
“Looking forward to working with you and others to create a usable implementation soon,” Fyookball notes. “That’s pretty amusing that this scheme can’t be done on BTC.”