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.
A cryptographic token is a quantified and tradable unit of value recorded on the blockchain.
Blockchains are both technological and social movements, yet very few people have both backgrounds.
Blockchain was born within the cypherpunks movement, strictly related to libertarian ideals and open source principles.
Cypherpunks write code, but they are equally talented as social agitators.
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. A Cypherpunk's Manifesto by Eric Hughes (9 March 1993)
If you don't already believe that blockchain was and is also a political project, read the message of Satoshi Nakamoto (creator of Bitcoin) 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 revolution.
Here is the original post of Satoshi Nakamoto proposing a peer-to-peer electronic cash system called Bitcoin.
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] "df8a9688de20afa8f42f8d9e42c7b74d4adea9c1b70efaae0227bb4c17cba37a"
# 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] "1c5de2ed842d981171451186773e34a2a877f75f44425001a3e57895585a0783"
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] "2019-05-29 14:27:40 CEST" ## ## [[1]]$data ## [1] "I'm genesis block" ## ## [[1]]$parent_hash ## [1] "0" ## ## [[1]]$hash ## [1] "97b8c61a154d920246d675b893af307d7bf22be639b820a57bd56fd17dae20df" ## ## ## [[2]] ## [[2]]$number ## [1] 1 ## ## [[2]]$timestamp ## [1] "2019-05-29 14:27:40 CEST" ## ## [[2]]$data ## [1] "I'm block 1" ## ## [[2]]$parent_hash ## [1] "97b8c61a154d920246d675b893af307d7bf22be639b820a57bd56fd17dae20df" ## ## [[2]]$hash ## [1] "ae91283e19f722ddb74dfe83e0721e07ad766e3e70f129b7515deaf543b983b6" ## ## ## [[3]] ## [[3]]$number ## [1] 2 ## ## [[3]]$timestamp ## [1] "2019-05-29 14:27:40 CEST" ## ## [[3]]$data ## [1] "I'm block 2" ## ## [[3]]$parent_hash ## [1] "ae91283e19f722ddb74dfe83e0721e07ad766e3e70f129b7515deaf543b983b6" ## ## [[3]]$hash ## [1] "fb6fe0265cba73aac5484d9af0d18d4f8b69189a0e3e7b266d1a469feeb488eb"
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(block, 1)
## $hash ## [1] "0c8536158da57a423750674eaaa1297c511896b82371fdc816e105c273fced41" ## ## $nonce ## [1] 2
proof_of_work(block, 2)
## $hash ## [1] "00e97789484d40519da718f435a117b6120914cb4ab2554a65ba00dc602e1982" ## ## $nonce ## [1] 297
proof_of_work(block, 3)
## $hash ## [1] "00026e5eb7139396d50dd199846a65eb8328dfa926d2faf68d12832ceba0b1c1" ## ## $nonce ## [1] 5318
proof_of_work(block, 4)
## $hash ## [1] "0000a090c57f694adaa44159d78608faf4232d89e4adc21d6e8e4aee1a77a9dd" ## ## $nonce ## [1] 41873
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] "2019-05-29 14:27:43 CEST" ## ## [[1]]$data ## [1] "I'm genesis block" ## ## [[1]]$parent_hash ## [1] "0" ## ## [[1]]$nonce ## [1] 1149 ## ## [[1]]$hash ## [1] "0006a32699f68d2c994c4589251193d4765a797462cca3f1b805f4a66c3cca77" ## ## ## [[2]] ## [[2]]$number ## [1] 1 ## ## [[2]]$timestamp ## [1] "2019-05-29 14:27:43 CEST" ## ## [[2]]$data ## [1] "I'm block 1" ## ## [[2]]$parent_hash ## [1] "0006a32699f68d2c994c4589251193d4765a797462cca3f1b805f4a66c3cca77" ## ## [[2]]$nonce ## [1] 3159 ## ## [[2]]$hash ## [1] "000f1a210b967a0b9762e8f3874e6d331f01c110ba00f63d3bf6b92eda95cbee" ## ## ## [[3]] ## [[3]]$number ## [1] 2 ## ## [[3]]$timestamp ## [1] "2019-05-29 14:27:43 CEST" ## ## [[3]]$data ## [1] "I'm block 2" ## ## [[3]]$parent_hash ## [1] "000f1a210b967a0b9762e8f3874e6d331f01c110ba00f63d3bf6b92eda95cbee" ## ## [[3]]$nonce ## [1] 4372 ## ## [[3]]$hash ## [1] "0006b7133ad010fe0efb3f36a966b69a8145f5649bafbdd9120d724a26d45cc6"
# 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
Finally, the blockchain ledger is distributed over a peer-to-peer network.
The steps to run the network are as follows:
Crypto art (or rare digital art) is limited-edition, collectible, and tradable art registered with a token on a blockchain.
We illustrate the typical workflow of crypto art with a real example from the digital gallery SuperRare.
Any sufficiently advanced technology is indistinguishable from magic. Arthur C. Clarke
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)
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.