Author

Topic: Two questions about hashing the block header. (Read 973 times)

hero member
Activity: 765
Merit: 503
hero member
Activity: 836
Merit: 1030
bits of proof
Below explanation using Matematica. I am sure you figure what the operations mean even if you do not use it regularly.

Code:
In[15]:= minTarget = 
 FromDigits["ffff", 16]*2^(8*FromDigits["1d", 16] - 3)

Out[15]= 56538243354614949726192090679290607878297928311398285361572003125835857920

In[16]:= target =
 FromDigits["44b9f2", 16]*2^(8*FromDigits["1a", 16] - 3)

Out[16]= 231607337543830564817752779584294829436484108612716418234853202329600

In[19]:= minTarget/target

Out[19]= 36649828352/150135

In[20]:= N[36649828352/150135]

Out[20]= 244112.
member
Activity: 61
Merit: 12
I see, thank you.

So how does 244 112.487774 = 440711666?

http://blockexplorer.com/b/125552
legendary
Activity: 1628
Merit: 1012
Okay, so f2b9441a is the Little-endian of 440711666.

Where does 440711666 come from?

https://en.bitcoin.it/wiki/Block_hashing_algorithm (PHP script at the bottom)

Current target difficulty.
member
Activity: 61
Merit: 12
Okay, so f2b9441a is the Little-endian of 440711666.

Where does 440711666 come from?

https://en.bitcoin.it/wiki/Block_hashing_algorithm (PHP script at the bottom)
member
Activity: 61
Merit: 12
By "hashing the block header" are you referring to hashing the contents of the merkleblock.cpp file?

I do not understand the structure of the code well enough to answer your question accurately. Although I'd say that "hashing the contents of the merkleblock.cpp file" is an inaccurate evaluation of what I'm looking to achieve.

To try and clarify, what I believe I am now looking for are the file(s) that performs this:

"When mining bitcoin, the hashcash algorithm repeatedly hashes the block header while incrementing the counter & extraNonce fields."
 - https://en.bitcoin.it/wiki/Block_hashing_algorithm

Note that finding the block header field names (container names?) in the source code is still my primary goal.
legendary
Activity: 1628
Merit: 1012
1. What do you mean "used in the protocol"? Do you mean what is the name of the containers in the source code?

Yes. Sorry my terminology is poor.

I was able to find (I think) that hashMerkleRoot is a block header field name from this file: https://github.com/bitcoin/bitcoin/blob/master/src/merkleblock.cpp

However I must confess that I am noob to the source. Can you point me in the direction of where I might find the code for the hashing the block header (and thus the field/container names)?

By "hashing the block header" are you referring to hashing the contents of the merkleblock.cpp file?
member
Activity: 61
Merit: 12
1. What do you mean "used in the protocol"? Do you mean what is the name of the containers in the source code?

Yes. Sorry my terminology is poor.

I was able to find (I think) that hashMerkleRoot is a block header field name from this file: https://github.com/bitcoin/bitcoin/blob/master/src/merkleblock.cpp

However I must confess that I am noob to the source. Can you point me in the direction of where I might find the code for the hashing the block header (and thus the field/container names)?
sr. member
Activity: 475
Merit: 252
1. Are these the exact field names used in the protocol, or are these just descriptive names for the purposes of the article?

2. A question about the Bits field.

1. What do you mean "used in the protocol"? Do you mean what is the name of the containers in the source code?

2. https://en.bitcoin.it/wiki/Difficulty#How_is_difficulty_stored_in_blocks.3F

Once you figure out how to calculate the msb with the remaining 3 bytes at this link, you'll figure it out.
legendary
Activity: 1628
Merit: 1012
Hi there,

I'm looking at the block header information on this page: https://en.bitcoin.it/wiki/Block_hashing_algorithm

It covers the following block header fields:

Version
hashPrevBlock
hashMerkleRoot
Time
Bits
Nonce


1. Are these the exact field names used in the protocol, or are these just descriptive names for the purposes of the article?

2. A question about the Bits field.

When hashing the block header in the example PHP code at the bottom of the bitcoin wiki page, the value used for Bits is 440711666.

However, when looking at the block information (http://blockexplorer.com/b/125552), the value they have displayed for Bits is Difficulty?: 244 112.487774 ("Bits"?: 1a44b9f2)

How do I convert the difficulty/bits information displayed on blockexplorer to 440711666?

Take a look at the source code - the first question answers itself.

https://github.com/bitcoin/bitcoin
member
Activity: 61
Merit: 12
Hi there,

I'm looking at the block header information on this page: https://en.bitcoin.it/wiki/Block_hashing_algorithm

It covers the following block header fields:

Version
hashPrevBlock
hashMerkleRoot
Time
Bits
Nonce


1. Are these the exact field names used in the protocol, or are these just descriptive names for the purposes of the article?

2. A question about the Bits field.

When hashing the block header in the example PHP code at the bottom of the bitcoin wiki page, the value used for Bits is 440711666.

However, when looking at the block information (http://blockexplorer.com/b/125552), the value they have displayed for Bits is Difficulty?: 244 112.487774 ("Bits"?: 1a44b9f2)

How do I convert the difficulty/bits information displayed on blockexplorer to 440711666?
Jump to: