Padding efficent merkle root algo (#436)

* Add initial work on padding efficent merkle roots

* Improve merklize_padded

* Improve tree_hash crate -- fix bugs, docs

* Update codebase for tree_hash API change

* Remove dbg statements, fix import error

* Fix clippy lints, doc error

* Tidy tree hash comments

* Increase tree_hash max tree height

* Fix PR review comments

* Fix typos

* Fix cache access off-by-one in tree hash

* Set max tree depth to 48 (from 64)
This commit is contained in:
Paul Hauner
2019-07-16 14:40:56 +10:00
committed by GitHub
parent af499c0b8c
commit 88c6d15c32
7 changed files with 403 additions and 12 deletions

View File

@@ -1,5 +1,17 @@
#[macro_use]
extern crate lazy_static;
pub mod impls;
pub mod merkleize;
mod merkleize_padded;
mod merkleize_standard;
pub use merkleize_padded::merkleize_padded;
pub use merkleize_standard::merkleize_standard;
/// Alias to `merkleize_padded(&bytes, 0)`
pub fn merkle_root(bytes: &[u8]) -> Vec<u8> {
merkleize_padded(&bytes, 0)
}
pub const BYTES_PER_CHUNK: usize = 32;
pub const HASHSIZE: usize = 32;
@@ -44,7 +56,7 @@ macro_rules! tree_hash_ssz_encoding_as_vector {
}
fn tree_hash_root(&self) -> Vec<u8> {
tree_hash::merkleize::merkle_root(&ssz::ssz_encode(self))
tree_hash::merkle_root(&ssz::ssz_encode(self))
}
}
};