10.02.2016 Views

Bitcoin and Cryptocurrency Technologies

1Qqc4BN

1Qqc4BN

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

DepositA [Altcoin block chain]<br />

RefundA [Altcoin block chain]<br />

Input:<br />

ScriptPubkey:<br />

Alice’s coins of value ​a<br />

Redeemable by providing<br />

either (​sigA ​<strong>and</strong> ​sigB​)<br />

or ​sigB ​<strong>and</strong> ​x​s.t. ​H(x) = <br />

→<br />

Input: DepositA<br />

Output: AddrA<br />

Timelock: T​ 2<br />

ScriptSig: sigA, sigB<br />

DepositB [<strong>Bitcoin</strong> block chain]<br />

RefundB [<strong>Bitcoin</strong> block chain]<br />

Input:<br />

ScriptPubkey:<br />

Bob’s coins of value ​b<br />

Redeemable by providing<br />

either (​sigA ​<strong>and</strong> ​sigB​)<br />

or ​sigA ​<strong>and</strong> ​x​s.t. ​H(x) = <br />

→<br />

Input: DepositB<br />

Output: AddrB<br />

Timelock: T​ 1<br />

ScriptSig: sigA, sigB<br />

Figure 10.6: Atomic cross‐chain swap protocol<br />

In step 1, Alice deposits altcoins of value ​a​so that can be redeemed in one of two ways (a “deposit”<br />

simply means sending those coins to a ScriptPubkey that specifies two possible conditions for<br />

spending it). First, if Alice <strong>and</strong> Bob mutually agree, they can redeem it. Indeed, Alice publishes the<br />

deposit only after making sure to get a refund transaction signed by Bob — this allows her to redeem<br />

her deposit if 2 time units elapse <strong>and</strong> it hasn’t already been claimed.<br />

The other way to claim Alice’s deposit, at any time, is by providing Bob’s signature as well as the value<br />

x ​which opens the hash commitment ​h.​Note that we write ​ ​in ​DepositA​to indicate that Alice<br />

literally writes the value of ​h​into the ScriptPubkey. Since ​x​is known only to Alice, at the end of stage<br />

1 neither party is able to claim the deposit this way. The idea is that Bob will learn the value ​x​,<br />

enabling him to claim the altcoins, if <strong>and</strong> only if Alice claims his bitcoins, as we’ll see.<br />

Step 2 is roughly the reverse of step 1: Bob deposits bitcoins of value ​b​so that it can be redeemed in<br />

one of two ways. The key difference is that he doesn’t pick a new secret; instead, he uses the same<br />

hash value ​h​(he would just copy the value from the ​DepositA​transaction to the ​DepositB<br />

transaction). This is the key to tying together transactions on the two block chains.<br />

At this point the ball is in Alice’s court. She could change her mind about the swap — if at time ​T​ 1​<br />

Alice<br />

hasn’t done anything to reveal ​x​to Bob, he will simply claim his deposit <strong>and</strong> quit the protocol. Alice’s<br />

other option is to claim Bob’s bitcoins before time ​T​ 1​<br />

. But she can only do this by creating <strong>and</strong><br />

broadcasting a ScriptSig which contains the value ​x​; Bob can listen to this broadcast <strong>and</strong> use the value<br />

same ​x ​to claim Alice’s altcoins, completing the swap.<br />

Note that if Alice tries to claim Bob’s bitcoins a tad too late (after time ​T​ 1​<br />

but before time ​T​ 2​<br />

), Bob<br />

might be able to claim ​both​deposits. Similarly if Alice claims Bob’s bitcoins on time but Bob waits too<br />

281

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!