
Hash functions: small computer programs which transform any kind of data into a string
of fixed length, regardless the size of input data (many-to-one function). The number of
possible inputs is larger than the number of possible outputs.
Cryptographic hash functions: 3 properties:
1) Preimage resistance: it is computationally infeasible to calculate any preimage x
of a given y (H(x)=y)
2) Second presage resistance: it is computationally infeasible to find a different input
string x′ such that H(x) = H(x′)
3) Collision resistance: it is computationally infeasible to find a pair of distinct input
strings x, x′ such that H(x) = H(x′)
+ Deterministic: identical hash values for identical input data;
+ Pseudorandom: the hash value returned by the hash function changes (pseudo)
randomly when the input data are changed.
Requirement to be a “good” hash function: the relation between the input bit string x and
the output bit string y should be complicated to prevent easy recovery of x from y.
SHA-256 (Secure Hash Algorithm): 256 bits in the output, 264-1 bits in the input. No formal
proof that it is a cryptographic hash function, but it has no known weaknesses.
What if we have to provide one unique hash value for several independent data? You can’t
use a hash function directly: the idea is to build structures made by hash functions.
Different patterns:
Independent hashing;
Repeated hashing: apply the hash function to the output of the step before;
Combined hashing: combine all the single data into one and then apply the hash
function, since it is computationally intensive use this method with small data;
Sequential hashing: incremental update of a hash value as new data arrives
(combined + repeated), useful if we want a single updated hash value;
Hierarchical hashing: when we want to have a single hash that represents a given
structure (independent + combined), more efficient since the chunks are hash values.