Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: betatest512 on September 20, 2012, 10:07:19 PM



Title: What have they done to the Nonce?
Post by: betatest512 on September 20, 2012, 10:07:19 PM
In https://en.bitcoin.it/wiki/Block_hashing_algorithm the algorithm show's that the nonce is "42a14695" and blockexplorer http://blockexplorer.com/block/00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d show's that the nonce is 2504433986

so what is done to the nonce to make it "42a14695"


Title: Re: What have they done to the Nonce?
Post by: DeathAndTaxes on September 20, 2012, 10:11:08 PM
They haven't "done" anything.  It is called hexadecimal.



Title: Re: What have they done to the Nonce?
Post by: betatest512 on September 20, 2012, 10:15:42 PM
They haven't "done" anything.  It is called hexadecimal.

2504433986 = 0x42a14695 = 1001100011011011110001 = "two trillion five hundred and four million, four hundred and thirty three thousand, nine hundred eighty six"

Not to be rude or anything but this thread combined with your other thread on blockheader indicates you lack even the most basics of programming.  Jumping right into something as complex as Bitcoin is unlikely going to pay any dividends if you don't have a foundation.

You may be better served by some self study of just basic programming concepts.  The language doesn't really matter but java is generally pretty easy for a beginner to pick up.

i used the converter here http://number.webmasters.sk/numerical.php and it tell's me that "42a14695" is equal to "1117865621"


Title: Re: What have they done to the Nonce?
Post by: Remember remember the 5th of November on September 20, 2012, 10:31:01 PM
They haven't "done" anything.  It is called hexadecimal.


You seriously can't count? It's 2 billion, 504 million...where on earth did you see 2 trillion and how do you expect it to fit in a 32-bit variable?


Title: Re: What have they done to the Nonce?
Post by: DeathAndTaxes on September 20, 2012, 10:35:53 PM
i used the converter here http://number.webmasters.sk/numerical.php and it tell's me that "42a14695" is equal to "1117865621"

Yeah I forgot Satoshi for some reason messed around with the endianess of each 16bit bit portion of the number.

12345678 -> 12 34 56 78 -> 78 56 34 12 -> 78563412

So
42a14695 -> 42 a1 46 95 -> 95 46 a1 42 -> 9546a142


Title: Re: What have they done to the Nonce?
Post by: Inaba on September 20, 2012, 10:39:12 PM
I wonder if the endian-ness of things might be a clue as to Satoshi's origins... maybe he was a big-iron programmer from back in the day or something?

Is there any definitive statements on why the endian-ness is swapped around so strangely from the start?


Title: Re: What have they done to the Nonce?
Post by: DeathAndTaxes on September 20, 2012, 10:46:11 PM
I wonder if the endian-ness of things might be a clue as to Satoshi's origins... maybe he was a big-iron programmer from back in the day or something?

Hmm.  Never thought about that angle before.  I mean for 99% of programmers all these endian conversions just make the code more confusion to understand however for some programmers it might be second nature.

Then again there are a lot of other "quirks" which are equally hard to explain.

Why use 32 bit nonce + extra nonce?  Why not just use a 64 bit nonce?

Why a double SHA-256?  If the fear was that SHA-256 would be partially compromised one would gain some security by using two algorithms but you don't really gain much performing the same algorithm twice.


Title: Re: What have they done to the Nonce?
Post by: dree12 on September 20, 2012, 10:47:37 PM
I wonder if the endian-ness of things might be a clue as to Satoshi's origins... maybe he was a big-iron programmer from back in the day or something?

Hmm.  Never thought about that angle before.  I mean for 99% of programmers all these endian conversions just make the code more confusion to understand however for some programmers it might be second nature.

Then again there are a lot of other "quirks" which are equally hard to explain.

Why use 32 bit nonce + extra nonce?  Why not just use a 64 bit nonce?

Why a double SHA-256?  If the fear was that SHA-256 would be partially compromised one would gain some security by using two algorithms but you don't really gain much performing the same algorithm twice.
The double SHA-256 prevents, I believe, hash extension attacks.


Title: Re: What have they done to the Nonce?
Post by: DeathAndTaxes on September 20, 2012, 10:50:21 PM
hash extension attacks are only possibly on arbitrary sized message.
Bitcoin block headers are fixed size.  A valid block header must be exactly 640 bits (no more, no less).


Title: Re: What have they done to the Nonce?
Post by: betatest512 on September 20, 2012, 10:50:45 PM
I wonder if the endian-ness of things might be a clue as to Satoshi's origins... maybe he was a big-iron programmer from back in the day or something?

