Bitcoin Forum
June 20, 2024, 07:47:24 AM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Protocol specification: double hash clarification  (Read 621 times)
The Networker (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
November 11, 2013, 01:32:09 AM
 #1

The protocol specification https://en.bitcoin.it/wiki/Protocol_specification states:

Example of double-SHA-256 encoding of string "hello":

2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 (first round of sha-256)
9595c9df90075148eb06860365df33584b75bff782a510c6cd4883a419833d50 (second round of sha-256)


I cannot work out the second round correctly. Is this formula supposed to be used to do that?

dhash(hello) = sha256(sha256(hello))

If so, the first round makes 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 correctly.

But the second round sha256(2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824) doesn't produce the value stated in the spec.

Could you please help wrap my head around that one?

Thanks.

bee7
Hero Member
*****
Offline Offline

Activity: 574
Merit: 523


View Profile
November 11, 2013, 01:34:50 AM
 #2

the second round should be taken on a binary representation of the first round result, not an ascii alphanumeric.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3430
Merit: 4669



View Profile
November 11, 2013, 01:37:18 AM
 #3

If so, the first round makes 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 correctly.

But the second round sha256(2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824) doesn't produce the value stated in the spec.

Could you please help wrap my head around that one?

99.99% of the time when someone comes asking this question (yes, it has been asked MANY times), it is because on the second round they are incorrectly hashing the string "2cf24db..." instead of the hex value 0x2cf24db...

You need to hash it as a numeric value and not as a string.
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!