Bitcoin Forum
November 10, 2024, 08:06:55 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: protocol specs on wiki  (Read 1142 times)
brybot (OP)
Newbie
*
Offline Offline

Activity: 24
Merit: 0


View Profile
May 23, 2011, 03:16:10 AM
 #1

I was trying to use an online sha-256 calculator to verify blocks, but I have had no luck. I was just stringing together the "header" and applying the sha-256 algorithm twice. Then I noticed that I get different results to "hello" than is displayed on the wiki. It shows two rounds of the hash algorithm. I get a match for the first round, but not on the second. Any idea what is going on here? Thanks

https://en.bitcoin.it/wiki/Protocol_specification
theymos
Administrator
Legendary
*
Offline Offline

Activity: 5376
Merit: 13407


View Profile
May 23, 2011, 03:37:28 AM
 #2

Probably endianness problems.

Looking at this block:
http://blockexplorer.com/rawblock/000000000000479de7df494b25c838f0e102d696e08ad2bb74066d7a7ae69511
Its binary header is:
Code:
01000000 version
1d8f4ec0443e1f19f305e488c1085c95de7cc3fd25e0d2c5bb5d000000000000 previous block
9762547903d36881a86751f3f5049e23050113f779735ef82734ebf0b4450081 Merkle root
d8c8c84d timestamp
b3936a1a bits
334b035b nonce

Hashed once:
0cdb93c3412d2f30eb7d8dfd13d3142eaa8738c0de2337ac8a80c623715d9c07
Hashed twice:
1195e67a7a6d0674bbd28ae096d602e1f038c8254b49dfe79d47000000000000

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
brybot (OP)
Newbie
*
Offline Offline

Activity: 24
Merit: 0


View Profile
May 23, 2011, 03:46:35 AM
 #3

Any chance you could show me how you did those hashes? If it were an endian problem, I'd expect to get the wrong hash for "hello" on both cases, not just one.

For the block you posted, I didnt get the right hash in either case. Am I to remove the the " previous block" text and just leave the values when I do the computation?
theymos
Administrator
Legendary
*
Offline Offline

Activity: 5376
Merit: 13407


View Profile
May 23, 2011, 03:56:00 AM
 #4

Yes, the comments need to be removed. To make that example, I just used this online tool:
http://www.fileformat.info/tool/hash.htm

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1026



View Profile
May 23, 2011, 04:57:39 AM
 #5

Keep in mind that the most significant bits are on the right.  The first hash has a leading zero, which is actually a trailing zero.  It is important to the second round.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!