Homework on Hash Functions - Answers
-
Hash functions are one-way functions that are mathematical calculations that produce a unique output for every unique input and this calculated output is irreversible, hence can not be used to determine the input. They are used primarily to map data of an arbitrary length to data of a fixed length.
-
https://en.m.wikipedia.org/wiki/Hash_function
https://en.m.wikipedia.org/wiki/Cryptographic_hash_function
https://en.m.wikipedia.org/wiki/Secure_Hash_Algorithms
https://en.bitcoinwiki.org/wiki/Hash
Hash function Review
Hash functions are primarily used to generate fixed-length output data that acts as a shortened reference to the original data. This is useful when the original data is too cumbersome to use in its entirety.
One practical use is a data structure called a hash table where the data is stored associatively. Searching linearly for a personās name in a list becomes cumbersome as the length of the list increases, but the hashed value can be used to store a reference to the original data and retrieve constant time (barring collisions). Another use is in cryptography, the science of encoding and safeguarding data. It is easy to generate hash values from input data and easy to verify that the data matches the hash, but hard to āfakeā a hash value to hide malicious data. This is the principle behind the PGP algorithm for data validation.
To be considered effective a hash function has to have the following properties:
⢠Computational efficiency - it shouldnāt take a long time to compute a hash from a given input.
⢠Collision resistance - it should be hard to find distinct inputs that would result in the same hash after the application of the hash function.
⢠Ability to hide information - it should be hard to derive anything useful about the input from the hash whether it be the whole input data or as simple info about it as to whether it is an odd or an even number.
⢠Random-looking hash - the hash should look like it was a result of several random events, like flipping a coin. There shouldnāt be an apparent particular transformation protocol.
Bitcoin Hash function
Bitcoin uses the SHA-256 hash algorithm to generate verifiably ārandomā numbers in a way that requires a predictable amount of CPU effort. Generating an SHA-256 hash with a value less than the current target solves a block and wins you some coins.
https://en.bitcoin.it/wiki/Block_hashing_algorithm
Many people fear that quantum computers will eventually break these hash functions. Bitcoin uses SHA256 for the data encryption on the chain and EDCSA for the digital signature. Quantum computing will likely break the digital signature before ever being able to challenge the strength of SHA256 as the latter is magnitudes of orders more difficult to break because of Double Hashing. This weakness in future security vulnerabilities means that the best practice is to only use a digital address once.
Transactions always contain the SHA256 of the transaction and the digital signature of the user. If this digital signature is connected to an address that was only used once to move assets out, then it would be safe when quantum computing reaches this capacity as no assets would be prone to exposure.
- A hash function is considered collision-resistant if 2 different random inputs (e.g. x and y) can produce the same hash result (i.e. H(x) = H(y)) even though they are completely different (i.e. x is not equal to y ). This is easily accomplished when the length of the hash function output is the same length or shorter than the un-hashed inputs. However, logically inputs longer than the hashed outputs necessarily will have these collisions. This is what is known as the pigeonhole principle. In situations where the hash function have proof that they are at least as difficult to brute force (through calculating) as extremely hard mathematical problems e.g. integer factorization, these cryptographic hash functions are considered provably secure, hence collision-resistant.