Separate the leafs hash domain from the internal nodes' one (#22)

* Separate the leafs hash domain from the internal nodes' one.

This change prevents an internal node from having the same hash as a leaf,
and thus from potentially ending up with two different trees with the same root hash.

Close #20

* Align with the CT spec, and allows building a tree from an empty dataset.

Fixes #20. Prepares #24.
This commit is contained in:
Romain Ruetschi
2016-12-19 16:14:41 +01:00
committed by Frederic Jacobs
parent bebbcde461
commit bce59c9f39
7 changed files with 114 additions and 67 deletions

View File

@ -16,7 +16,7 @@ static digest: &'static Algorithm = &SHA512;
fn test_protobuf_inverse() {
let values = (1..10).map(|x| vec![x]).collect::<Vec<_>>();
let tree = MerkleTree::from_vec(digest, values.clone()).unwrap();
let tree = MerkleTree::from_vec(digest, values.clone());
for value in values {
let proof = tree.gen_proof(value).unwrap();