Computing preimages (nonces) that satisfy a hash output with known property (minimum number of prefixed zeroes) is the foundation of bit-coin mining and block-chain validation. For this purpose, all available hardware, whether general purpose PCs and servers or custom ASICs that specifically target bitcoin mining, is rated for performance in terms of "Hashes/sec, Mega Hashes/Sec, or Giga Hashes/Sec".
Without specifying the length of the data that is hashed, I find this rating of HW in terms of 'Hashes/Sec' to be vague at best. All hashing algorithms input messages of arbitrary length and computed an fixed length message digest. So, a processing power that performs a "million hashes per second" over input blocks of length 100 bytes is not quite the same of another HW that can perform 'million hashes per second' with input blocks where the block length is 4 kilo bytes.
What does it mean to say 'my HW can perform x hashes/sec'? Does each 'hash' refer to the block size of SHA256 algorithm, which is 512 bits?
Or, does a hash refer to hashing a block chain, whose length is highly variable subject to the transactions that define a block-chain?
Is there is a well known benchmark program that can measure the 'hashes/sec' supported by any piece of HW?
Without clarifying the above details & publishing a benchmark that everyone can look up to, vendors' claims of "Hashes/Sec" seems like a marketing ploy to me.
[Added Later] I have a further question on the details of how a valid nonce is searched. As I understand it, the search is determined by 3 parameters
(a) The block header (b) target string (c) nonce
A representative pseudo code that searches for the nonce can be written as:
while (hash_256(hash_256(block_header, nonce) >= target_string) do
nonce = nonce + 1
I have modeled the above pseudo code from this blog of Ken Schriff. It is not clear how this code models the 'difficulty' parameter. Above loop (as well as the one found in the blog) iterates through all nonce values from 0 through (2^32-1). Or, exactly 4 billion iterations of the hash function. Even a PC with a 12 year old Pentium 4 CPU that performs at 1 MHashes/Sec (cf. Mining Hardware Comparison) can crack this in 4000 seconds, or in about an hour. Custom ASICs with GHashes/sec performance will crack it in a second.
What is the correction needed to reflect the 'difficulty' parameter in this pseudocode? Does the size of the nonce have to be related to the difficulty ?