README

wch6766/MoonSecureCodec/lib/merkle does not have a README file

#
MerkleProof

pub(all) struct MerkleProof {
leaf_hash : Bytes
steps : Array[MerkleStep]
}

A complete Merkle inclusion proof for a leaf.

#
MerkleStep

pub(all) struct MerkleStep {
is_left : Bool
sibling_hash : Bytes
}

A single step along a Merkle verification path.

#
MerkleTree

pub(all) struct MerkleTree {
leaves : Array[Bytes]
levels : Array[Array[Bytes]]
root_hash : Bytes
}

RFC 6962 compliant Merkle Tree with domain separation against second-preimage attacks.

#
MerkleTree::get_proof

fn MerkleTree::get_proof(self : MerkleTree, index : Int) -> Result[MerkleProof, String]

Generate a Merkle inclusion proof for the leaf at the specified index.

#
MerkleTree::leaf_count

fn MerkleTree::leaf_count(self : MerkleTree) -> Int

Return the number of original leaves in the tree.

#
MerkleTree::new

fn MerkleTree::new(leaves : Array[Bytes]) -> MerkleTree

Construct a new Merkle Tree from an array of leaf data bytes.

#
MerkleTree::root

fn MerkleTree::root(self : MerkleTree) -> Bytes

Get the Merkle root hash as raw bytes.

#
MerkleTree::root_hex

fn MerkleTree::root_hex(self : MerkleTree) -> String

Get the Merkle root hash formatted as lowercase hex string.

#
MerkleTree::verify_all

fn MerkleTree::verify_all(self : MerkleTree) -> Bool

Generate and verify every inclusion proof against the current root. This is useful as a release-time self-check before publishing a manifest.

#
verify_proof

fn verify_proof(proof : MerkleProof, expected_root : Bytes) -> Bool

Verify a Merkle inclusion proof against an expected root hash.

Source Files

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io