## Bitcoin block hashing algorithm. nonce

0

1

Referencing the Bitcoin wiki, what is the auhoritative source for providing a hash of the previous block? Or do miners keep listening to latest blocks?

How is hash of the Merkle root generated?

Can a miner generate a block with no transactions? That means generating block by keeping hash Merkle root as all 0s.

One more question: nonce size is only four bytes (32 bits). Given version, previousBlockHash, hashMerkleRoot, bits are constant, would it not be very easy to iterate through all possible nonces?

2^32 = 4 G = 4 G hash machine can finish this task in one second.

Question was closed 2016-03-31T16:17:52.907

1

What is the auhoritative source for providing hash of previous block? or do miners keep listening to latest blocks?

There's no authoritative source, that's the whole point of Bitcoin. Miners keep listening for latest blocks, yes. They decide for themselves which block to accept. And since all miners (and clients) are programmed to accept only valid blocks (where its header hash is equal or below than the current target) they soon reach consensus upon which blocks are valid.

One more question: nonce size is only 4 bytes(32 bits). Given version, previousBlockHash, hashMerkleRoot, bits are constant, would not it be very easy to iterate through all possible nonces? 2^32 = 4 gigs = 4 gig hash machine can finish this task in one second.

More often than not, just that 4 byte nonce is not enough randomness to find a block. Miners constantly add new transactions - therefore the hashMerkleRoot isn't really constant.

Also I think there's an extranonce field which adds more space.

You cannot create a block with no transactions at all. Every block needs a coinbase transaction which claims fees and subsidy for the miner. Because of that, the merkle root can never be emoty. Also, it is inside this transaction that the extraNonce is located, so it affects the block header through the merkle root. – Pieter Wuille – 2013-11-17T11:06:24.760

@PieterWuille thanks I removed that part of my answer. Perhaps you can answer more specifically on the issue of the transactions as I also wasn't aware of it. – Luca Matteis – 2013-11-17T12:01:14.623

@PeterWuille Could you please point me to any documentation about extraNonce and generating MerkleRoot. – Htaras – 2013-11-26T16:01:20.763

@Htaras the extranonce is documented here: https://en.bitcoin.it/wiki/Transactions#Generation

Miners also tend to play with the block time to add extra randomness, especially in pool mining. This is one of the reasons block times are a little all over the place.

– Matthieu – 2014-06-27T02:06:45.247