1.
When machines take decisions on their own:
Introduction to
Smart Contracts
philippe.camacho@dreamlab.net
Dreamlab
28 of August 2015
Bern, Switzerland
2.
2
“As another example, consider a hypothetical
digital security system for automobiles. The smart
contract design strategy suggests that we
successively refine security protocols to more fully
embed in a property the contractual terms which
deal with it. These protocols would give control of
the cryptographic keys for operating the
property to the person who rightfully owns that
property, based on the terms of the contract. In
the most straightforward implementation, the car
can be rendered inoperable unless the proper
challenge-response protocol is completed with
its rightful owner, preventing theft.”
Nick Szabo
3.
3
A smart contract is a program which execution is autonomous and
totally transparent.
In particular this execution cannot be reverted and its trace is public
and immutable.
A smart contract can send, receive and store money. It can also
interact with other smart contracts or any computational systems
connected to the internet.
4.
4
«Traditional» contract
Contract
Execution
Audit
(Control)
Definition
Interaction between human and objects.
Possible application of punishments
Definitions can be interpreted (trial)
Paper
(semi-) manual
data recollection
5.
5
Smart contract
Contract
Execution
Audit
(Control)
Definition
Program execution
(Only one interpretation)
Not reversible, autonomous
Software
program
Real time
Immutable
6.
6
Agenda
• Bitcoin
• Change of paradigm
• Bitcoin is more than money
• Smart contracts
• Examples
• Ethereum
Objective:
understading the
principles behind this
technology
Objective:
Have a feeling of the
impact and challenges
related to this
technology
15.
15
¿But who did invent Bitcoin?
No one knows...
Anyways trust should
not depend on this.
http://www.newsweek.com/2014/03/14/face-behind-bitcoin-247957.html
19.
19
Fix #2
The Bitcoin network shares a database
of all the transactions
20.
20
Audit
Not only the banking industry is
going to be impacted by Bitcoin,
but also the audit industry
21.
21
Solution #2
Origin Destination Amount
Homer Lisa 1 BTC
Homer Bart 2 BTC
Lisa Bart 1 BTC
… … …
The Bitcoin network
checks that an
account has enough
funds before
accepting a
transaction.
22.
22
Every transaction needs to be public.
Nobody will want to use such a system that
reveals all this information!
26.
26
Bitcoin y Anonymity
• Bitcoin is not totally
anonymous by default
• Some attempts to improve anonymity
zerocash-project.orgBlockchain.info
Dilemma: privacy
v/s crime
27.
27
Every account is public so I can spend
money from any of them
(I can spend other people’s
bitcoins).
30.
32
Solution #4
Origin Destination Amount Signature
HhY67j81 Jh89HF8m 1 BTC Djsh767
HhY67J81 LaU4V6uU 2 BTC 8988dd
Jh89HF8m LaU4V6uU 1 BTC djDhd7n
… … …
Bitcoin addresses are
computed from the public
key
Message
31.
33
What does it mean when I say
“I own 30 BTC”?
You know the private key related to a
public key (≈bitcoin address)
and its balance is 30 BTC.
You are the only person to know this
private key.
1
2
Implicit contract
You know the key => you are the owner
(Being owner = having the hability to
transfer)
32.
34
¿Future of banking?
YCombinator
70+ millionsde USD
39 000 businesses
served
40 millions USD
Wences Casares
Debit card that can be
paid in BTC
33.
35
Pagar con bitcoin
Paying with bitcoin is very easy
but cannot be reverted
My bitcoin address:
1Ask9dvcJHEyjiVm5L9vjxYTU3i8Q1Q1zV
34.
36
I still can do evil things....
What about publishing a
fake history of transactions?
39.
41
Proof of Work
00000
00001
00010
00011
00100
00101
00110
00111
01000
01001
01010
01011
01100
01101
01110
01111
10000
10001
10010
10011
10100
10101
10110
10111
11000
11001
11010
11011
11100
11101
11110
11111
H1001101|| x 000||10
Find value x so
that the output
begins with 3 zeros.
The only way (*) to compute
this value so that the output
starts with 𝒏 zeros is to try at
random around de 𝟐 𝒏 times.
(*) If you find another way you can
(1) become rich, (2) famous (Turing Award), or (3) both (start with (1) then (2)...
40.
42
Solution #5
• The first node that manages to
solve this puzzle/equation wins
the block
• The bitcoin network extends this
chain with the new block
• The network always chooses to
extend the largest chain
Grrr!
I need to control
51% of the computational
power of the network (*)
(*) It is not that simple… => Majority is not Enough: Bitcoin Mining is Vulnerable
http://arxiv.org/abs/1311.0243
42.
44
Sounds good… but why would
people waste their CPU cycle?
43.
45
Mining
• The winnner of a block receives a
reward of 25 BTC
Indeed this is how the bitcoins are
«created»
• This process is called mining
44.
46
Solution to the
consensus
problem
(Proof of work)
Simple tools
(Hash
functions +
digital
signature)
Economic
incentive
Why is Bitcoin’s design so brilliant?
47.
49
Bitcoin is a smart contract
• It is a program
• Its execution is autonomous
• because of the decentralized network
• Every transactions are public
• It is not possible to modify the history of transactions
• The execution cannot be reverted
• A few clauses/statements of this contract
• No more than 21.000.000 de bitcoins
• A new block every 10 minutes
• Mining difficulty is ajusted to the power of the network
• Only a subset of possible transactions are allowed
• …
48.
50
Bitcoin transaction
https://bitcoin.org/en/developer-guide#signature-hash-types
Much more complex
than a simple signed
message…
It is a smart
contract!
49.
51
Sure, a smart contrat that
executes another smart
contract….
51.
53
Ethereum
• Platform similar to Bitcoin but:
• The language for writing smart
contracts is more expressive
(Turing-Complete)
• Avoids to reinvent the wheel by
forking an existing
cryptocurrency
• All the smart contracts use the
same blockchain
• Crowdfunding (sept. 2014)
• 31531 BTC = US$18,439,086
• Launching:
• it’s live since July 30th 2015!
Vitalik Buterin
Ethereum founder
52.
54
Sales contract
http://etherscripter.com/0-5-1/
Hard problem
solved: who
pays/sends the
product first?
53.
55
More examples of smart contracts
• Decentralized DNS
• Autonomous companies
• Define the shares at the beginning
• Dividends can be distributed automatically
• One could buy and sell stock instantly
• Insurance
• Heritance
• Direct democracy
• IOT (IBM+ Samsung using Ethereum =>
https://www.youtube.com/watch?v=U1XOPIqyP7A)
Great video, only 8
minutes
54.
56
Challenges
• Scalability (current problem with Bitcoin)
• Privacy v/s Criminality
• A bug can be very expensive
• A breach can lead to a loss of all funds of the contract
(which could be a whole company!)
• Generalized bug
• Fork Bitcoin in 2013
• Security?
Still relying on the
break-and-fix cycle
55.
57
Using smart contracts for crime
• Enable to do business without relying on trust
• => perfect for cybercrime
• Example of evil businesses
• Selling secrets
• DoS
• Assassination
• Defacement
• Relies on very sophisticated cryptography on top of
smart contracts
http://www.arijuels.com/wp-content/uploads/2013/09/public_gyges.pdf