Course: Blockchain & Bitcoin 101
Section: Functions, Hash Functions, Crypography
05 Reading Assignment
link: https://blockgeeks.com/guides/what-is-hashing/
title: What Is Hashing? [Step-by-Step Guide-Under Hood Of Blockchain]
Notes:
Hashing is taking an input of any length and creating an output of fixed length. In Cryptocurrencies, the input is transactions. In Bitcoin, the output is always a fixed length of 256 characters.
Bitcoin uses hashing function SHA-256 (Secure Hashing Algorithm 256).
Six Properties of a Cryptographic Hash Function:
1. Deterministic: No matter how many times you input the same data, you will get the same output.
2. Quick Computation: The hash function must be able to return a hash quickly. If too slow, then inefficient.
3. Pre-Image Resistance: It is infeasible to determine the input data based on the output hash. Exception: inputs a small fixed range of known values, such as the numbers 1 to 6 on a die. When working with larger datasets, the difficulty rises exponentially. It is only by brute force that the original input can be determined, and that can take several lifetimes.
4. A Small Change in Input Changes the Output: Even a minor change in the input, such as adding an extra exclamation mark, will generate a completely different hash output.
5. Collision Resistant: Each input will generate its own unique hash. Having two different inputs generate the same hash is known as a collision. It is infeasible that this would ever happen.
6. Puzzle Friendly: H(k|x) = Y k represents the particular value chosen. It must be from a particularly large distribution of points.
The vertical bar is concatenation.
Y is the output hash. Given output hash Y and value k, it will be infeasible to find input value x from a wide distribution to concatenate with k to equal Y.
“For every output “Y”, if k is chosen from a distribution with high min-entropy it is infeasible to find an input x such that H(k|x) = Y.”
“high min-entropy” “means that the distribution from which the value is chosen is hugely distributed so much so that us choosing a random value has a negligible probability.”
Homework Q & A:
1. What is the hashing algorithm called used in Bitcoin?
Bitcoin uses hashing function SHA-256 (Secure Hashing Algorithm 256).
By the way, Keccak-256: Produces a 256-bit hash and is currently used by ethereum.
2. Why is this hashing algorithm really hard (almost impossible) to brute-force?
Pre-image Resistance is a property of blockchain. It is infeasible to determine the output hash from the input hash, when the input comes from a large amount of data.
With a 128-bit input, on average, it would take
on average 2^127 = 1.7 X 10^38 attempts.
Even with the best computers and working 24/7/365, it would take many years to find a match.