What I Learned in Berkeley’s Blockchain Class (Part 2)

Josh Ephraim
Berkeley Blockchain
8 min readJan 31, 2018

--

This is part two of a series on UC Berkeley’s CS 294–144: Blockchain, Cryptoeconomics, and the Future of Technology, Business and Law.

You can read part one here

Class two was a technical primer on Bitcoin. The assignment was to read the Bitcoin and Ethereum White Papers.

Bitcoin: A Peer-to-Peer Electronic Cash System

Ethereum: A Next-Generation Smart Contract and Decentralized Application Platform

Bitcoin is the first example of blockchain technology. It was defined in the Bitcoin source code. So to understand blockchain technology we need to understand how Bitcoin works.

Hopefully this helps a little…

There’s a lot of debate today about what Bitcoin should be. Is it digital gold (store of value) or a new payment method (medium of exchange)? Let’s look at the actual text.

“A purely peer-to-peer version of electronic cash would allow online payments to be sent directly from one party to another without going through a financial institution” — Bitcoin: A Peer-to-Peer Electronic Cash System by Satoshi Nakamoto

Professor Dawn Song walked us through the components needed to make this work.

Warning, this gets pretty technical (for me)!

Version Zero: a world of perfect trust, where you could send digital cash directly to someone else as payment. This would be simple, accessible, and fast because there would be no middle-men and no verification process. The problem here is that there would also be no privacy and no security. It would be impossible to prevent fraud.

In the real world, if someone gives you a dollar bill, you can see that you hold the dollar and they don’t. But online there is something known as the Double-Spending Problem. Because it is easy to copy or reproduce a file, if I give you a digital dollar directly, there’s no way for you to know if I am giving you the original dollar, or if it’s just a copy.

If we lived in a world with perfect trust, we wouldn’t have to worry about the double-spending problem. But because there is always a risk of fraud, we’ve found another way to make payments online.

Version One: Most people conduct commerce online by using a trusted third party to keep track of whose dollars are whose. Users identify themselves by logging into a central website with password-based authentication, and the central website can check every transaction to make sure that each buyer spent money they actually had, and each seller receives that money. This is done using a central ledger.

With this system you get simplicity, accessibility, speed of transactions, and the ability for the trusted entity to fix errors and reverse transactions. However, it also comes with weak security (passwords can be stolen), the risk of unfairness from the central entity (the entity can cheat or adjudicate disagreements unfairly), and a lack of privacy (nothing is completely anonymous).

A good example of this type of system is Venmo. Venmo keeps track of all payments sent and received through their central ledger. For each payment they will subtract money from the payer and add money to the payee. If you’re a Venmo user, you are putting your trust in Venmo to do this fairly and accurately.

Digital Signatures: An Alternative to Passwords

Version Two: Instead of using usernames and passwords, you can use digital signatures.

Passwords are really convenient, but they are vulnerable. A central entity needs to manage them, and they can be vulnerable to attack. Many companies have been victims of hacks in the past several years.

An alternative to usernames and passwords is to use digital signatures.

With a physical signature, we assume you are the only one that can make your signature, but that anyone who sees it knows it’s yours. We also assume that your signature is tied to a particular document so that signature can’t be used to indicate your agreement to another document.

The pope still signs documents using a signet ring like the one below (more common in previous centuries). By impressing the ring in wax, an image is created. This image, in theory, is known to the public as only the pope’s (because no one else has the ring).

An example of a Signet Ring. This one is the Royal Signet Ring from the country of Georgia

If someone wants to create a digital signature, let’s call her Emily, she will generate a public key (PK) and a secret or private key (SK). The public key is analogous to the imprint of the pope’s signet ring, while the secret key is known only to Emily. The secret key is analogous to the ring itself, which only the pope controls and never shares.

If Emily wants to send a message, she will input her secret key and the message, and apply a mathematical transformation that results in the signature on the message. Then, if you take the message, the signature on the message, as well as the public key, you can test whether the original message was indeed signed by Emily with her secret key.

Why do we want these digital signatures? It’s more secure. If you use a secret key, a central entity or a hacker cannot falsify transactions on your behalf (that is, unless they somehow get your secret key). Since the secret key is not on the central entity’s servers, hackers can’t steal your information by hacking those servers. There is also added privacy. Instead of providing the central entity with personal information, users can be identified using public keys functioning as pseudonyms.

