1 of 41

Securing Blockchains

Andrew Miller

IC3 Retreat

May 17, 2016

2 of 41

Blockchain is

an opportunity to build

resilient by design

infrastructure

3 of 41

A blockchain is a Virtual Trusted Computer

Consistency - Every server gives the same result

Availability - New transactions are processed (quickly)

4 of 41

5 of 41

Withdraw $500

Does Alice’s account have $500?

OK, subtract $500 and dispense cash

Alice

Alice: $800

Alice: $300

6 of 41

Withdraw $500

“Alice”

Does Alice’s account have $500?

OK, subtract $500 and dispense cash

Withdraw $500

“Alice”

Does Alice’s account have $500?

OK, subtract $500 and dispense cash

Alice: $800

Alice: $-200!!!

7 of 41

Distributed systems are notoriously difficult

“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, 1987

8 of 41

The good news - 30 years of science to draw upon

9 of 41

Lessons from 30 years are not always applied

10 of 41

Stellar

Fork predicted months in advance, based on flaws discovered during peer-review

11 of 41

What goes wrong? (and how IC3 can help)

- “Don’t roll your own crypto” build from existing reliable components

- Implementation errors program analysis, secure language design

- Defective protocols we prove that protocols are secure

- Mismatched interfaces between systems

we build generic abstractions that can be put together safely

12 of 41

The traditional distributed systems setting

“Consortium blockchain”

Nodes are run by well-known, trusted entities

13 of 41

The “permissionless blockchain” setting is new

13

Sybil attack

14 of 41

- Miners are neither employees nor contractors

- Spending on “defense” is % of market cap

…. yet they are the ones doing the work

$1M spent per day on Bitcoin mining

Market cap: $6B

Mining is 98% of the Bitcoin’s operational cost

The cost to attack the network with hashpower: ~ $1M/day

15 of 41

Permissioned vs Permissionless Blockchains

We don’t know (yet) how to replicate Bitcoin’s success

We know how to build secure and scalable permissioned blockchains

16 of 41

The 5 layers of blockchain architecture

Network: broadcasting transactions and blocks

Consensus: the agreement-reaching engine

Storage: bootstrapping new nodes, storing archival data

Application: transactions, smart contract language

View: cached summary of the transaction log

17 of 41

The 5 layers of blockchain architecture

Network: broadcasting transactions and blocks

Consensus: the agreement-reaching engine

Storage: bootstrapping new nodes, storing archival data

Application: transactions, smart contract language

View: cached summary of the transaction log

18 of 41

The 5 layers of blockchain architecture

Network: broadcasting transactions and blocks

Consensus: the agreement-reaching engine

Storage: bootstrapping new nodes, storing archival data

Application: transactions, smart contract language

View: cached summary of the transaction log

19 of 41

What we want: a Virtual Trusted Computer

What programs run on the trusted computer?

20 of 41

Smart Contracts: programs for the Trusted Computer

  • Executable programs running on a blockchain
  • Interact with assets and data
  • May serve as a replacement for legal contracts

Example:

if GOOGL is trading at more than

$800 per share on May 20, 2016

then transfer 5 shares of GOOGL from Alice to Bob,

and have Bob pay Carol $15,000

Contract

21 of 41

The Story

Smart Contract programming is error-prone

22 of 41

Fall 2014: Smart contracts in UMD security class

Mistakes exhibited by students are also

found in today’s Ethereum smart contracts

What happens when a third player tries to join the contract?

Avoidable mistakes!

23 of 41

We have the tools to correctly engineer consensus protocols and secure blockchains.

Security hazards abound.

Avoid repeating past mistakes!

24 of 41

25 of 41

26 of 41

Backup slides

27 of 41

Reality: Computers and network links sometimes fail

28 of 41

Open research questions

How can we use existing “authorities” as oracles?

See demo: TownCrier

How can we provide privacy at the same time as auditability?

See talks: Hawk, and Solidus

How can we make blockchains scalable and efficient?

See talks: BitcoinNG, Federated Consensus, HoneyBadgerBFT

Can we integrate blockchains within existing law / institutions?

29 of 41

“Blockchain technology”

a toolbox of applied cryptography and distributed computing techniques, for building trustworthy shared databases

- hashes and authenticated data structures

(e.g. a literal “blockchain”)

- digital signatures

- consensus protocols

- zero-knowledge proofs, homomorphic encryption

- computer languages for business+security policies

(e.g. “smart contracts”)

30 of 41

DuckCoin - threshold signature

OK

OK

OK

NO

What’s my account balance?

31 of 41

Smart contracts - computer programs that

enforce business and security policies

Example: a jointly-owned fund with three principals

Each principal may authorize transfers of up to $1000 per day

Authorization from any majority (2 of 3) can transfer any amount

32 of 41

Smart contracts - computer programs that

enforce business and security policies

data: principals = [p1,p2,p3]

on request(transfer $X to #Recipient):

if (this request is signed by 2/3 principals) then approve

if (this request is signed by 1/3 principals and

this principal has spent < $limitPerDay - $X) then approve

otherwise deny

33 of 41

Example: a jointly-owned fund with three principals

Smart contracts - computer programs that

enforce business and security policies

Each principal may authorize transfers of up to $1000 per day

Authorization from any majority (2 of 3) can transfer any amount

Properties - robust with regard to loss/theft of any 1 principal’s key

How would you implement this in a business contract?

Who has “custody” of these funds?

34 of 41

DuckCoin - a pedagogical blockchain design

35 of 41

DuckCoin - a pedagogical blockchain design

Three “nodes” - Huey, Dewey, and Louie run a consortium blockchain

Step I. run a consensus algorithm to put transactions in order

Step II. sign and publish each transaction and updated balances

Step III. store balances in an authenticated data structure

The system is designed to withstand 1 node failure

and graceful degradation (other failures are detected)

36 of 41

DuckCoin - consensus protocol

X

Transfer $5,000 to Bob

- Jointly process user requests

- Withstand 1 node crashing

- Prevent “double spends”

Transfer $5,000 to Carol

37 of 41

DuckCoin - authenticated data structure

Block

Block

Block

Transaction

Transaction

Transaction

Transaction

Transaction

Transaction

Transaction

Transaction

Transaction

Balance

Balance

Balance

Balance

Balance

Balance

Balance

Balance

Balance

38 of 41

Security Analysis ← This part is important!!!!

Assumptions:

How many nodes can fail, how reliable are communications?

Examples:

What happens if 2 nodes crash? If 1 node is commandeered?

What happens if the network intermittently disrupted?

Guarantees:

Safety/consistency Liveness/availability

Auditability Privacy

39 of 41

Bitcoin Mining: a

force field for open blockchains

40 of 41

The good news - 30 years of science to draw upon

Large toolbox of provably-secure protocols

- PBFT

- Paxos

- Raft (just to name a few)

Scientific methods for rigorously evaluating new protocols

What properties do they guarantee?

What assumptions do they rely on?

41 of 41

Bitcoin Mining is a surprising new solution for the “open blockchain” setting