SHA-256 hashing function outputs 32 byte hash always. How can I, using 32 byte seed and SHA-256 hashing function to create an 64 byte hash output ?
I've heard that they use technique like this (pseudocode):
init_hash = SHA256 (seed)
next_hash = SHA256 (init_hash + 1)
next_hash_vol2 = SHA256 (next_hash + 2)
next_hash_vol3 = SHA256 (next_hash_vol2 + 3)
...
next_hash_volA = SHA256 (next_hash_vol9 + A)
...
next_hash_vol10 = SHA256 (next_hash_volF + 10)
...
...
next_hash_vol64 = SHA256 (next_hash_vol63 + 40)
This sounds really nice! But problem is that SHA-256 ALWAYS generates 32 byte output, but I need 64 bytes :(
If you are starting with a 32 byte seed and a 32 byte hash, you will end up with 32 bytes of entropy no matter how much you expand it.
Given that, then you have many options such as the one @David Schwartz suggested. Here is a different option in pseudocode:
hash64(inputString)
hash1 = SHA256(inputString)
hash2 = SHA256(hash1)
return concatenate(hash1, hash2)
end hash64
Many other similar options are possible, such as:
hash64(inputString)
gnirtStupni = reverse(inputString)
hash1 = SHA256(inputString)
hash2 = SHA256(gnirtStupni)
return concatenate(hash1, hash2)
end hash64
Essentially, two separate hashes based on the same input, but tweaked so the hashes are not identical. Then concatenate the two hashes.