A stream that generates a merkle tree based on the incoming data. Adapted from mafintosh/merkle-tree-stream.
Signatures & integrity checks are part of what makes Dat a great protocol.
Each chunk that passes through the system is hashed and made part of a tree
of hashes. We end up creating hashes of hashes thanks to
flat-tree
, which in the end allows us to
validate our complete data set.
This module is only needed to create new Dat archives, but not to read them.
```rust extern crate merkletreestream; extern crate rust_sodium;
use merkletreestream::{HashMethods, DefaultNode, MerkleTreeStream, Node, PartialNode}; use rust_sodium::crypto::hash::sha256; use std::rc::Rc;
struct S;
impl HashMethods
fn parent(&self, a: &DefaultNode, b: &DefaultNode) -> Vec
fn node(&self, partial: &PartialNode, hash: Vec
fn main() {
let roots = Vec::new();
let mut mts = MerkleTreeStream::new(S, roots);
let mut nodes: Vec
sh
$ cargo add merkle-tree-stream
MIT OR Apache-2.0