Hmm.  Never thought about that angle before.  I mean for 99% of programmers all these endian conversions just make the code more confusion to understand however for some programmers it might be second nature.

Then again there are a lot of other "quirks" which are equally hard to explain.

Why use 32 bit nonce + extra nonce?  Why not just use a 64 bit nonce?

Why a double SHA-256?  If the fear was that SHA-256 would be partially compromised one would gain some security by using two algorithms but you don't really gain much performing the same algorithm twice.

please can anyone explain how the extra nonce portion work..


Title: Re: What have they done to the Nonce?
Post by: dree12 on September 20, 2012, 10:53:41 PM
hash extension attacks are only possibly on arbitrary sized message.
Bitcoin block headers are fixed size.  A valid block header must be exactly 640 bits (no more, no less).
I was going by this (http://crypto.stackexchange.com/questions/779/hashing-or-encrypting-twice-to-increase-security/884#884).


Title: Re: What have they done to the Nonce?
Post by: DeathAndTaxes on September 20, 2012, 10:55:28 PM
The generation (block reward) tx has a single input.  Normally the input of any tx is the unspent output of a prior tx however generated coins are produced from "thin air".  The input is a special type of tx called the coinbase.   The Bitcoin network doesn't use the value in here for anything (although it is now used by subordinate chain in merged mining).   Miners can modify this to produce more possible block headers for the same set of inputs.

So say for a given set of transactions, time, prior block, and difficulty you try all nonces 0 to 2^32-1.  What can you hash next if you don't want to wait for any of the other values to change.  You simply change the value in the coinbase field to another value.  That will produce a new merkle tree and thus a new markle root hash.  Technically it doesn't need to be incremented any new value is fine but for simplicity and record keeping (pools) it makes sense to just increment the value.   Pools do this to issue work to multiple workers that are otherwise the same.   solo miners will need to increment this if they have a hashing rate greater than ~4GH/s.


Title: Re: What have they done to the Nonce?
Post by: DeathAndTaxes on September 20, 2012, 10:58:51 PM
hash extension attacks are only possibly on arbitrary sized message.
Bitcoin block headers are fixed size.  A valid block header must be exactly 640 bits (no more, no less).
I was going by this (http://crypto.stackexchange.com/questions/779/hashing-or-encrypting-twice-to-increase-security/884#884).

Yeah the answer is technically correct in the general sense.  Double hash is a useful cryptographic feature to prevent extension attacks.  The author of that answer may not have been aware that Bitcoin has a fixed size header.


Title: Re: What have they done to the Nonce?
Post by: betatest512 on September 21, 2012, 12:20:28 AM
The generation (block reward) tx has a single input.  Normally the input of any tx is the unspent output of a prior tx however generated coins are produced from "thin air".  The input is a special type of tx called the coinbase.   The Bitcoin network doesn't use the value in here for anything (although it is now used by subordinate chain in merged mining).   Miners can modify this to produce more possible block headers for the same set of inputs.

So say for a given set of transactions, time, prior block, and difficulty you try all nonces 0 to 2^32-1.  What can you hash next if you don't want to wait for any of the other values to change.  You simply change the value in the coinbase field to another value.  That will produce a new merkle tree and thus a new markle root hash.  Technically it doesn't need to be incremented any new value is fine but for simplicity and record keeping (pools) it makes sense to just increment the value.   Pools do this to issue work to multiple workers that are otherwise the same.   solo miners will need to increment this if they have a hashing rate greater than ~4GH/s.

can some provide an example of how it is done..


Title: Re: What have they done to the Nonce?
Post by: Revalin on September 21, 2012, 04:10:39 AM
I wonder if the endian-ness of things might be a clue as to Satoshi's origins... maybe he was a big-iron programmer from back in the day or something?

Is there any definitive statements on why the endian-ness is swapped around so strangely from the start?


http://en.wikipedia.org/wiki/Endianness#Endianness_in_networking


Title: Re: What have they done to the Nonce?
Post by: betatest512 on September 21, 2012, 02:54:20 PM
can anyone tell me how to increment the coinbase after going though all the nonce..


Title: Re: What have they done to the Nonce?
Post by: DeathAndTaxes on September 21, 2012, 04:28:05 PM
can anyone tell me how to increment the coinbase after going though all the nonce..

Same way you increment anything.

coinbase = coinbase +1


Title: Re: What have they done to the Nonce?
Post by: DannyHamilton on September 24, 2012, 10:05:07 PM
Same way you increment anything.

coinbase = coinbase +1
coinbase++;