and the


Luigi R. Viggiano

## About this presentation How to navigate: - space bar: next slide - n: next, p: previous - f: full screen - esc: overview - arrow keys: directional moves - s: speaker's view with notes Open source: [fork me on github](!
## About the author - Funder member of JUG Torino. - Uses Java since 2000. - Free lance, worked in finance, telecommunications and public administration. - Uses bitcoin since Jul-2015. - Learning blockchain and crypto currencies since November 2017. - Author of [OWNER](, an open source Java configuration library focused on properties files.
## Agenda - What is money. - What are bitcoins and what is the blockchain. - How cryptography and distributed networking have been applied in bitcoin. - What is mining. - What is the current status and the future potentials of the blockchain. Note: - DAPP: Decentralized Applications. - DAO: Decentralized Autonomous Applications.


## Brief history of monies - Barter. - Rare metals, minerals. - Gold/Silver/Bronze coins. - Adoption of the Gold Standard (1821-1900). - Banknote (convertible to gold). - Fractional-reserve. - "Fiat Money" (end of Gold Standard, Richard Nixon in 1971). Note: - baratto - oro, argento, diamanti (gold standard) - monete d'oro (circolazione aurea) garantite dall'imperatore, giulio cesare (primo caso di inflazione) - nota di banco (convertibile in oro) - riserva frazionaria (in Europa l'1% è la riserva obbligatoria) - abolizione del gold standard -> "Fiat Money", Moneta fiduciaria senza copertura - Friedrich August von Hayek "Denationalization of Money"

Money Functions

The main functions of money are distinguished as:
  • a medium of exchange;
  • a unit of account;
  • a store of value;
  • and, sometimes, a standard of deferred payment.
Any item or verifiable record that fulfills these functions can be considered as money.
## Money Properties To fulfill its various functions, money must have certain properties: - Fungibility: its individual units must be capable of mutual substitution (i.e., interchangeability). - Durability: able to withstand repeated use. - Portability: easily carried and transported. - Divisibility: can be divided into small increments that can be exchanged for goods of varying values. - Cognizability: its value must be easily identified. - Stability of value: its value should not fluctuate.
# Bitcoin - Cryptography. - Distributed Networking. - Game Theory. - Economic Theory. Note: Il protocollo è l'insieme di regole utilizzate per gestire la comunicazione e lavorare le transazioni. - Crittografia coinvolge gli aspetti legati alla privacy delle informazioni, alla integrità e alla non ripudiabilità. - Distributed networking coinvolge lo scambio di informazioni in una rete decentralizzata, e il consenso su queste informazioni, per costruire un Libro Mastro (Ledger) su cui tutti sono d'accordo su chi possiede quanti bitcoin (o relativi asset su altre blockchain). - Game theory, coinvolge le regole implementate in bitcoin affinché ogni giocatore tragga vantaggio dal seguire le regole, e uno svantaggio in caso in cui cerchi di imbrogliare. Rif: John Nash, John Nash. - La teoria economica legata a bitcoin riguarda gli aspetti intrinseci e sociali della moneta come l'emissione, la divisibilità, la fungibilità e gli aspetti quali l'impatto della regolamentazione.

What is Bitcoin?

First decentralized digital currency.
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.
Satoshi Nakamoto - the bitcoin whitepaper

Why Bitcoin?

The Times 03/Jan/2009 Chancellor on brink of second bailout for banks
Satoshi Nakamoto - Genesis Block

Why Bitcoin?

We can win a major battle in the arms race and gain a new territory of freedom for several years.

Governments are good at cutting off the heads of a centrally controlled networks like Napster, but pure P2P networks like Gnutella and Tor seem to be holding their own.
Satoshi Nakamoto

Brief History of Bitcoin

  • September 2008 - Bankruptcy of Lehman Brothers.
  • January 2009 - Bitcoin Genesis Block.
  • June 2011 - WikiLeaks accepts bitcoins donations.
  • October 2013 - FBI arrests Ross Ulbricht (Silk Road).
  • December 2013 - China crackdown.
    • January 2014 - Alibaba stops using bitcoins.
  • February 2014 - Mt. Gox bankruptcy, lost 850k btc.
  • January 2015 - Bitstamp hacked, lost 19k btc.
  • August 2016 - Bitfinex hacked, lost 120k btc.
  • 2017 - Japan, Russia, USA and others talk about regulations.
  • December 2017 - Bitcoin futures CBOE and CME quoted on Chicago Stock Exchange.
