This document provides an overview of blockchains and bitcoin. It first explains basic cryptography concepts like symmetric encryption, public key cryptography, and hash functions. It then discusses how blockchains work by linking blocks together through hashes. Blockchains provide security by making alterations to past blocks difficult. Bitcoin uses public key cryptography and blockchains to allow digital value transfers without a central authority. Transactions are ordered through a mining process where miners compete to validate blocks and earn rewards.
4. Symmetric cryptography
Symmetric cryptography encrypts and decrypts data using the same key
● The key must be shared before any message is transmitted
○ Sharing the key through the network would render the key useless
● Extremely fast compared to public-key encryption (~1000x)
● Less secure due to speed and usually smaller keys
● Up to the 1970’s this was the only available form of encryption
● DES, 3DES, Blowfish, AES, ...
5. Public-key cryptography
Public-key or Asymmetric cryptography encrypts using one key and decrypts data
using a different but related key
● Both private and public keys are generated at the same time
○ One key is the inverse of the other
○ The public key can be available to the entire world
○ The strength of the algorithm relies on the fact that by knowing the public key it is extremely
hard to guess the private key
● Extremely slow compared to symmetric encryption (~1000x)
● More secure due to lack of speed and usually much bigger keys
● First algorithms were discovered in the 1970’s
● RSA is by far the most used algorithm
6. Public-key cryptography
● Confidentiality
○ Data is encrypted with the public key and consequently, can only be decrypted with the private
key
■ Only the holder of the private key will be able to decrypt the original message
○ Integrity is guaranteed because the smallest change in the encrypted data will fail to decrypt to
something meaningful
● Authentication
○ Data is encrypted with the private key and consequently, can only be decrypted with the public
key
■ Anyone can decrypt the data but only the holder of the private key could have encrypted
the data originally
● This means that the original payload was signed by the holder of the private key
○ Integrity is guaranteed because the smallest change in the encrypted data will fail to decrypt to
something meaningful
7. Public-key cryptography
● Communication
○ Because public-key algorithms are orders of magnitude slower than symmetric algorithms,
hybrid protocols are used in communications
i. A secret key is generated and shared using public-key algorithms
ii. Data is transmitted encrypted by a symmetric algorithm using the previously shared secret
key
iii. Cyclically, after a certain period of time, new secret keys are generated and shared
● This means that to get access to all the data the attacker would need to compromise
all the shared keys (or the private key)
8. Hash Functions
● Produce a message digest (or summary) of the payload
○ The digest always has the same length regardless of the original payload size
○ The same input always produces the same digest
● The smallest change in the payload produces a completely different result
(digest)
○ It is extremely difficult to produce a payload that produces the same result as another payload
i. Instead of using a public-key algorithm for signing an entire document, a message digest of
the document can be produced and only the digest needs to be signed using the public-key
algorithm
ii. SHA256 “Hello World”:
a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e
iii. SHA256 “Hello World ”:
a2f63ad70f3e5c61e5eafa164e95cbe40c9689c304ddd9b74fddf4169e3e838b
● Extremely fast
● MDx (e.g. MD5), SHAn (e.g SHA256)
10. What are Blocks
Block Id <necessary for chains>
Data <the content of the Block>
Prev <previous block hash; necessary for chains>
Nonce <value to be mined in order for the Hash to follow a specific rule>
Hash <Block digest (Block Id + Data + Prev + Nonce)>
11. What are Blockchains
● The Previous field contains the hash of the previous Block
○ This implies a chain from the last Block up to the first Block
● The Nonce makes the Block calculation to take some time
○ If the Hash needs to follow a specific rule (like a pattern) then multiple calculations with different
Nonces must be executed until the rule is followed
○ This is Mining
Block Id 1
Data <d1>
Prev 0
Nonce <n1>
Hash <h1>
Block Id 2
Data <d2>
Prev <h1>
Nonce <n2>
Hash <h2>
Block Id 3
Data <d3>
Prev <h2>
Nonce <n3>
Hash <h3>
Block Id 4
Data <d4>
Prev <h3>
Nonce <n4>
Hash <h4>
12. What are Blockchains
● If someone changes the content of one Block
○ that Block’s Nonce becomes invalid and needs to be re-mined
○ that Block’s Hash will be different
○ the subsequent Blocks all become invalid and need to be re-mined as well
○ this makes Blockchains resistant to changes
Block Id 1
Data <d1>
Prev 0
Nonce <n1>
Hash <h1>
Block Id 2
Data <d2’>
Prev <h1>
Nonce <n2’>
Hash <h2’>
Block Id 3
Data <d3>
Prev <h2’>
Nonce <n3’>
Hash <h3’>
Block Id 4
Data <d4>
Prev <h3’>
Nonce <n4’>
Hash <h4’>
13. Distributed Blockchains
● All the nodes should have the exact same chain
○ it is only necessary to check the Id and the Hash of the last Block in all the nodes to be sure that
all contain the exact same chain
Block Id 1
Hash <h1>
Block Id 2
Hash <h2>
Block Id 3
Hash <h3>
Block Id 4
Hash <h4>
Node 1
Block Id 1
Hash <h1>
Block Id 2
Hash <h2>
Block Id 3
Hash <h3>
Block Id 4
Hash <h4>
Node 2
Block Id 1
Hash <h1>
Block Id 2
Hash <h2>
Block Id 3
Hash <h3>
Block Id 4
Hash <h4>
Node 3
14. Blockchain attacks
● If an attacker changes one Block in the chain
○ his chain will be different from that point until the end
○ because most of the nodes agree that <h4> is the hash of Block 4 and not <h4’>, the chain of
Node 2 is considered invalid
Block Id 1
Hash <h1>
Block Id 2
Hash <h2>
Block Id 3
Hash <h3>
Block Id 4
Hash <h4>
Node 1
Block Id 1
Hash <h1>
Block Id 2
Hash <h2’>
Block Id 3
Hash <h3’>
Block Id 4
Hash <h4’>
Node 2
Block Id 1
Hash <h1>
Block Id 2
Hash <h2>
Block Id 3
Hash <h3>
Block Id 4
Hash <h4>
Node 3
15. Bitcoin
Bitcoin is a Ledger
Public-key cryptography
Transactions
Lost Bitcoins
Anonymity
Transaction order challenges
Bitcoin Transaction order
Bitcoin double spend attack
Bitcoin generation
Bitcoin final considerations
16. Bitcoin is a Ledger
● Bitcoin is essentially a Ledger file
○ Each Block in the chain contains a list of transactions
○ Each computer in the Bitcoin network contains a copy of the chain since the first Block
○ Everyone knows about all transactions ever made
○ Designed so that no Trust is needed
○ Nodes receive transaction requests and forward that information to the other nodes
17. Public-key cryptography
● Relies on public-key cryptography
○ Public keys are the send-to (Outputs) addresses in transactions
■ When sending money, you send money to a public key
○ You prove you own money by signing (with your private key) an unspent transaction that was
sent to you.
■ With the signature, everyone can confirm that you allowed the transaction without
knowing your private key
■ Because the signature depends on the message, it will be different for every transaction
and cannot be reused
18. Transactions
● To make a transaction, the sender must reference unspent transactions that
belong to him and are marked as unspent
○ If the sum of the input transaction is greater than the value to be transferred, a second Output
must be added with the remainder with the sender as the destination
● This creates a chain of transactions up until the first Block
○ (this chain isn’t the Block chain)
Txn #20102
Inputs txn#11111
txn#12121
Outputs <Bob> 5.0
<Alice> 0.5
Txn #11111
Inputs txn#...
txn#...
Outputs Alice 3.0
Txn #12121
Inputs txn#...
txn#...
Outputs <Alice> 2.5
19. Transactions
● When Bitcoin wallet is installed it checks all the transactions since the first Block
○ This can take over 24 hours
○ Needs to be done only once
● Once a transaction is used it is marked as spent
○ preventing double spending
○ When checking a transaction, nodes check if it wasn’t already spent
○ There is an index of unspent transactions to speed this process
● To check your balance you need to go through every transaction ever made
20. Lost Bitcoins
● User mistakes can result in permanent loss of Bitcoins
○ If a user loses his private key, that money is lost permanently
○ There is no form of appeal
○ Those losses are from the global Bitcoin economy
● Over 2600 Bitcoins were lost once due to a malformed address
21. Anonymity
● If you access Bitcoin through an anonymizing network that hides your IP address
you will only reveal your public key
● You can generate a public key for every incoming transaction (receiving
addresses)
○ Different public keys can be associated together when they are used in the same transaction when
the sender proves that he owns the input transactions by signing them
● Public and Private key pair can be generated offline
○ Makes it really difficult to find who owns those public keys
22. Transaction order challenges
● Transactions are passed node by node
○ There is no guarantee that the order in which they are sent is the same in which they are received
○ Timestamps can easily be forged
○ Alice could create a transaction to Bob
■ Bob would ship the product
■ Alice would forge a transaction to herself with the same inputs as the transaction to Bob
■ If the last transaction is accepted, Bob will not receive the money and already has shipped
the product
23. Bitcoin Transaction order
● Transactions are placed in groups creating Blocks
○ Transactions in the same Block are considered to have happened at the same time
○ It is the Blockchain that orders transactions
○ Transactions not yet in a Block are called unconfirmed or unordered transactions
● Anyone can create a Block with a particular set of Transactions and propose it to
be the next Block in the chain
○ Because multiple people might have different proposals at the same time there should be an
agreement mechanism
24. Bitcoin Transaction order
● The solution is the Blockchain Nonce
○ On average the entire network will take 10 minutes to find the Nonce
■ A single computer would take years
○ The first person to mine a block will broadcast the block
■ His block is accepted as the next block in the chain
■ The probability of people finding the Nonce at the same time is very low
○ Why 10 minutes?
■ Shorter times lead to instability
■ Higher times delay confirmations
○ Every 2 weeks the Bitcoin software changes the rule for the Nonce so that it becomes harder to
solve to cope with computing power increase
25. Bitcoin Transaction order
● Occasionally there can be multiple options for the next Block
○ Having multiple blocks in different branches is even more unlikely
Node 1
Node 2
Node 3
26. Bitcoin Transaction order
● The tie is broken when someone computes the next Block for a branch
○ The longest branch always wins
Node 1
Node 2
Node 3
27. Bitcoin Transaction order
● Transactions in the dropped Blocks return to unconfirmed state and wait to
enter a next Block
○ The Blockchain quickly stabilizes
Node 1
Node 2
Node 3
28. Bitcoin double spend attack
● Alice sends money to Bob
○ Bob waits for the transaction to be confirmed
○ Bob sends the product to Alice
○ Alice creates a concurrent longer Branch and wins
■ Alice must win a race against the rest of the network to do this
○ Alice to Bob transaction will become invalid because it will be seen as a double spending
● It is very unlikely for Alice to win the race as she is competing against the rest of
the network
○ She would need 50% of the entire computing power to have a 50% chance
● As a consequence, transactions far back in the chain are more secure
○ It is recommended to wait several Blocks until assuming a transaction final
29. Bitcoin double spend attack
● People group together in mining pools
○ Steady income on mining rewards or fees
○ Some pools have more than 20% of the total computing power
○ BTC Guild solved 6 Blocks in a row by itself
■ Voluntarily limited his members
■ It is recommend to wait more than 6 Blocks to assume that a transaction is final
● On average each Block takes 10 minutes
● Only after 1h or 1h30m a Block can be assumed final
30. ● A reward is given to who solves a Block
○ This is why Block solving is called Mining
● Every 4 years the reward is cut in half
○ Last Bitcoin will be in mined in 2140
○ Total possible Bitcoins: 21 Million
■ You can send 0.00000001 Bitcoins in transactions
● Transaction fees
○ To retain the incentives to mining
○ Mining in reality is the processing of transactions
○ Transactions with fees will probably be processed faster
○ Hopefully fees will be lower compared to other payment systems
Bitcoin Generation
31. ● Used for illegal activities
○ WannaCry ransomware asked Bitcoins as ransom payment
● Mining uses a huge amount of energy
● Specialized hardware is being created for mining
○ GPUs are extremely well suited for Mining
■ Both AMD and Nvidia are working on special hardware, tuned hardware and specific drivers
for current products
■ There have been shortages of GPUs
● Main sources of information used in this talk and useful links
○ https://anders.com/blockchain/
○ https://www.youtube.com/watch?v=_160oMzblY8
○ http://www.fudzilla.com
Bitcoin final considerations
32. Thank You
Twitter
@EqualExperts
LinkedIn
linkedin.com/company/equal-experts
UNITED KINGDOM
+44 203 603 7830
helloUK@equalexperts.com
Equal Experts UK Ltd
30 Brock Street
London NW1 3FG
INDIA
+91 20 6607 7763
helloIndia@equalexperts.com
Equal Experts India Private Ltd
Office No. 4-C
Cerebrum IT Park No. B3
Kumar City, Kalyani Nagar
Pune, 411006
Web
www.equalexperts.com
CANADA
+1 403 775 4861
helloCanada@equalexperts.com
Equal Experts Devices Inc
205 - 279 Midpark way S.E.
T2X 1M2
Calgary, Alberta
PORTUGAL
+351 211 378 414
helloPortugal@equalexperts.com
Equal Experts Portugal
Avenida Dom João II, Nº35
Edificio Infante 11ºA
1990-083 Parque das Nações
Lisboa – Portugal
Thank You
USA
+1 866-943-9737
helloUSA@equalexperts.com
Equal Experts Inc
1460 Broadway
New York
NY 10036