Bitcoin Forum
September 27, 2018, 10:55:59 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Why do we need double hashing in a Merkle tree?  (Read 755 times)
fevirfevir
Newbie
*
Offline Offline

Activity: 17
Merit: 0


View Profile
August 13, 2015, 11:32:33 AM
 #1

Hi,

In Bitcoin, the Merkle tree created from all transactions contains nodes that represent a double hash of each transaction: N = SHA256(SHA256(tx0)

What's the point of doing so? Can't we just do a N =  SHA256(tx0)?

Thanks.
1538088959
Hero Member
*
Offline Offline

Posts: 1538088959

View Profile Personal Message (Offline)

Ignore
1538088959
Reply with quote  #2

1538088959
Report to moderator
1538088959
Hero Member
*
Offline Offline

Posts: 1538088959

View Profile Personal Message (Offline)

Ignore
1538088959
Reply with quote  #2

1538088959
Report to moderator
Make a difference with your Ether.
Donate Ether for the greater good.
SPRING.WETRUST.IO
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1538088959
Hero Member
*
Offline Offline

Posts: 1538088959

View Profile Personal Message (Offline)

Ignore
1538088959
Reply with quote  #2

1538088959
Report to moderator
1538088959
Hero Member
*
Offline Offline

Posts: 1538088959

View Profile Personal Message (Offline)

Ignore
1538088959
Reply with quote  #2

1538088959
Report to moderator
Kazimir
Legendary
*
Offline Offline

Activity: 1176
Merit: 1000



View Profile
August 13, 2015, 11:36:09 AM
 #2

Any hash would do, and Sha256(Sha256(x)) can also be considered "just a hash".

I assume Satoshi chose this double Sha256 (also called "Sha256d") just in case a future possible vulnerability is discovered with Sha256. It would give us more time to switch to something else (like Sha3).

In theory, there's no difference between theory and practice. In practice, there is.
Insert coin(s): 1KazimirL9MNcnFnoosGrEkmMsbYLxPPob
fevirfevir
Newbie
*
Offline Offline

Activity: 17
Merit: 0


View Profile
August 13, 2015, 11:49:02 AM
 #3

Thanks for your answer. I was thinking along the same lines, that it's somewhat of a security measure.

But if there would be a flaw in SHA256, wouldn't that impact both SHA256d hashed transactions, pretty much the same as SHA256 hashed transactions? It would of course depend on the flaw found, but reasoning that Satoshi choose this as a security measure, we're talking delay here.

Just wondering if the choice for SHA256d is a functional decision, like speed improvement.
Kazimir
Legendary
*
Offline Offline

Activity: 1176
Merit: 1000



View Profile
August 13, 2015, 12:41:50 PM
 #4

Not every kind of Sha256 vulnerability would also apply on Sha256d. So I guess it's for security.

Still, I would rather have seen something like Sha256(x+Sha256(x)) instead of just Sha256(Sha256(x)). But either way, it's fine.

In theory, there's no difference between theory and practice. In practice, there is.
Insert coin(s): 1KazimirL9MNcnFnoosGrEkmMsbYLxPPob
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!