<p><strong>Bitcoin does work with full or complete binary trees.</strong> For complete trees, leaves without a partner are simply hashed with themselves instead. The attack that <a href="https://bitcoin.stackexchange.com/questions/50762/why-must-be-the-merkle-tree-a-full-binary#comment58878_50762">CodesInChaos</a> links was solved by checking that every transaction is unique which is required for valid blocks anyway.</p>
<p><a href="https://i.sstatic.net/ziVM0.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ziVM0.png" alt="enter image description here" /></a></p>
<p><sup>Image from Bitcoin Developer Guide</sup></p>

CC BY-SA 3.0
2017-01-13T09:22:09.837Z
2017-01-13T09:48:43.900Z
2020-06-16T11:10:03.350Z
Murch
<p>Bitcoin uses a Merkle tree with hash functions. I mean I do not get it why there must be a full binary tree? A complete could also be possible?</p>

CC BY-SA 3.0
2017-01-12T19:40:19.510Z
Bitcoin [messed up](https://crypto.stackexchange.com/questions/2106/what-is-the-purpose-of-using-different-hash-functions-for-the-leaves-and-interna) their merkle trees . I guess requiring a power-of-two as leaves is their workaround for this flaw.
CodesInChaos
CC BY-SA 3.0
2017-01-12T20:15:15.127Z
Related: [\[Full Disclosure\] CVE-2012-2459 (block merkle calculation exploit)](https://bitcointalk.org/index.php?topic=102395.0) on bitcointalk.
CodesInChaos
CC BY-SA 3.0
2017-01-13T09:14:44.263Z
@CodesInChaos: The second link is interesting, but I don't see what the first link has to do with the question?
Murch
CC BY-SA 3.0
2017-01-13T09:19:48.847Z
@Murch It's about how you to design a proper merkle tree that doesn't suffer from ambiguities between different length inputs. Such a merkle tree won't need silly restrictions like a power-of-two number of leaves. But bitcoin didn't use leaf-tagging (or one of the alternative safe constructions) which led to problems.
CodesInChaos
CC BY-SA 3.0
2017-01-13T09:27:48.497Z
@CodesInChaos: Bitcoin doesn't require a full binary tree, it only requires a complete binary tree. I thought you were saying that you didn't understand why a binary tree was chosen over more children.
Murch
<merkle-tree>
Why must be the Merkle Tree a full binary?
Peter
# Why must be the Merkle Tree a full binary?

(Asked by: username_0 on 2017-01-12)

Bitcoin uses a Merkle tree with hash functions. I mean I do not get it why there must be a full binary tree? A complete could also be possible?

**Tags:** merkle-tree

> **Comments:**
> **username_1**: Bitcoin [messed up](https://crypto.stackexchange.com/questions/2106/what-is-the-purpose-of-using-different-hash-functions-for-the-leaves-and-interna) their merkle trees . I guess requiring a power-of-two as leaves is their workaround for this flaw.  
> **username_1**: Related: [\[Full Disclosure\] CVE-2012-2459 (block merkle calculation exploit)](https://bitcointalk.org/index.php?topic=102395.0) on bitcointalk.  
> **username_2**: @username_1: The second link is interesting, but I don't see what the first link has to do with the question?  
> **username_1**: @username_2 It's about how you to design a proper merkle tree that doesn't suffer from ambiguities between different length inputs. Such a merkle tree won't need silly restrictions like a power-of-two number of leaves. But bitcoin didn't use leaf-tagging (or one of the alternative safe constructions) which led to problems.  
> **username_2**: @username_1: Bitcoin doesn't require a full binary tree, it only requires a complete binary tree. I thought you were saying that you didn't understand why a binary tree was chosen over more children.  

---

## 1 answers

### Answer by username_2 on 2017-01-13. Score: 0 | Accepted answer

**Bitcoin does work with full or complete binary trees.** For complete trees, leaves without a partner are simply hashed with themselves instead. The attack that [username_1](https://bitcoin.stackexchange.com/questions/50762/why-must-be-the-merkle-tree-a-full-binary#comment58878_50762) links was solved by checking that every transaction is unique which is required for valid blocks anyway.

[![enter image description here](https://i.sstatic.net/ziVM0.png)](https://i.sstatic.net/ziVM0.png)

Image from Bitcoin Developer Guide


---