## What is the Blockchain? - Decentralized Database. - Records are "Blocks" of transactions - Tamper-proof (verifiable) - Immutable (permanent and unmodifiable)
## What's new? - Solves the problem of "double spending". - Decentralized. - Trustless: no financial institutions, governments... - Censorship resistant.
## What's new? - Resilient and Secure. - Permissionless - instant - low cost bank for everyone - 24/7 365 days/year. - Transnational, borderless. Note: - Il "double spending" in una rete decentralizzata e asincrona è da sempre considerato non un problema difficile da risolvere, ma impossibile. - Resilient: nessuno è mai riuscito a fermarlo, hackerarlo o semplicemente romperlo.
## What's new? Bitcoin is - Asset, not liability. - Scarce. - Emission mimics gold extraction. - Divisible. - Durable.

What's new?

The first time in history we have a digital asset that can be transferred but cannot be duplicated.

Gold 2.0?

## Bitcoin vs FIAT Money vs Gold | Functions | Gold | FIAT Money | Bitcoin | |--------------------|------|------------|---------| | Medium of exchange | OK | OK | OK | | Unit of account | OK | OK | OK | | Store of value | OK | OK | OK |
## Bitcoin vs FIAT Money vs Gold /2 | Properties | Gold | FIAT Money | Bitcoin | |--------------------|------|------------|---------| | Fungibility | + | ++ | +++ | | Durability | ++ | + | ++ | | Portability | - | + | ++ | | Divisibility | + | ++ | +++ | | Cognizability | - | + | ++ | | Stability | ++ | + | - | Note: - Fungibility: its individual units must be capable of mutual substitution (i.e., interchangeability). - Durability: able to withstand repeated use. - Portability: easily carried and transported. - Divisibility: can be divided into small increments that can be exchanged for goods of varying values. - Cognizability: its value must be easily identified. - Stability of value: its value should not fluctuate.
## Bitcoin vs FIAT Money vs Gold /3 | Characteristics | Gold | FIAT Money | Bitcoin | |-----------------|--------------|---------------|--------------| | Intrinsic value | None | None | None | | Security | Chemical | Paper & Ink | Cryptography | | Emission | Availability | Discretionary | Algorithmic | | Adoption | Voluntary | Legal | Voluntary |


Cryptography is the practice of techniques for secure communication in the presence of third parties called adversaries. More generally, cryptography is about constructing and analyzing protocols that prevent third parties or the public from reading private messages.
## Cryptography Cryptography is a branch of information security. - Privacy => Encryption. - Integrity => Digest, Digital Fingerprint. - Non-repudiation => Digital Signature. Note: - La privacy riguarda il fatto che io devo poter trasmettere informazioni confidenziali ad un destinatario prevenendo che queste informazioni siano lette da persone non autorizzate. Questo problema attiene alla cifratura dei messaggi. - L'integrità riguarda il contenuto di un messaggio, e cioè posso confidare sul fatto che le informazioni non siano state alterate da un nemico. - La non ripudiabilità riguarda il fatto che una volta che so che un messaggio è non è stato nè intercettato nè alterato da un nemico, questo messaggio possa essere attribuito al mio interlocutore con certezza e quindi non possa essere ripudiato. Questo argomento è pertinente quindi alla firma digitale.

Symmetric-key Encryption

The encryption key is shared between Alice and Bob, and they need to keep it secret.


How can they safely exchange the secret shared key?

Asymmetrical Encryption

Alice and Bob will generate two complementary keys.

What can be encrypted with one key can be decrypted with the other key.

