Skip to content

Instantly share code, notes, and snippets.

@sgkim126
Created June 13, 2018 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgkim126/66a077b914263768d479c842bae7e30b to your computer and use it in GitHub Desktop.
Save sgkim126/66a077b914263768d479c842bae7e30b to your computer and use it in GitHub Desktop.
pub fn skewed_merkle_root<Iter, In, Out, Xor>(base: Out, inputs: Iter) -> Out
where
Iter: IntoIterator<Item = In>,
In: AsRef<[u8]>,
Xor: AsRef<[u8]>,
Out: BitXor<Output = Xor> + Blake, {
inputs.into_iter().fold(base, |acc, input| {
let xor = acc ^ Blake::blake(input);
Blake::blake(&xor)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment