Weave documentation
Rust referenceweave-strand

weave-strand · merkle_tree

Source declarations, signatures and documentation for merkle_tree.

Source: sigil/weave/models/strand/src/merkle_tree.rs. SHA-256: e07689743692335d133001f4c2cfff5667b50148743e9cf1729ff86755ac25fc.

This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.

merkle_tree::Node

A node in the merkle tree

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Node {
/// The flat-tree index of this node

pub index: u64,
/// The size of data this node represents

pub size: u64,
/// The hash of this node

pub hash: [u8; 32]
}

Source line: 9.

merkle_tree::Proof

A proof that a specific block is part of the merkle tree

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Proof {
/// The index of the block being proven

pub index: u64,
/// The nodes needed to verify the proof

pub nodes: Vec<Node>,
/// The signature over the tree root (optional)

pub signature: Option<Vec<u8>>
}

Source line: 22.

merkle_tree::MerkleTree

Merkle tree for efficient cryptographic verification

#[derive(Debug, Clone)]
pub struct MerkleTree {

}

Source line: 35.

merkle_tree::MerkleTree::new

Create a new empty merkle tree

pub fn new() -> Self;

Source line: 45.

merkle_tree::MerkleTree::add

Add a new leaf node to the tree

pub fn add(&mut self, node: Node);

Source line: 53.

merkle_tree::MerkleTree::root_hash

Get the current root hash

pub fn root_hash(&self) -> [u8; 32];

Source line: 68.

merkle_tree::MerkleTree::roots

Get the current roots

pub fn roots(&self) -> Vec<Node>;

Source line: 83.

merkle_tree::MerkleTree::peaks

Get the peaks (roots) of the tree

pub fn peaks(&self) -> Vec<Node>;

Source line: 88.

merkle_tree::MerkleTree::proof

Create a proof for a specific block

pub fn proof(&self, index: u64) -> Option<Proof>;

Source line: 93.

merkle_tree::MerkleTree::verify

Verify a proof against a node

pub fn verify(&self, proof: &Proof, node: &Node) -> Result<bool, String>;

Source line: 126.

merkle_tree::MerkleTree::verify_proof

Verify a proof with data

pub fn verify_proof(&self, proof: &Proof, data: &[u8]) -> Result<bool, String>;

Source line: 131.

merkle_tree::flat_tree

Flat-tree indexing scheme

pub mod flat_tree;

Source line: 237.

merkle_tree::flat_tree::depth

Get the depth of a node

pub fn depth(index: u64) -> u64;

Source line: 239.

merkle_tree::flat_tree::parent

Get the parent index

pub fn parent(index: u64) -> u64;

Source line: 245.

merkle_tree::flat_tree::sibling

Get the sibling index

pub fn sibling(index: u64) -> u64;

Source line: 256.

On this page