The hashing algorithm used in bitcoin.
There is a common, but false, belief that Adam Back is the original source of the hash puzzle used in bitcoin. This belief derives from the paper’s references to ‘Hashcash’ [2]. Instead, we find the base algorithm defined on page 4 of ‘DOS-resistant authentication with client puzzles’ [12]. The authors did not release code, and a modified protocol and code were used in the bitcoin core release of 2009.
The original implementation of Hashcash is available via the
Internet Archive project here and the
original code here. The false belief that Hashcash was ‘used as the mining function in bitcoin’ can be quickly dispelled by comparing the codes used in each.
This exercise will demonstrate that the variables and functions written for bitcoin, such as
nTotalLower and
nTargetValue, differ radically from the functions used in Hashcash.
It was implemented simply in bitcoin, where comparisons, such as the following, were used instead of schemes that are more difficult to implement:
if(hash <= hashTarget)
{pblock->nNonce = tmp.block.nNonce;
assert(hash == pblock->GetHash());
and
// Check proof of work matches claimed amount
if(CBigNum().SetCompact(nBits) > bnProofOfWorkLimit)
return error(“CheckBlock() : nBits below minimum work”);
if(GetHash() > CBigNum().SetCompact(nBits).getuint256())
return error(“CheckBlock() : hash doesn’t match nBits”);
Other methods, including seeking matched hash collisions, such as are found in Hashcash, could have been incorporated; but this would have involved additional changes that would have made the initial implementation of bitcoin more difficult.
The originally incorporated code derives from implementations developed by Wei Dai and Steve Reid.