Of Blockchains, Crypto and NFTs:� Essential Blockchain and Crypto Mechanics for Engineers
Michael A. Ramalho, Ph.D.
May 19, 2022
FWCS SP/COMM Chair
IEEE Aerospace and
Electronics
Systems Society
Florida West Coast Section
Florida West Coast Section�(Michael Mayor / michael.mayor@ieee.org)
Orlando Section
(Pierce Mooney / pierce.a.mooney@ieee.org)
(Michael Ramalho / mar42@cornell.edu)
DISCLAIMER:
In other words: My opinion/analysis only. Use at your own risk.
2
© 2022 FWCS IEEE SP/COMM. All rights reserved.
TALK OUTLINE
3
© 2022 FWCS IEEE SP/COMM. All rights reserved.
Definitions: Blockchains, DAOs, NFTs
4
© 2022 FWCS IEEE SP/COMM. All rights reserved.
Blockchain Basics
Blockchain is a shared, immutable ledger that facilitates the process of recording “transactions” or ”assets”.
Virtually anything of value can be tracked or traded on a blockchain network (not just crypto or NFTs or music).
Key Elements:
* - Example: Bitcoin doesn’t release block creation awards until 100 blocks have past.
Blockchain Types – Blockchain Has Many Uses Other Than Crypto and NFTs!
* -Example: NIST Report 8419 (https://doi.org/10.6028/NIST.IR.8419 ).
Important: What is a Decentralized Autonomous Organization (DAO)? What is Web3?
A DAO is a organization - represented by rules encoded as a computer program - that is:
[In other words they are member-owned communities without centralized leadership used for ANY purpose.]�
A DAO's financial transaction record and program rules (e.g., smart contracts) are maintained on a blockchain.
A DAO participant thus eliminates the need to involve a mutually acceptable trusted third party for transactions.
Web3 is the general term for the next phase of the Internet:
Blockchains are essential Web3 technology - Individual Cryptocurrencies and NFT markets are DAO examples.
Three Essential Technologies for Blockchains and Cryptocurrencies
�NOTE: Non-engineers ... Just hold on until we get through this ...
8
© 2022 FWCS IEEE SP/COMM. All rights reserved.
Essential Technology: Consensus Algorithms For Public, Permissionless Blockchains
Blockchains aim to produce an immutable distributed ledger where some of the participants ...
�Thus, fault-tolerant consensus mechanisms are used in both distributed computing and blockchains to�arrive at the state of the network/blockchain among the distributed processing system participants.
�Since nefarious behavior on a crypto network may result in huge (and immutable) crypto losses - permissionless, public blockchains place a very high importance for secure, fault-tolerant consensus!�Both reward and penalty mechanisms are employed in most crypto blockchains.
�There are many such algorithms: Proof-of-Work, Proof-of-Stake, Proof-of-Authority, Proof-of-Space/Storage,�Proof-of-Elapsed-Time – and many yet to come.
�We will focus on the two most popular of these: “Proof-of-Work” and variants of “Proof-of-Stake”.
Essential Technology: Random Number Generators
Two general methods (one crypto uses both):
Cryptographic Secure Pseudo Random Number Generators (CSPRNG/CPRNG) are used in blockchain for:
Issues / Problems:
1: Is a given / 2: Is solved for many fields / 3: Is a given / 4: One way to solve is described later
Optional: Uniform pdf to�Desired pdf Mapping
N-bit Output (N<<M)
(Non-Uniform pdf)
Seed
CPRNG
Clock
M-bit Output
(Uniform pdf)
0
2M-1
~
f(x)
~
2M
1
Essential Technology: Cryptographic Hash Functions (SHA-256, p/o SHA-2 family from NSA*)
Input_Data
“One-Way” Hash Function (SHA-256)
Output_Hash (256 bits for SHA-256)
Arbitrary Length Input
Advanced Encryption Standard (AES) (FIPS PUB 197)
Deterministic value, but appears random relative to similar looking inputs.
Fixed-length Output (256 bits for SHA-256)
Example: Output_Hash = HashSHA-256(Input_Data)
0x7F83B1657FF1FC53B92DC18148A1D65DFC2D4B1FA3D677284ADDD200126D9069
0x451CAE5B3608B3556D46E41809AFBF80C1ADBEC092504D6FE86FA31A22795525
Hello World!
Hello Vorld!
“W” and “V” have only LSB different in ASCII encoding!
On average, 128 of the 256 bits will be different. For ANY difference in input!!�Often called “The Avalanche Effect”.
HASHSHA-256
HASHSHA-256
Designed to be virtually impossible to go this way.
“One-Way Functions”
Easy to go this way. Output only “appears random”.
https://doi.org/10.6028/NIST.FIPS.197
Input_Data1 : Input_Data2
HashSHA-256
Output_Hash (256 bits for SHA-256)
Deterministic value, but appears random relative to�EITHER Input_Data1 or Input_Data2.
Note: Concatenation often written as hash(x1 + x2) in�hash documentation (do not confuse with linear�addition of vectors). We will use this notation herein.
Concatenation of Inputs
This ”concatenation property” is often used in situations requiring hashing.
* - Others commonly used are RIPEMD, WHIRLPOOL, SWIFFT
Essential Technology: Merkel Tree & Merkel Root (Binary Hash Chain)
Binary Hash Tree of 4 Data Blocks
00
1
0
01
10
11
000
001
011
010
101
100
110
111
Block 0�Hash
Block 1�Hash
Block 7�Hash
Block 3�Hash
Block 2�Hash
Block 4�Hash
Block 5�Hash
Block 6�Hash
Merkel�Root
Merkel Tree with 8 Data Blocks
Hold on ... hashing is used in at least two more applications in blockchain!
Blockchain Basics – Bitcoin Example
13
© 2022 FWCS IEEE SP/COMM. All rights reserved.
Bitcoin – Most Famous Public Permissionless Blockchain for Cryptocurrency
“What is needed is an electronic payment system based on cryptographic proof instead of trust, allowing any two willing parties to transact directly with each other without the need for a trusted third party.”�
* - Original intent was not to be an investment vehicle.
How Blockchains are Formed – Bitcoin Version 2 Example
Diagram and block decode from: https://www.oreilly.com/library/view/mastering-bitcoin/9781491902639/ch07.html
To “Genesis Block” (Block at Height 0)
Side Note: “Block Height” is not stored anywhere – as it is NOT always a�unique identifier (when there are forks, multiple blocks may have same height).
Expand
Block at Height 277315
Block�Header
Hash of Block Header is: ”0000000000000002a7bbd25a417c0374cc55261021e8a9ca74442b01284f0569”
This is the�“chaining”�mechanism
The “previousblockhash” element is the “header hash” of the prior block in the chain.
Merkle Tree Root Hash (of transactions below header)
4 Bytes: The size of the block after this field.
”Unix time” (uint: seconds from Jan 1, 1970)
Version 2 rules used (for encoding of this block)
KEY TO BITCOIN: WILL EXPLAIN SHORTLY!
Crypto Blockchain Essentials
16
© 2022 FWCS IEEE SP/COMM. All rights reserved.
Proof-of-Work (PoW) Consensus Algorithm: Bitcoin’s “Computationally Intensive Puzzle”
* - There are exceptions to be described later.
Proof-of-Work: Let’s talk about that NONCE [Bitcoin/Original-Ethereum/Original-Dogecoin/Litecoin]
HASHSHA-256{[Bitcoin Block Header without Nonce field] + [Nonce]} = 256-bit Result*
* - When used for signature/verification purposes, result also called a “message digest”
Block Header
Transactions
Nonce
A Bitcoin Block
Similarly: If you want to try nonces to produce exactly k leading zeros in the result (i.e., 0b{k-zeros}{(256-k)-don’t cares}),�then ON AVERAGE we expect to try 1/(1/2k) = 2k trials to obtain this result.
Question: How many “random Nonces” do you have to try if you want the hash result to begin with a binary zero?�(Desired 256 bit result in binary to be 0b0XXXXXXXXX ...XX, where X is “don’t care”; that is value < 2255).��Answer: Since the result is expected to be random, there is a 50% probability of the first bit being a “0” (p = 1/21).��The probability distribution of the number X of Bernoulli trials needed to get one success is a geometric distribution�where the mean of the distribution is 1/p. So ON AVERAGE we expect to need 2 trials.
255 bits don’t care
one zero bit
Proof-of-Work: Let’s talk about that NONCE & DIFFICULTY
HASHSHA-256{[Bitcoin Block without Nonce field] + [Nonce*]} = 256-bit Result
* - Extra Credit: The Bitcoin Nonce field is only 32 bits. Why is this a problem? How to fix it?
If we want the result to 0b{k-zeros}{(256-k)-don’t cares}), ON AVERAGE we expect to try 1/(1/2k) = 2k Nonces.
Now suppose:
IF we were limited to hash results numbers having the form of 0b{k-zeros}{(256-k)-don’t cares},�THEN we would find k so as to produce a block every 10 minutes (again, on average).��We need to set 2k to be approximately equal to 600X, that is: k ⋍ log2[600*X].
200 Million, Tetra hashes/sec
(200*106) (1*1013) = (2*1021)
(84.8*106) (1*1013) = (8.48*1020)
Block 730466 (mined on April 04, 2022 at 7:10 PM EDT) hash is ...�0x00000000000000000002a24e1b956496a6f6c7d1eae6342488a257c9ade1909d�... which had 78 leading (binary) zeros (4*19+2).
Approximate hash rate in April 2022 is (2*1021),�so log2[(6*102)*(2*1021)] = 79.98, ~ 80 leading zeros needed
In July 2021, hash rate was (8.48*1020), ~ 79 leading zeros needed.
Homework: Playing with “Proof of Work” Blockchains – Go to https://demoblockchain.org/tokens*
Same�transactions�different�order
Different�Nonces�needed�for�four, hex�zeros
Miners don’t�all work on the�“same hash problem”�(e.g., transactions�can be recorded�in a different order).��Demo goal here is�for a hash result�to have form of�0x0000{XXXX}�(sixteen leading zeros).
Create your own blockchain.
* - This is a commercial site. Not an endorsement. Demo may be taken down at any time.
Possible Chain 1
Possible Chain 2
Proof-of-Work: What is the Target? How is DIFFICULTY Adjusted?
�Block 730466 (mined on April 04, 2022 at 7:10 PM EDT) hash is ...�0x00000000000000000002a24e1b956496a6f6c7d1eae6342488a257c9ade1909d�... which had 78 leading (binary) zeros (4*19+2).��Note: Wanting a result to be 0b{k-zeros}{(256-k)-don’t cares}) ... is equivalent to saying ...�the value must be less than or equal to 0b{k-zeros}11111111111111...111 (i.e., < 2(256-k))��Bitcoin specifies that the hash must be less than a specific target value (a specific 256 bit unsigned integer)�... thus not limited to power of 2 changes in our examples prior.�
Simplified, the Bitcoin’s target value is adjusted periodically as follows:
Bitcoin’s “Difficulty Adjustment” is an adaptive control system
* - Due to an error, actually 2015 blocks. See details at https://minerdaily.com/2021/how-are-bitcoins-difficulty-and-hash-rate-calculated�** - Hard adaptation limit/clipping at 4x or ¼ X at each target value epoch update.
Previous�Example
Bitcoin Difficulty – The Game Is Rigged!
Details:
Minting time for a�particular block.��The average time for�the (2016 block) epoch.��Note the block time�variance (~ -15/+20%).
Sichuan�Shutdown
Image Credit: https://wdrfree.com/stock-vector/carrot-man-carrots
INDEPENDENT OF HOW MANY MINERS ARE WORKING ON THE SOLUTION!
Miner 1 has�10% of hashpower
Miner 1�Doubles GPUs
Miner 1 now has�18% of hashpower
Double resource consumption with no collective gain!��Bitcoin Tragedy of the Commons!
The Genius of Bitcoin’s “Proof of Work” (sometimes called blockchain conflict resolution)
2 different miners “solve hash problem” at nearly the same time
A
B
Transactions on abandoned Fork A but not Fork B�will be introduced onto a future Fork B block.
Side Note: We now see why “block height” isn’t the chaining mechanism (A & B at same height).
The Horrible Downside of “Proof of Work” – ESG Waste!
To increase your chances of successful mining in a cost-effective manner you must:
13.5 Th/s, 1323 Watts
99.9%* of compute cycles (and thus electric power) is devoted to solving the Proof-of-Work hash “puzzle”!�Bitcoin hash operations today consume the equivalent of the power needs of Switzerland. This is unsustainable!�There must be more ESG-friendly ways to building blockchains in accordance with DAO principals!
“Bitcoin Mining” isn’t “mining” or “puzzle solving” in Traditional Sense: It is “Purposeful Random Guessing” at best!
Traditional Mining�(mine where gold was found before)
Puzzles Involve Skill�(would not try this piece in middle)
X
BITCOIN:�Idiocy of Random Digging�(dog without sense of smell)
Can We Choose the Next Block Host Without the Purposeful ESG Waste Used in “Proof of Work”?
Statistically, We already know the answer!
Let’s simplify the problem (we will later relax these assumptions):
Benevolent Ramalho�Random Choosing�Machine
1
2
3
4
5
6
7
8
N
Problems:
METHOD 1: FAIL
Cryptographically Secure�Pseudo Random�Number Generator
1
2
3
4
5
6
7
8
N
Seed
Clock
Challenges:
Hash�(what�else?)
S1
S2
S3
S4
S5
S6
S7
S8
SN
Enroll with�your secret�random number
Seed
Problem:
Last CPU to send their�secret (after seeing all�others) can bias seed.*
METHOD 2: FAIL
H1
H2
H3
H4
H5
H6
H7
H8
HN
Step 1: Enroll with�a hash of your secret�random number
ENROLL
S1
S2
S3
S4
S5
S6
S7
S8
SN
Step 2: After enrollment�is complete, then send�secret random number
VERIFY PREVIOUSLY�SENT HASH
Step 3: Verify previously�sent hash is correct�for secret sent.
WORKS: “RanDAO commit-reveal scheme”*
* - Ethereum uses this. There are other schemes as well.
S1
S2
S3
S4
S5
S6
S7
S8
SN
Seed
Hash
Step 4: Hash as before
* - Also called “grinding”.
“Proof-of-Stake” architectures “appoint” the next block creator without ESG waste in PoW�[Peercoin/Cardano/Avalanche/Polkadot/Solana/Ethereum 2.0]
* - And you guessed it, some of the mechanisms use hash randomness properties instead of CSPRNGs.
Loose Definition of “Proof of Stake”
Proof-of-Stake (PoS): Some Popular Variants
Highest Chance�of Being Chosen�for Pure PoS
Pure Proof of Stake (PPoS): Algorand
Other criteria for PoS weighting other than amount staked:
Delegated PoS (e.g., EOS) and Leased PoS (e.g. Waves) – Are variations on the above.
Proof of Importance (e.g., PoI, XEM)
Liquid PoS (e.g., Tezos)
Bonded PoS (e.g., Cosmos)
Others: Proof of Authority, Proof of Burn, Proof of Elapsed Time, Proof of Capacity, Proof�of Presence, Proof of Assignment, Delegated Byzantine Fault Tolerance, Proof of Activity ...
I prefer “Probabilistic Validator Selection” for these techniques.
Blockchain Hygiene: Incentives and Disincentives for “Proof-of-Work” and “Proof-of-Stake”
PoW:
* Bitcoin’s maturation period is 100 blocks (about 16 hours).
** Bitcoin/Litecoin expectation is circa 2140.
PoS / Delegated PoS (and other derivatives):
Economics of PoW/PoS: “Solo Mining/Minting” vs “Pooled Mining/Minting”
Solo Mining (PoW):
Solo Minting (PoS):
Pooled Mining (PoW):
Pooled Staking (PoS) or “Centralized Exchange Staking” (PoS):
This is the “crypto staking” you often hear about (e.g., Binance).
(https://coinmarketcap.com/alexandria/article/crypto-staking-guide)
Fiat-Currency vs Crypto Currencies / What are “StableCoins”?
Fiat Currencies: US Dollar, Euro, Yuan ...
Crypto Currencies: Bitcoin, Ethereum, Litecoin, Dogecoin ...
StableCoins: Tether (USDT), USD Coin (USDC), TerraUSD (UST), Binance USD (BUSD), ...
* - Due to control dynamics, some miners might exit – allowing remaining to become profitable.
May 13,�2022
(was 3rd�largest)
Side Note About Crypto Wallets (added since TerraUSD implosion)
Crypto Transactions:
Crypto Wallets:
Transactions (Scale/Latency/Cost Tradeoffs) & Role of “Layer 2 Crypto” Networks.
Scaling:
Goal: To increase transaction speed/throughput & minimize delay – ideally without sacrificing decentralization or security.
Layer 2 Downsides:
Layer 2 Networks (aka “sidechains” or “off-chain solutions”):
Reprise on DAO Governance ....
REPRISE (earlier slide):
A DAO is a organization - represented by rules encoded as a computer program - that is:
[In other words they are member-owned communities without centralized leadership used for ANY purpose.]�
A DAO's financial transaction record and program rules (e.g., smart contracts) are maintained on a blockchain.
A DAO participant thus eliminates the need to involve a mutually acceptable trusted third part for transactions.
IMPLICATION:
BOTH Layer 1 DAOs (a cryptocurrency) or a Layer 2 DAOs governance/rules (a “Web 2.0 sidechain”) requires�A SIGNIFICANT AMOUNT OF TRUST.
By participating in either/both – you are agreeing to the terms the DAO set.��Cryptocurrency and Layer 2 networks have significantly different governance. Caveat Emptor!
Future for Crypto, NFTs and Web3
34
© 2022 FWCS IEEE SP/COMM. All rights reserved.
Intersection of Non-Fungible Tokens (NFTs) and Crypto / What are ICOs?
Image credit: https://boredapeyachtclub.com/#/home
Web3 Economy: Opportunities and Concerns
REPRISE (earlier slide):
OBSERVATION & OPINION BELOW – COME TO YOUR OWN CONCLUSIONS!
Talk Summary
37
© 2022 FWCS IEEE SP/COMM. All rights reserved.
Talk Summary
38
© 2022 FWCS IEEE SP/COMM. All rights reserved.
39
© 2022 FWCS IEEE SP/COMM. All rights reserved.