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.

y all miners (so they can check that the contract was executed correctly) but shouldn’t be<br />

predictable to either player (or else they might refuse to join if they know they will have to play<br />

second).<br />

This is the problem of r<strong>and</strong>omness beacons. As we discussed in Section 9.4, the contract might hash<br />

the value of the next block in the blockchain after both players have joined. For our specific<br />

application, the problem is a bit easier, since only Alice <strong>and</strong> Bob need to be convinced that the coin<br />

flip is r<strong>and</strong>om, not the whole world. So they might use the approach from Section 9.3: they both<br />

submit the hash of a r<strong>and</strong>om value, then both reveal the inputs, <strong>and</strong> derive the r<strong>and</strong>om bit from the<br />

inputs. Both approaches have been seen in practice.<br />

Other applications.​Playing chess might be fun, but the real excitement for Ethereum is about<br />

financial applications. Many of the applications we’ve discussed in the text so far, including prediction<br />

markets, smart property, escrowed payments, micropayment channels, <strong>and</strong> mixing services, can all be<br />

implemented in Ethereum. There are subtleties to all of these applications, but they are all possible<br />

<strong>and</strong> in most cases are much simpler to implement than the types of bolt‐on protocols we’ve seen with<br />

<strong>Bitcoin</strong>. There are also a host of other applications, like auctions <strong>and</strong> order books, that we haven’t<br />

talked about but which people are enthusiastic about using Ethereum to implement.<br />

State <strong>and</strong> account balances in Ethereum. ​In Chapter 3, we discussed two ways to design a ledger:<br />

account‐based <strong>and</strong> transaction‐based. In a transaction‐based ledger like <strong>Bitcoin</strong>, the blockchain stores<br />

only transactions (plus a small amount of metadata in the block headers). To make it easier to validate<br />

transactions, <strong>Bitcoin</strong> treats coins as immutable, <strong>and</strong> transaction outputs must be spent in their<br />

entirety, with change addresses used if necessary. Effectively, transactions operate on a global state<br />

which is a list of UTXOs, but this state is never made explicit in the <strong>Bitcoin</strong> protocol <strong>and</strong> is simply<br />

something miners create on their own to speed up verification.<br />

Ethereum, on the other h<strong>and</strong>, uses an account‐based model. Since Ethereum already stores a data<br />

structure mapping contract addresses to state, it is natural to also store the account balance of every<br />

regular address (also called an owned address) in the system. This means that instead of representing<br />

payments using an acyclic transaction graph where each transaction spends some inputs <strong>and</strong> creates<br />

some outputs, Ethereum just stores a balance for each address like a traditional bank might store the<br />

balance of each account number.<br />

Data structures in Ethereum. ​In Chapter 3, we said that an account‐based ledger would necessitate<br />

fancy data structures for record‐keeping. Ethereum has just such data structures. Specifically, every<br />

block contains a digest of the current state (balance <strong>and</strong> transaction count) of every address as well as<br />

the state (balance <strong>and</strong> storage) of every contract. Each contract’s storage tree maps arbitrary 256‐bit<br />

addresses to 256‐bit words, making for a whopping 2​ 256 ​ ⨉ 256 = 2​ 264​ bytes of storage! Of course, you<br />

could never fill up all of this storage, but that’s the theoretical space. The digest makes it easy to<br />

prove that a given address has a given balance or storage state. For example, Alice can prove to Bob<br />

what her balance is without Bob having to scan the entire block chain to verify the proof.<br />

290

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

Saved successfully!

Ooh no, something went wrong!