Professional Documents
Culture Documents
(Sem-II)
Unit-II
Feature Engineering
Image courtesy: http://beetfusion.com/
A HISTORICAL PERSPECTIVE
20
The Fundamentals
Hash Functions: Map any sized data to a fixed size; Example H(x) = x %
n, where x and n are integers and % is the modular (remainder after division
by n) operations. x can be of any arbitrary length, but H(x) is within the
range [0,n-1].
Cryptographically Secured:
One way, given a x, we can compute H(x), but given a H(x), no deterministic
algorithm can compute x
For two different x1 and x2, H(x1) and H(x2) should be different
Cryptographic Hash Functions
Examples: MD5, SHA256
D1 D2 D3 D4
Use of Merkle Trees
Bayer, Harber and Stornetta used Merkle Tree in 1992 for timestamping and verifying a
digital document - improved the efficiency by combining timestamping of several
documents into one block
Source: Statistica
The Technology behind Bitcoin – The Blockchain
A = ₹100 A = ₹100
₹ 50
A -> B ₹50 A -> B ₹50
A = ₹100 A = ₹100
The term was coined by Nick Szabo, a computer scientist and cryptographer, in 1996
Szabo claimed that smart contracts can be realized with the help of a public ledger
The product team expects the money to be get paid based on the
project progress
The contract is written in a code which is available to all the stakeholders – the supporters and
the product team – Do you see an application of Blockchain here?
Crowdfunding Platform using Smart Contracts
If certain goals of the project are reached, then the code automatically transfers the money from
supporters to the production team
Crowdfunding Platform using Smart Contracts
If the project goals (contracts) fail, then the code can transfer the money back to the supporters
Smart Contracts – The Advantage
Immutable: No party will be able to change the contract once it is fixed and written to
the public ledger (the Blockchain)
Distributed: All the steps of the contract can be validated by every participating party –
no one can claim later that the contract was not validated
Why Blockchain?
The blocks are immutable
The information is open – everyone can check and validate
Smart Contract Platforms
Image courtesy: http://beetfusion.com/
THE ARCHITECTURAL
PRINCIPLES
44
The Blockchain
Spanned over multiple organizations or individuals who may not trust each other
In Bitcoin: A block may contain more than 500 transactions on average, the average size
of a block is around 1 MB (an upper bound proposed by Satoshi Nakamoto in 2010)
May grow up to 8 MB or sometime higher (as of March 2018)
Larger blocks can help in processing large number of transactions in one go.
Structure of a Block (Reference: Bitcoin)
Two components:
Block Header
List of Transactions
T1 T2 T3 T4
Block Header (Reference: Bitcoin)
Block identifier – the hash of the current block header (Hash algorithm: Double SHA256)
Previous block hash is used to compute the current block hash
Transactions in a Block (Reference: Bitcoin)
Transactions are organized as a Merkle Tree. The Merkle Root is used to construct the block
hash
If you change a transaction, you need to change all the subsequent block hash
The difficulty of the mining algorithm determines the toughness of tampering with a block in a
blockchain
Transactions in a Block (Reference: Bitcoin)
The Block contains two parts – the header and the data (the transactions)
The header of a block connects the transactions – any change in any transaction will
result in a change at the block header
The headers of subsequent blocks are connected in a chain – the entire blockchain
needs to be updated if you want to make any change anywhere
Layers of Blockchain
Image courtesy: http://beetfusion.com/
THE MINERS
2
The Life of a Miner
• Validate transactions and construct a block
• Listen for new blocks – validate and re-broadcast a new block when it is
proposed
current_difficulty = previous_difficulty *
(2 weeks in milliseconds)/(milliseconds to
mine last 2016 blocks)
Hash-rate versus Difficulty
• The hash is a random number between 0 and 2256-1
– Tofind a block, the hash must be less than a given target
Source: http://bitcoin.sipa.be/
MiningHardware
• Specialized hardware
– GPU
– FPGA
• ASIC
– Released in 2013
– Fast computation of
SHA256
Image source:
https://steemkr.com/bitcoin/@pawank/bitcoin-mining
TerraMiner IV
• ASIC based bitcoin mining rig
• 2Terahash per second
• Cost: USD 3500 approx
MiningPool
• Pooling of resources by the miners
• Cons
– Leads to centralization
– Discourages miners for running complete mining procedure
Summary –Permissionless BlockchainandBitcoin
• The permissionless or open model of blockchain – any user can join the network
and participate in transactions
– Bitcoin is developed on this principle