0% found this document useful (0 votes)
24 views19 pages

Merkle Tree

Uploaded by

Ansh Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views19 pages

Merkle Tree

Uploaded by

Ansh Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Hash functions 1

• Hash functions are used to create fixed-length digests of arbitrarily long input strings. Hash functions
are keyless, and they provide a data integrity service. They are usually built using iterated and
dedicated hash function construction techniques.

• Various families of hash functions are available, such as MD, SHA1, SHA-2, SHA-3, RIPEMD, and
Whirlpool. Hash functions are commonly used for digital signatures and message authentication codes,
such as HMACs.

• Hash functions are also typically used to provide data integrity services. These can be used both as one-
way functions and to construct other cryptographic primitives, such as MACs and digital signatures.
Some applications use hash functions as a means for generating PRNGs. There are

• two practical and three security properties of hash functions that must be met depending on the level of
integrity required.
Hash functions 2

The practical properties:


1. Hash functions compress arbitrary messages into fixed-length
digests.
2. They are easy to compute.

The security properties of hash functions are:


3. Pre-image resistance also known as one-way property
h(x) = y
4. Second pre-image resistance also known as weak collision
resistance
given x and h(x), it is almost impossible to find any other message
3. Collision resistance also known as strong collision resistance
h(x1) != h(x2)
Hash Functions

• A hash function H accepts a variable-length block of data M as input and produces a fixed-size
hash value

• h = H(M)

• Principal object is data integrity

• Cryptographic hash function

• An algorithm for which it is computationally infeasible to find either:


(a) a data object that maps to a pre-specified hash result (the one-way property)

(b) two data objects that map to the same hash result (the collision-free property)
Hash Function Uses

Can be used to construct


Commonly used to Can be used for a pseudorandom
create a one-way intrusion and virus function (PRF) or a
password file detection pseudorandom number
generator (PRNG)
When a user enters a Store H(F) for each file
password, the hash of on a system and secure
that password is the hash values
compared to the stored
hash value for
verification One can later determine A common application
if a file has been for a hash-based PRF is
modified by for the generation of
recomputing H(F) symmetric keys
This approach to
password protection is
used by most operating An intruder would
systems need to change F
without changing H(F)
Attacks on Hash Functions

Brute-Force Attacks Cryptanalysis


• Does not depend on the specific algorithm, • An attack based on weaknesses in a particular
only depends on bit length
cryptographic algorithm
• In the case of a hash function, attack depends
• Seek to exploit some property of the
only on the bit length of the hash value
algorithm to perform some attack other than
• Method is to pick values at random and try an exhaustive search
each one until a collision occurs
7
applications of hash functions in blockchains
• Hash functions are used in cryptographic puzzles such as the Proof of Work (PoW) mechanism in
Bitcoin. Bitcoin's PoW makes use of the SHA-256 cryptographic hash function.

• The generation of addresses in blockchains. For example, in Ethereum, blockchain accounts are
represented as addresses. These addresses are obtained by hashing the public key with the Keccak-256
hash algorithm and then using the last 20 bytes of this hashed value.

• Message digests in digital signatures.

• The creation of Merkle trees to guarantee the integrity of transaction structure in the blockchain.
Specifically, this structure is used to quickly verify whether a transaction is included in a block or not.
Merkle trees

• Merkle trees are the core building


blocks of all blockchains; for
example, Bitcoin and Ethereum

• The concept of Merkle trees was


introduced by Ralph Merkle.

• Merkle trees enable the secure


and efficient verification of large
datasets

8
9

• A Merkle tree is a binary tree in which the inputs are first placed at the leaves (nodes with no
children), and then the values of pairs of child nodes are hashed together to produce a value for the
parent node (internal node), until a single hash value known as a Merkle root is achieved.

• This structure helps to quickly verify the integrity of the entire tree (entire dataset), but just by
verifying the Merkle root on top of the Merkle tree, because if any change occurs in any of the
hashes in the tree, the Merkle root will also change.

• This is the reason why the integrity of the system can be verified quickly by just looking at the
Merkle root.
10

• Another advantage of Merkle trees is that there is no requirement of storing large amounts of data,
only the hashes of the data, which are fixed-length digests of the large dataset.

• Due to this property, the storage and management of Merkle trees is easy and efficient as it takes a
very small amount of space for storage.

• Also, due to the fact that the tree is storage efficient, the relevant proofs for integrity are also
smaller in size and quick to transmit over the network, thus making them bandwidth efficient over
the network.
11

Patricia trees

• A trie, or a digital tree, is an ordered tree data structure used to store a dataset.