## Asymmetrical Encryption The "Secret Key" is kept safe and secret. ![Key Handling](images/crypto-asym-key-handling.svg) The other key is the "Public Key" and is given to everyone.
## Asymmetrical Encryption Bob shared his Public Key on the network, so Alice can use it. ![Asymmetrical Encryption](images/crypto-asymmetric-key.svg) Only Bob can decrypt the message with the Secret Key. Note: Bob generate a two keys: a public key and a secret key. Bob gives Alice his public key on the public network. Alice uses Bob's public key to encrypt the message. Bob uses his private key to decrypt Alice's message.
## Criptographic Hash functions Hash functions maps data of arbitrary size to a fixed size. ![Hash function](images/hash-functions.png) They are used to create "digests" or "fingerprints" for data integrity. Note: - Un esempio di controllo di integrità è il controllo di parità o il check-sum. - Un altro esempio è il codice fiscale, l'ultima lettera è calcolata sulla base di tutte le altre.
## Cryptographic Hash functions Properties: - Deterministic. - Quick to compute. - Infeasible to reverse. - Unpredictable: small change on the input => complete different output. - Resistant to collision. Popular hash functions: MD5, SHA, DSA. Bitcoin uses SHA-256 (32 bytes output, [2^256 possible combination]( Note: - deterministic: dato un input viene prodotto sempre lo stesso output - infeasible to reverse: dev'essere impossibile, dato un hash ottenere il messaggio originale L'unico modo dev'essere il brute force. - small change: idealmente, cambiando un bit nel messaggio originale ogni bit nel valore dell'hash dovrebbe avere il 50% di possibilità di cambiare. - collision: due input diversi non devono mai generare lo stesso hash - SHA: Secure Hash Algorithm - DSA: Digital Signature Algorithm - MD5: Message Digest
## Cryptographic Hash functions Example: ```bash $ echo -n "Vires in numeris." | md5 82e556facfe79ad4e31851f310284756 $ echo -n "Vires in numeris." | shasum -a 256 663dbafd847734a61d5e87b84988455e8920c470931c38d1a10b1cc4783e61d6 - $ echo -n "Vires in numeris. 1" | shasum -a 256 e93fa18d3dd5cd416388de277a2e270c0cbd4eeeb62fceae84727492d722a8fa - $ echo -n "Vires in numeris. 2" | shasum -a 256 651becf6a431285a350abf62537bece3b438a3a88e9eea6b8fb5554a85026508 - ``` See: [SHA-256 demo](
## Digital Signature Combining Cryptographic Hashing with Asymmetric Encryption we can achieve digital signature: ![Digital Signature](images/crypto-digital-signature.svg) Both authenticity and integrity can be verified by everyone having Alice's Public Key. Note: It is not necessary to encrypt the message, but just the hash "fingerprint". To verify the signature one can decrypt just the hash value with the public key, then check if that matches with the hash of the message.
## The # Bitcoin Protocol
## Transaction A transaction contains basically the same information of a cheque. ![cheque](images/cheque.jpg) But digital signature allows anyone to verify the transaction, immediately and safely.
## Transaction Alice sends $2 to Bob, and signs the transaction: | From | To | Amount | Signature | | ------------- | ------------- | ------- | --------- | | Alice | Bob | $2 | 101110111 | The transaction is transmitted to all the nearest nodes in the bitcoin network and after few seconds every node has a copy of it in the `mempool`.
## Double Entry Bookkeeping Example: Alice sends 0.8 btc to Bob. ![Transaction](images/transaction.svg) The change is given back to Alice, and a little amount is given to the miner as fee. Note: - Double Entry Bookkeeping: in Italiano Partita Doppia: dare (input) avere (output).
## Bitcoin Transaction And here is how real transactions look like on []( website. ![Blockchain transaction](images/blockchain-txs.png)
## The Ledger The Ledger contains all the transactions since the beginning. | From | To | Amount | Signature | | ------------- | ------------- | ------- | --------- | | - | Alice | $10 | 010101110 | | - | Bob | $5 | 101110110 | | - | Charlie | $3 | 111010110 | | Alice | Bob | $2 | 101110111 | | Bob | Charlie | $1 | 010001001 | Note: Traduzione di Ledger: Libro Mastro
## Decentralized Ledger Every node has a full copy of the blockchain, achieving a decentralized ledger. ![Decentralized Ledger](images/decentralized-ledger.png)

Bitcoin Address

Bitcoin Address

Generated by

## Bitcoin Address - The private key is (a random number <2^256) used to sign spending transactions. - The bitcoin address represent the beneficiarys; it is obtained by a hashing algorithm and is represented in Base 58, contains a version digit and a checksum. ![Bitcoin Address Generation](images/bitcoin-address-generation.svg) Note: - 2^256 is a large number, ~ 10^77 in decimal, (the visible universe is 10^80 atoms.) - Base 56 is used to make it compact and easier to read. Excerpt From: Andreas M. Antonopoulos. “Mastering Bitcoin”.

Bitcoin Address

