1-Blockchain - Distributed Ledger - Cryptographic Basics For Cryptoc
1-Blockchain - Distributed Ledger - Cryptographic Basics For Cryptoc
BLOCKCHAIN AND
DISTRIBUTED LEDGER TECHNOLOGY
Module 1
Blockchain - Distributed Ledger - Cryptographic basics for cryptocurrency -
signature schemes, encryption schemes and elliptic curve cryptography - CAP
theorem - Categories of Blockchain: Public blockchain, Private blockchain,
Permissioned Ledger, Tokenized blockchain, Tokenless blockchain, and
Sidechains.
Money and Currency
• “The amount of goods my 10 US Dollar bill buys now is way less than
what it used to buy me 10 years ago”
• Simple terminologies that are used for examining money or currency
– Medium Of Exchange-It is widely accepted as a medium of
exchange
– Portable –It can be carried along and exchanged.
– Durable – It can be used a number of times without degrading.
– Fungible – Its one unit is equivalent to another.
– Divisible – It can be divided into smaller units of value.
– Store Of Value– It should maintain its purchasing power
Money and Currency: Fiat Money
Regulatory
Agency (RBI)
Customers Bank
Employee
Bank
How do you transact?
Your write a check or do internet transaction to pay a payee
Bank checks
if you have balance > transaction amount
If yes, it debits your account by balance = balance ‐ transaction_amount
credit’s payee’s account by payee.balance = payee.balance + transaction_amount
If no, the transaction is invalid and rejected.
You can check your transaction list online, or check the monthly
statement
Database uses centralized storage of data. Blockchain uses decentralized storage of data.
Data can be easily deleted or modified if needed Data once entered cannot be deleted and is
with proper authorization. permanent in nature.
Offers faster query and search capabilities for Search and query operations are generally slower
complex data structures. due to its distributed nature.
Vulnerability to single point of failure as data is Highly resistant to system failure due to
stored in one central location. distributed nature and multiple copies of data.
Cryptographic basics for
cryptocurrency
• A cryptographic hash function (CHF) is a
mathematical algorithm that maps data of arbitrary size (often
called the "message") to a bit array of a fixed size (the "hash value",
"hash", or "message digest").
• Ideally, the only way to find a message that produces a given hash is
to attempt a brute-force search of possible inputs to see if they
produce a match, or use a rainbow table of matched hashes.
You can’t “reconstruct” the cat picture from just the hash –ONE WAY FUNCTION
How does a cryptographic hash function work?
Suppose you want to hash a file containing the six bytes a1 02 12 6b
c6 7d. You want the hash to be a 1-byte number (8 bits). You can
construct a hash function using addition modulo 256, which means to
wrap around to 0 when the result of an addition reaches 256
Integrity Checks using Hash Values
Secure Hash Algorithm
• SHA originally designed by NIST & NSA in 1993
• Revised in 1995 as SHA-1
• US standard for use with DSA signature scheme
– standard is FIPS 180-1 1995, also Internet RFC3174
• based on design of MD4 with key differences
• produces 160-bit hash values
• recent 2005 results on security of SHA-1 have raised concerns on its use in
future applications
Examples of cryptographic hash functions
• MD 5:
– It produces a 128-bit hash. Collision resistance was broken
after ~2^21 hashes.
• SHA 1:
– Produces a 160-bit hash. Collision resistance broke after
~2^61 hashes.
• SHA 256:
– Produces a 256-bit hash. This is currently being used by
Bitcoin.
• Keccak-256:
– Produces a 256-bit hash and is currently used by Ethereum.
SHA Versions
Message size < 264 < 264 < 264 < 2128 < 2128
Block size 512 512 512 1024 1024
Word size 32 32 32 64 64
# of steps 80 64 64 80 80
Secure Hash Algorithm
• SHA-256 is used in several different parts of
the Bitcoin network:
– Mining uses SHA-256 as the proof-of-work
algorithm.
– SHA-256 is used in the creation of bitcoin
addresses to improve security and privacy.
Construction of Hash functions
• Hash functions are typically constructed from fixed-input compression functions!
– Example: See construction of SHA-256 Hash function SHA-256 used in Bitcoins
– Also referred to as Merkle-Damgard Transform
• Why does it work?
– Theorem: If c is collision-free, then SHA-256 is collision-free.
512
bits Message
Message Message (block n)
(block (block
1) 2)
256 256
bits bits
c c c Has
IV
h
SHA 256…
• it takes the message you're hashing, and it breaks it up into
blocks that are 512 bits in size. The message size, in
general, isn't necessarily a multiple of block size. To make it
a multiple of block size, we will use some kind of padding
(i.e. a 1 followed by a certain number of 0)
• you start with the 256-bit value called the IV, specified in
the standards document and the first block. This 768-bits
string goes through a special function c (compression
function) that outputs a 256-bits string
• Then the compression function (Merkle‐Damgard transform) is
applied to the concatenation of the first output and the
second block
• The process is repeated until the end of the blocks, the
hash is the final 256-bits output
One Compression function in SHA-256
• One compression function in
SHA-256 comprises
• a 256-bit block cipher with 64
rounds,
• a key expansion mechanism from
512 to 2048 bits, and
• a final set of eight 32-bit
additions.
Hash Pointers and Data Structures
Pointers
Hash Pointers
• Hash pointer is:
– Pointer to where some info/data is stored,
and
– (Cryptographic) hash of the info
Hash Pointers
An attacker wants to tamper with one block of the chain, let’s say, block 1.
The attacker changed the content of block 1, because of “collision free” property of the hash
function, he is not able to find another data which has the same hash with the old one. So
now the hash of this modified block is also changed.
To avoid others noticing the inconsistency, he also needs to change the hash pointer of that
block in the next block, which is block 2.
Now the content of block 2 is changed, so to make this story consistent, the hash pointer in
block3 must be changed.
Finally, the attacker goes to the hash pointer to the last block of the blockchain, which is a
roadblock for him, because we keep and remember that hash pointer.
Conclusion on Tamper evident log
• If the adversary wants to tamper with data anywhere
in this entire chain, in order to keep the story
consistent he's going to have to tamper with hash
pointers all the way back to the beginning. And he's
ultimately going to run into a road block, because he
wont be able to tamper with the head of the list.
• So we can build a block chain like this containing as
many blocks as we want, going back to some special
block at the beginning of the list which we might call
the genesis block. And that's a tamper evidence log
built out of the block chamber.
Merkle tree
• Another useful hash pointer data structure is the Markle tree.
• A Markle tree is a data structure used for efficiently verifying the
integrity of large sets of data.
• Binary tree with hash pointers!
H( ) H( )
H( ) H( ) H( ) H( )
H( ) H( ) H( ) H( ) H( ) H( ) H( ) H( )
Restricted to
Access Limited to a group Combination of
Open to everyone specific
Control of organizations public and private
participants