Imagine yourself to be a University Dean in the position of creating a new course on blockchains. To which department would you assign the course?
In fact, any of these departments would be appropriate.
Blockchains are both technological and social movements, yet very few people have both backgrounds.
The Crypto Anarchist Manifesto by Timothy C. May dates back to mid-1988 and was distributed to some like-minded techno-anarchists at the Crypto ’88 conference:
Combined with emerging information markets, crypto anarchy will create a liquid market for any and all material which can be put into words and pictures. Timothy C. May, Crypto Anarchist Manifesto
The following excerpt from the Cypherpunk Manifesto by Eric Hughes is particularly telling since it contains, 30 years before, all ingredients of modern blockchain technology:
We the Cypherpunks are dedicated to building anonymous systems. We are defending our privacy with cryptography, with anonymous mail forwarding systems, with digital signatures, and with electronic money. […] Cypherpunks write code. We know that software can’t be destroyed and that a widely dispersed system can’t be shut down. Eric Hughes, Cypherpunk Manifesto
Haber and Stornetta were trying to deal with the epistemiological problem of truth in the digital age:
The prospect of a world in which all text, audio, picture and video documents are in digital form on easily modifiable media raises the issue of how to certify when a document was created or last changed. The problem is to time-tamp the data, not the medium. Haber and Stornetta, How to Time-Stamp a Digital Document
Blockchain is much more than a technology, it is also a culture and community that is passionate about creating a more equitable world through decentralization.
We are now entering a radical evolution of how we interact and trade because, for the first time, we can lower uncertainty not just with political and economic institutions but with technology alone. Bettina Warburg
The numerous components of blockchain technology can make it challenging to understand.
However, each component can be described simply and used as a building block to understand the larger complex system.
The building blocks of a blockchain are… blocks.
A block is a container for data
In its simplest form it contains:
genesis_block = list(number = 0, timestamp = "2009-01-03 18:15:05", data = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks")
The ideal cryptographic hash function has five main properties:
# load library library(digest) # hash a string digest("Così tra questa immensità s'annega il pensier mio: e il naufragar m'è dolce in questo mare", "sha256")
## [1] "721956f9e4d4a31524ec94bc9926445c81228b96129132745a362eca8d016154"
# hash a slightly different string digest("Così tra questa infinità s'annega il pensier mio: e il naufragar m'è dolce in questo mare", "sha256")
## [1] "0095d410ee1935a163891970ee2606f2031238ac7adf839fe02d3353162cf5a0"
mine <- function(previous_block, genesis = FALSE){ if (genesis) { # define genesis block new_block <- list(number = 0, timestamp = Sys.time(), data = "I'm genesis block", parent_hash = "0") } else { # create new block current_number = previous_block$number + 1 new_block <- list(number = current_number, timestamp = Sys.time(), data = paste0("I'm block ", current_number), parent_hash = previous_block$hash) } # add hash new_block$hash <- digest(new_block, "sha256") return(new_block) }
chain = function(nblocks) { # mine genesis block block_genesis <- mine(NULL, TRUE) # first block is the genesis block blockchain <- list(block_genesis) if (nblocks >= 2) { # add new blocks to the chain for (i in 2:nblocks){ blockchain[[i]] <- mine(blockchain[[i-1]], FALSE) } } return(blockchain) }
chain(nblocks = 3)
## [[1]] ## [[1]]$number ## [1] 0 ## ## [[1]]$timestamp ## [1] "2020-04-02 14:11:42 CEST" ## ## [[1]]$data ## [1] "I'm genesis block" ## ## [[1]]$parent_hash ## [1] "0" ## ## [[1]]$hash ## [1] "b5eeb3c562f792b32eef6beb2b49811144d5bd82776ae1c3da0ef21454fb47f8" ## ## ## [[2]] ## [[2]]$number ## [1] 1 ## ## [[2]]$timestamp ## [1] "2020-04-02 14:11:42 CEST" ## ## [[2]]$data ## [1] "I'm block 1" ## ## [[2]]$parent_hash ## [1] "b5eeb3c562f792b32eef6beb2b49811144d5bd82776ae1c3da0ef21454fb47f8" ## ## [[2]]$hash ## [1] "ad2ff4ea8809d4441a0ce2f791a50b59bda6d27769188ec92821357224909fea" ## ## ## [[3]] ## [[3]]$number ## [1] 2 ## ## [[3]]$timestamp ## [1] "2020-04-02 14:11:42 CEST" ## ## [[3]]$data ## [1] "I'm block 2" ## ## [[3]]$parent_hash ## [1] "ad2ff4ea8809d4441a0ce2f791a50b59bda6d27769188ec92821357224909fea" ## ## [[3]]$hash ## [1] "0dc117c2cfdbdeaecb3857d78f7b4af636ef69ac8e707b3fb206b0a7b5670686"
proof_of_work = function(block, difficulty) { block$nonce <- 0 hash = digest(block, "sha256") zero = paste(rep("0", difficulty), collapse="") while(substr(hash, 1, difficulty) != zero) { block$nonce = block$nonce + 1 hash = digest(block, "sha256") } return(list(hash = hash, nonce = block$nonce)) }
proof_of_work(genesis_block, 1)
## $hash ## [1] "047a64e2b4e9b1a410e3000137388b87bd5a81cc4f123e31b955165e9f43696d" ## ## $nonce ## [1] 6
proof_of_work(genesis_block, 2)
## $hash ## [1] "003722bfa5f44c1feb4cb378c3c9ef81c296aad19b45cb276895205445cf52db" ## ## $nonce ## [1] 456
proof_of_work(genesis_block, 3)
## $hash ## [1] "0001d5bd9509cf12da2fece9045768d474064bc7b587332c8b19cd57b937aab4" ## ## $nonce ## [1] 2222
proof_of_work(genesis_block, 4)
## $hash ## [1] "00009859981b96f9db1ef9ad0b231579859d40f793dc76436adf9f20d5042112" ## ## $nonce ## [1] 98060
mine <- function(previous_block, difficulty = 3, genesis = FALSE){ if (genesis) { # define genesis block new_block <- list(number = 0, timestamp = Sys.time(), data = "I'm genesis block", parent_hash = "0") } else { # create new block current_number <- previous_block$number + 1 new_block <- list(number = current_number, timestamp = Sys.time(), data = paste0("I'm block ", current_number), parent_hash = previous_block$hash) } # add nonce with proof of work new_block$nonce <- proof_of_work(new_block, difficulty)$nonce # add hash new_block$hash <- digest(new_block, "sha256") return(new_block) }
chain = function(nblocks, difficulty = 3) { # mine genesis block block_genesis = mine(NULL, difficulty, TRUE) # first block is the genesis block blockchain <- list(block_genesis) if (nblocks >= 2) { # add new blocks to the chain for (i in 2:nblocks){ blockchain[[i]] <- mine(blockchain[[i-1]], difficulty) } } return(blockchain) }
chain(nblocks = 3)
## [[1]] ## [[1]]$number ## [1] 0 ## ## [[1]]$timestamp ## [1] "2020-04-02 14:11:47 CEST" ## ## [[1]]$data ## [1] "I'm genesis block" ## ## [[1]]$parent_hash ## [1] "0" ## ## [[1]]$nonce ## [1] 2767 ## ## [[1]]$hash ## [1] "00072a6bfe3dd5e9d095e2520aa1bcde75183cb02aeef262e862c8799c272c27" ## ## ## [[2]] ## [[2]]$number ## [1] 1 ## ## [[2]]$timestamp ## [1] "2020-04-02 14:11:47 CEST" ## ## [[2]]$data ## [1] "I'm block 1" ## ## [[2]]$parent_hash ## [1] "00072a6bfe3dd5e9d095e2520aa1bcde75183cb02aeef262e862c8799c272c27" ## ## [[2]]$nonce ## [1] 6643 ## ## [[2]]$hash ## [1] "0006bb284ca31067a8cd0b68ef34cb9ffe4e57542d1587f3e56206144be66b66" ## ## ## [[3]] ## [[3]]$number ## [1] 2 ## ## [[3]]$timestamp ## [1] "2020-04-02 14:11:48 CEST" ## ## [[3]]$data ## [1] "I'm block 2" ## ## [[3]]$parent_hash ## [1] "0006bb284ca31067a8cd0b68ef34cb9ffe4e57542d1587f3e56206144be66b66" ## ## [[3]]$nonce ## [1] 277 ## ## [[3]]$hash ## [1] "000e5157b7490f871c0cda9063a0af5582af66628d8a01459548044be26af04a"
## Digital signature # load library library(openssl) # generate a private key (key) and a public key (pubkey) key <- rsa_keygen() pubkey <- key$pubkey # build a transaction trans = list(sender = "A", receiver = "B", amount = "100") # serialize data data <- serialize(trans, NULL) # sign (a hash of) the transaction with private key sig <- signature_create(data, sha256, key = key) # verify the message with public key signature_verify(data, sig, sha256, pubkey = pubkey)
## [1] TRUE
## Encryption # load library library(openssl) # generate a private key (key) and a public key (pubkey) key <- rsa_keygen(512) pubkey <- key$pubkey # message msg <- charToRaw("Blockchain is magic!") # cipher the message with public key ciphermsg <- rsa_encrypt(msg, pubkey) # decrypt the message with private key rawToChar(rsa_decrypt(ciphermsg, key))
## [1] "Blockchain is magic!"
Finally, the blockchain ledger is distributed over a peer-to-peer network.
The steps to run the network are as follows:
A cryptographic token is a quantified and tradable unit of value recorded on the blockchain.
There are then different forms and functions of tokens:
A cryptocurrency (or digital currency) is a digital asset designed to work as a medium of exchange that uses strong cryptography to secure financial transactions, control the creation of additional units, and verify the transfer of assets.
B-money was an early proposal, dated 1998 and circulated in the cypherpunk mailing lists, created by Wei Dai for an anonymous, distributed electronic cash system
Satoshi Nakamoto (a pseudonymous) referenced B-money when proposing Bitcoin in 2009 in his white paper Bitcoin: A Peer-to-Peer Electronic Cash System
the message of Satoshi Nakamoto embedded into the very first Bitcoin block:
The Times 03/Jan/2009 Chancellor on brink of second bailout for banks
considering the context in which they appear – during the bank-driven financial crisis of 2009, the worst after the economic recession of 1929 – these words are calling for economic revolution
here is the original post of Satoshi Nakamoto proposing Bitcoin
F2Pool added the following message, a clear reference to Satoshi’s genesis block message, to block 629999, the last block before bitcoin halving:
NYTimes 9/Apr/2020 With $2.3T Injection, Fed’s Plan Far Exceeds 2008 Rescue
Fiat money is a currency without intrinsic value that has been established as money, often by government regulation.
The term fiat derives from the Latin fiat (“let it be done”) used in the sense of an order, decree or resolution.
Blockchain technology has many more potential use cases beyond other than just serving as the fuel behind Bitcoin.
Below, we’ve outlined some of its emerging applications across finance, business, and government.
Haber and Stornetta, the inventors of blockchain, in their proposal envisaged the adoption of blockchain beyond text, possibly in art as well:
Of course digital time-stamping is not limited to text. Any string of bits can be time-stamped, including digital audio recordings, photographs, and full-motion videos. […] time-stamping can help to distinguish original photograph from a retouched one. Haber and Stornetta, How to Time-Stamp a Digital Document
We illustrate the typical workflow of crypto art with a real example from the digital gallery SuperRare.
“Ownership does not include intellectual property rights such as copyright claims, ability to produce commercially, and create merchandise therefrom, etc. The intellectual property remains the possession of the creator” SuperRare Terms of Service
The incentive of rewards may help encourage nodes to stay honest.
If a greedy attacker is able to assemble more CPU power than all the honest nodes, he would have to choose between using it to defraud people by stealing back his payments, or using it to generate new coins.
He ought to find it more profitable to play by the rules (generate new coins), such rules that favor him with more new coins than everyone else combined, than to undermine the system and the validity of his own wealth. Satoshi Nakamoto (Bitcoin white paper)
Ethereum blockchain is enriched with smart contracts. The term smart contract dates to 1994, defined by Nick Szabo as:
A computerized transaction protocol that executes the terms of a contract. The general objectives of smart contract design are to satisfy common contractual conditions (such as payment terms, liens, confidentiality, and even enforcement), minimize exceptions both malicious and accidental, and minimize the need for trusted intermediaries.
The user issuing a transaction to a smart contract will have to pay a fee proportional to the complexity of the code executed.