hd keys

  • Type 0: Non deterministic Wallets (deprecated).
  • Type 1: Deterministic (seeded) Wallets.
  • Type 2: Hierarchical Deterministic Wallets.

See: Mnemonic code converter.

## Block Blocks contain transactions and header information. ![Block](images/block.png) When the proper hash is calculated, the block can be appended in the blockchain.
## Blockchain Blocks are chained using hash; altering any part of a block, invalidates all subsequent blocks! ![Blockchain](images/blockchain.png) See: [blockchain demo](
## Bitcoin Header ![Bitcoin header](images/block-header.png) See: [](

Merkle Tree

Merkle Tree, or Hash Trees, allow efficient verification of large data structures.

Hash Tree

## Network 1. New transactions are broadcast to all nodes. 2. Each node collects new transactions into a block. 3. Each node works on a proof-of-work for its block. 4. When a node finds a proof-of-work, it broadcasts the block. 5. Nodes accept the block only if all transactions in it are valid and not already spent. 6. Nodes express their acceptance of the block by working on creating the next block. Blocks in the blockchain become immutable.
## Double Spending Alice has $10 in her balance, but she tries to cheat. ![Double Spending](images/double-spending.svg) Only one of the two nodes will be able to validate the transaction in a block, so Alice won't able to double spend her money.
## Blockchain Fork Different parties need to use common rules to maintain the history of the blockchain. - A blockchain diverges into two potential paths forward. - A change in protocol. - Hard Fork (change in rules, nodes need an update) - Soft Fork (change in rules, backward compatible) Note: - Hard Fork: change in rules, old nodes need an update because they'll refuse new blocks. - Soft Fork: change in rules, old node will accept new blocks; new nodes may or may not accept old blocks. - [User Activated Soft Fork] ( - Miner Activated Soft Fork
## Blockchain Fork Two miner generate two different blocks at the same time. ![Blockchain Fork](images/blockchain-fork.svg) Two (or more) blocks have the same block height.

Blockchain Consensus

Blockchain Fork Resolution

Miners will work on the longest chain; the shorter chain are quickly invalidated. The network will reach the consensus in few blocks. Every new block added is basically a confirmation over the previous ones.


Mining is the process to add new blocks of transactions in the block chain.
## Mining Mining is intentionally designed to be resource consuming, but quick to verify. - Verify the transactions (balance, signatures, etc). - Determine the consensus over the network, and prevent double spending. - Securing the block chain, making computationally impractical to be modified by anyone. Mining is a competitive task: the first who mines a new block wins.


Miners are paid for their work with transaction fees and a reward: new bitcoins emission.

This decreasing-supply algorithm approximates the rate at which commodities like gold are mined.

## Proof of Work PoW system is security measure to deter denial of service attacks and other service abuses such as spam on a network by requiring some work from the service requester. PoW is a technique used to secure the blockchain using SHA-256, this process is called "mining". The primary purpose of mining is to allow Bitcoin nodes to reach a secure, tamper-resistant consensus.
## Proof of Work in practice Finding a SHA-256 starting with "00" (difficulty) ```bash $ echo -n "Vires in numeris. 1" | shasum -a 256 e93fa18d3dd5cd416388de277a2e270c0cbd4eeeb62fceae84727492d722a8fa - $ echo -n "Vires in numeris. 2" | shasum -a 256 651becf6a431285a350abf62537bece3b438a3a88e9eea6b8fb5554a85026508 - ... $ echo -n "Vires in numeris. 174" | shasum -a 256 0051d0c37a3326411c9a4d2d338494c602ed6cb3d6e65bc9089ab2e08793ad53 ``` The more leading zeroes you require, the harder is to find a matching solution. Difficulty is exponential: 2^n, where n=number of bits. Note: The "00" is expressed in hexadecimal, so it means 00000000 in binary.
## Mining Difficulty Bitcoin network goal is to add a new block every 10 minutes. - Miners compete to be the first one to generate a new block. They need investing upgrading the hardware and increasing the overall Hash Rate. - Every 2 weeks (2016 blocks) the difficulty is adjusted calculating the new difficulty to *retarget* the network to have a new block every 10 minutes, constantly.

Mininig Difficulty