However, you can’t store your secret keys in your head like you can for a simple username and password. With secret keys, you need to manage them yourself.

A Bloomberg anchor shared his public & secret keys on TV, only to have it promptly stolen (Credit: The Verge)

The central entity also needs to manage the public keys on their servers. Privacy is at risk, because if your public key is somehow matched with your personal identity, it is no longer private. And lastly, the central entity can still cheat because they are still managing the ledger. They can refuse or fail to process your transaction. They can also go back and erase transactions.

Version Three: In this version, you can still sign transactions with digital signatures. You still manage your secret key and the central entity manages the public keys. The central entity also still manages the ledger.

But now, the central entity applies their own digital signature to batches of transactions (plus all old batches) every 10 minutes. These are called blocks.

A block is a batch of transactions plus a digital signature. The whole chain contains all transactions over time. This is why it is called a blockchain.

This is an improvement over Version 2 because the central entity can’t present different batches to different users or delete transactions after the fact without being caught. Because the ledger is still centralized, the central entity can still refuse to process or post transactions.

In class we discussed the issues with trusting a central authority. Banks can go bust, and governments can limit trade, freeze assets, or cause hyperinflation. So if you can build something without the need to trust a central entity, that would be a good thing.

Version Four: Bitcoin

Just like the previous version, it is private (pseudonymous — users’ identities correspond to their keys), and transactions are conducted through digital signatures on a blockchain. What’s different here is that the ledger is fully decentralized.

Full decentralization means that the community maintains the fully public ledger so that no single entity can suppress transactions. The way to maintain and continue to verify the ledger is through mining. The network designates one player to sequence a transaction authoritatively in a block. All of the miners race to be the one to sequence transactions in the block because the lucky winner who creates the next block is compensated with new bitcoin created by the system (currently miners are rewarded with 12.5 BTC).

How Does Mining Work

Professor Song described mining as “the hashing slot machine.” A hash function takes a particular input and applies a transformation (a function) to produce a single random-looking output. Whoever finds the correct output gets the right to create the next block and is therefore compensated with new bitcoin. This is the lottery aspect.

Another messy diagram I drew

Hash functions have a few important properties:

  • Pre-image resistance: given an input, it is computationally difficult to determine the output
  • Collision resistance: it’s difficult to find two inputs with the same output
  • Deterministic: the output will always be the same for a given input
  • Should look random
  • Hides information about the input

The faster your machine is at these hash functions, the higher the probability is that you are the first to mine a block. This is the proof of work system. Whoever uses the most computational power is rewarded with the right to mine the next block and receive the new bitcoin created by the system. The new block contains the previous block’s hash, the transactions included in the new block, as well as the nonce (the winning lottery ticket- a number that delivers a desirable hash, therefore awarding the miner the right to create the next block).

This is what a block looks like

What Happens When Miners Find a Block at the Same Time?

When miners find a block at the same time, what happens is called a fork. This happens fairly often, and the chain that wins is the one that is longer. This is also the chain with the most amount of work. Subsequent blocks get added to one chain, and the other gets abandoned. The transactions that would have been in the abandoned block are then put in later blocks in the network.

The green block is the “genesis” block. The black chain is the accepted chain, and the purple blocks have been abandoned

What We Can Learn About Blockchain Technology from Bitcoin

  1. Blockchains are a strict ordering of messages.
  2. The permission to write is rule based, and the permission to read is global.
  3. No message modification (immutable).
  4. No middlemen
  5. More transparent
  6. Can theoretically be faster because there’s no execution, clearing and settlement like normal financial instruments.

Professor Song described a blockchain as a distributed bulletin board with consistency (every server gets the same result), and availability (new transactions are processed quickly). But many of the potential benefits of blockchains have not yet been realized. Distributed systems are notoriously difficult. Bitcoin certainly hasn’t solved yet for low transaction fees, fast transactions, or as a real store of value, medium of exchange, or unit of account.

Professor Song ended with a quote:

A distributed system is one in which the failure of a computer you didn’t even know existed can render your own computer unusable — Leslie Lamport (Turing Award Winning Computer Scientist), 1987

There’s a lot more room for innovation in this space!

Have a question or comment? Let me know on twitter!

--

--

Josh Ephraim
Berkeley Blockchain

legal counsel to startups and VCs, jd-mba, former investor at Dorm Room Fund