Professional Documents
Culture Documents
Functions
Security properties:
• Property 1: Deterministic
• No matter how many times you parse through a particular input through a hash function you will
always get the same result.
• Property 2: Quick Computation
• Hash function should be capable of returning the hash of an input quickly.
• Property 3: Pre-Image Resistance
• Given H(x), it is infeasible to determine x, where x is the input and H(x) is the output hash.
• Property 4: Small Changes In The Input Changes the Hash.
• Even if you make a small change in your input, the changes that will be reflected in the hash will be
huge.(Avalanche effect)
• Property 5: Collision Resistant
• It is infeasible to find x and y such that x != y and H(x)=H(y)
H(x) = H(y)
y
Collisions do exist ...
possible outputs
possible inputs
c c c
IV Hash
SHA-256 Operation
• Takes the message you're hashing, breaks it up into blocks that are
512 bits in size, pad the blocks if it is not a multiple of 512 (i.e. a 1
followed by a certain number of 0)
• 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 cc(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,
Secure Hash Algorithm in Bitcoin
• 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.
Pointers and Linked Lists
• Pointers
• Pointers are variables in programming which stores the address of another
variable.
• Linked Lists
• a sequence of blocks, each containing data which is linked to the next block via a
pointer variable which is pointing to address of the next node in it and hence the
connection is made
• The first block is called as “genesis block”
Linked List
Hash Pointer
• hash pointer is:
• pointer to where some info as well as the (cryptographic) hash of the info are
stored.
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,
Merkle Tree
• Binary tree with hash pointers = “Merkle tree”
• A Markle tree is a data structure used for efficiently verifying the integrity of
large sets of data.
• In a Merkle tree, data blocks are grouped in pairs and the hash of each of these
blocks is stored in a parent node.
• The parent nodes are in turn grouped in pairs and their hashes stored one level
up the tree.
• This continues all the way up the tree until we reach the root node.
• if an adversary tampers with some data block at the bottom of the tree, that
will cause the hash pointer that’s one level up to not match, and even if he
continues to tamper with this block, the change will eventually propagate to the
top of the tree where he won’t be able to tamper with the hash pointer that
we’ve stored.
binary tree with hash pointers = “Merkle tree”
H( ) H( )
H( ) H( ) H( ) H( )
H( ) H( ) H( ) H( ) H( ) H( ) H( ) H( )