Having a higher hash power advantages one miner over the others; mining industry developed more energy and cost efficient strategies over the years:

  • CPU.
  • GPU (graphic cards, 400x-800x faster than CPU mining, up to 2,100 Mhash/sec).
  • FPGA (Field-programmable gate array, up to 25,200 Mhash/sec).
  • ASIC (Application-specific integrated circuit, up to 18,000,000 Mhash/sec).
  • Pooled mining.

# Using Bitcoin
## Use cases - International remittance. - Store of value. - Online payments. - Charity. - Mining. - Micro payments. (Lightning Network) Note: - International remittance: A remittance is a transfer of money by a foreign worker to an individual in his or her home country - Store of value against inflation Venezuela - Online stores have advantage of lower fee compared to credit card, paypal etc.


Hot storage

  • Web Wallets.
  • Software Wallets:
    • Mobile Wallets.
    • Desktop Wallets.

Cold storage

  • Paper Wallets.
  • Hardware Wallets.

Web Wallets

Web Wallets


  • Ease of use.
  • Accessible from any device.
  • Usually linked with exchange services.


  • Private keys are on someone else's server.
  • Prone to hackers.
  • Website management can suspend and control your account.
  • You rely on someone's else security.
TIP: Always use 2FA.

Software Wallets

Software Wallets


  • More secure than online wallets.
  • You have control over your money.
  • Easy for everyday usage and practical to carry.
  • You can backup by yourself.


  • Vulnerable to malwares, virus, and hackers.
  • The device can be lost or stolen or incur in an hardware failure.

Paper Wallets

Paper Wallets


  • More secure than software wallets and online wallets.
  • Always off-line (when properly handled) cannot be hacked.
  • Easy to backup.


  • They can get damaged with time, water, fire...
  • They can get stolen.
  • They need to be generated offline; some technical knowledge is necessary.

Hardware Wallets

Hardware Wallets


  • Most secure.
  • Can be backed up.
  • Password protected.
  • Minimal risk to hacking.


  • Cost.
  • Not very easy for everyday usage.

Future blockchains

Where are we today?

  • Currencies.
    • Privacy coin.
  • Developer Tools, Smart contracts, Platforms.
  • Content Monetization, Distributed Computing.
  • Trading, Insurance, Lending, Investing, Value Exchange.
  • Governance, Healthcare, Identity.
  • Others: Products Tracking and Food Traceability, Smart Properties, Gaming, Gambling, Sports.

Decentralized Applications

Do DApps already exist?

Smart Contracts

  • Self-executing contracts.
  • SC are programs with a wallet.
  • They involve a number of parties.
  • SC encodes rules and penalties around an agreement in a computer program.
  • A trigger event (like an expiration date, for example) is hit and the contract executes itself.
  • Oracles are trusted data feeds that send information to the Smart Contract.

Autonomous Agents

  • Software that runs without needing human assistance.
  • They could be able to reproduce (like a computer virus)
    • i.e. rent virtual private servers and install new instances of itself.
  • They could improve their program, hiring devs or using genetic algorithms and AI.

Decentralized Applications

DApp = frontend (or client) + contracts.

  • Public registries (car or home registry, dns names, etc.)
  • Smart properties, smart properties sharing.
  • Insurance.
  • Governance, iVoting.

Decentralized Autonomous Organizations

It is an entity that lives on the internet and exists autonomously, but also heavily relies on hiring individuals to perform certain tasks that the automaton itself cannot do.

Decentralized Autonomous Organizations

  • Has an internal capital, or properties and assets.
  • Makes decisions for itself.
  • Can buy resources and hire people.
  • They could pay dividends => Decentralized Autonomous Corporations (DAC).

See: DAOs, DACs, DAs and More: An Incomplete Terminology Guide, Vitalik Buterin.

## References - Demo: - [Anders Brownworth: Blockchain demo]( - Books: - [Satoshi Nakamoto: Bitcoin: A Peer-to-Peer Electronic Cash System]( - [A. M. Antonopoulos: Mastering Bitcoin]( - [Gianmaria Allisiardi: Bitcoin Per Tutti](
## References - Online courses: - [Bitcoin and Cryptocurrency Technologies]( - Movies: - [Christopher Cannucciari: Banking on Bitcoin]( - [Nicholas Mross: The Rise and Rise of Bitcoin]( - [Bitcoin: The End of Money as We Know It]( - Youtube: - [Andreas M. Antonopoulos]( - [Marco Ducci]( - [Ferdinando M. Ametrano](

The end

Thanks for your attention!