1
I understand the role that the nonce plays in the block header for calculating a hash for a valid proof of work.
But what I ask is: Do we consider the nonce in the prevBlockHash calculation of the previous block because, well, it's in the block header already (for the proof-of-work calculation), and it would be silly to write a calcPrevBlockHash function that calculates the previous block's header by ignoring the nonce?
Or is there a specific security property or assurance that we get when including the nonce in the prevBlockHash calculation of the subsequent block?
For instance, you could argue that we hash the timestamp because we want to capture the time that the block was generated. See answer here: Why the timestamp component of the block header? I guess you can argue the same for the nonce field.
But I claim that we could still have the nonce in the block header, and not hash it during the prevBlockHash calculation of the subsequent block, and things would still work. You would still be (a) able to validate this block, and (b) unable to mess around with the transactions in the block, because that would modify the hashMerkeRoot field, and thus render the block invalid.
2
Possible duplicate of Why change the nonce instead of just rehashing?
– Jestin – 2016-07-26T19:39:21.200It is not. I understand why the nonce needs to be changed, I question why it needs to be included in the block header, and thus be hashed. – Kostas – 2016-07-27T02:09:26.193
1You still have to include the nonce in the block hash somehow, otherwise what do you change in order to find a good proof-of-work? And in that case, anyone who tries to validate the block will need to be given the nonce, or have to do a ton of extra work to reconstruct it. If you don't put it in the block, you'd have to distribute it some other way. – Nate Eldredge – 2016-07-27T02:24:18.820
@NateEldredge: 1. "You still have to include the nonce in the block hash somehow, otherwise what do you change in order to find a good proof-of-work?" The nonce of course. Why do you have to include it in the block hash though? 2. "If you don't put it in the block, you'd have to distribute it some other way." But I never suggested not including the nonce in the block. My question has to do with why we're including it in the block header. Is there a reason it needs to be hashed, or is it a "just because" thing. – Kostas – 2016-07-27T14:39:58.147
@Kostas: So, you have a block header. You compute the hash of it. The result doesn't have enough leading zeros to be a valid proof-of-work. Now what? You can do whatever you want to the nonce, but it's irrelevant: if it's not in the header, then the data you're hashing doesn't change, and when you hash it again you're just going to get the same not-good-enough hash value. The hash function is a function, after all; giving it the same input always gives the same output. – Nate Eldredge – 2016-07-27T15:25:46.173
@NateEldredge: We talk about different hashing processes. There's the process where you try to come up with a block header hash that's lower than the target. It makes perfect sense to consider the nonce here. (In fact, the nonce is a key element in this hash calculation.) This is what you refer to, and we agree. However, I refer to the other hashing process that occurs when I want to create block n+1, and wish to refer to block n by its
prevBlockHash. – Kostas – 2016-07-27T18:10:09.110What I ask then is: Is there some specific property that mandates why we need to include the nonce in this
prevBlockHashhash? Or is it something along the lines of: "Well, it's part of the header because we need it there to calculate the proof-of-work. We actually don't need to include it when doing theprevBlockHashthing (we don't get any extra warranties by doing so), but it would be overkill to code acalcPrevBlockHashfunction that ignores thenoncefield, so we just include it as well in ourprevBlockHashcalcuation." – Kostas – 2016-07-27T18:11:20.210@Kostas: Ok, now I think I understand your question. As it stands, the two processes are one and the same! I suppose in principle you could make them separate, and exclude the nonce from the latter, but it gains nothing and adds unnecessary complexity. – Nate Eldredge – 2016-07-27T18:28:10.203
@NateEldredge: Right.
hashBlockHeader()is what you use for the proof-of-work calculation and theprevBlockHashcalculation now. (Note: made-up function names.) All I'm asking is: If you were to calculateprevBlockHashusing acalcPrevBlockHash()function that ignores the nonce field, would that break anything? Would you lose any security properties that would currently have? – Kostas – 2016-07-27T18:31:43.753Let us continue this discussion in chat.
– Kostas – 2016-07-27T18:52:37.780