• The Practical Algorithm to Retrieve Information Coded in Alphanumeric (Patricia) tree, also
known as a Radix tree, is a compact representation of a trie in which a node that is the only child
of a parent is merged with its parent.

• A Merkle-Patricia tree, based on the definitions of Patricia and Merkle, is a tree that has a root
node that contains the hash value of the entire data structure.

• Merkle-Patricia trees are used in the Ethereum blockchain.


12

Distributed hash tables

• A hash table is a data structure that is used to map keys to values.

• Internally, a hash function is used to calculate an index into an array of buckets from which the
required value can be found.

• Buckets have records stored in them using a hash key and are organized into a particular order.

• Distributed Hash Table (DHT) as a data structure where data is spread across various nodes, and
nodes are equivalent to buckets in a peer-to-peer network.
• data is passed through a hash function, which then generates a compact key. This key is then
linked with the data (values) on the peer-to-peer network.

• When users on the network request the data (via the filename), the filename can be hashed again
to produce the same key, and any node on the network can then be requested to find the
corresponding data.

• A DHT provides decentralization, fault tolerance, and scalability.

13
14
SHA-3 Algorithm

• The SHA or SHA-3 (Secure Hash Algorithm 3) is known to be the latest member of
the SHA family of the secure hash algorithm stands it is published by the NIST on
the year 2015.
• the SHA-3 is different when we look at the internal structure of the SHA-3 because
the MD-5 structure is different from the SHA-1 and SHA-2.
• the SHA-3 is designed in order to provide a “random mapping” from a particular
string of binary data to a “message digest” that is fixed in size, the SHA-3 also
helps to achieve more security properties.
Difference Between SHA-256 and SHA-3

Feature SHA-256 SHA-3


Algorithm SHA-256 is a member of the SHA-256 family. SHA-3 is a different hash function.

Designed by the Keccak Team through an open


Design Process Developed by the National Security Agency (NSA)
competition organised by the NIST.

Security No known vulnerabilities as of current date. No known vulnerabilities as of current date.

Block size 512 bits Variable, with the most common being the 1600 bits.

Variable, with standard output size being 224, 256, 384


Output size 256 bits
or even 512 bits.

Performance Generally faster due to the simpler structure. Generally slower due to its more complex construction.

Resistance Susceptible to length extension attacks. Resistant to length extension attacks.

Padding scheme Uses the Merkle Damgard construction. Uses the sponge construction.

Message schedule Different from SHA-3. Based on the Keccak’s permutation.

15
16

Keccak-256
• Keccak-256, a cryptographic function, is part of Solidity (SHA-3 Family).

• This function computes the hash of an input to a fixed-length output, yielding


a singular 32-byte hash from any number of inputs.
• This cryptographic hash function can only be used in one direction and cannot
be reversed.
How Does Keccak-256 Work? 17

Give a string as input, such as “Namaste Duniya,” then send it through a hash
function using keccak256.
This would lead to:
Namaste Duniya -> keccak-256(hashing function) ->
8a0fe4fd16bb35fbecde2e774008fb7f92a8568a680f3fa93d0948bcfbf68dc3

The string “Namaste Duniya”, is not the same as “namaste duniya”. If we hash
“namaste duniya”, we will get a totally different result.
namaste duniya -> keccak-256(hashing function) ->
544ff8f09d34fdfbfa5a8dcb9d7d57deb6c862026cb8b655cfd7bf9c192e4d21

Even the slightest alteration or modification to the string has a significant


impact on the hash digest. No matter how much input is provided, the outcome
will always be the same.
What are the Use Cases of Keccak-256? 18

These are some use cases for it:


• Ethereum uses Keccak-256 in a consensus engine called Ethash.

• Small-sized cryptographic signature (by signing the hash instead of a larger input).

• To extract a deterministic, unique ID from a collection of data.


SHA-256 vs Keccak-256
S No. SHA-256 Keccak-256
SHA-256 is the implementation of Keccak256, a cryptographic
1. the SHA-2 standard with a 256 bits function, is part of Solidity (SHA-3
key. Family).
The SHA-256 is weaker than The keccak-256 is much stronger
2.
Keccak-256. compared to SHA-256.
Computes the SHA-256 hash of the Computes the Keccak-256 hash of
3.
input. the input.
sha256(bytes memory) returns keccak256(bytes memory) returns
4.
(bytes32). (bytes32).
The Bitcoin blockchain makes
extensive use of SHA-256,
including when identifying Ethereum uses Keccak-256 in a
5.
transaction hashes and when miners consensus engine called Ethash.
are performing proof-of-work
mining.
19

You might also like