Ridge-Lab/moonmls/tree does not have a README file

    CreatedUpdatePath

    pub struct CreatedUpdatePath {
    update_path :
    UpdatePath

    path_secrets : Array[Bytes]
    commit_secret : Bytes
    new_tree : RatchetTree
    new_private_state : PrivateTreeState
    }

    Result of creating an UpdatePath (RFC 9420 §7.6).

    PrivateTreeState

    pub struct PrivateTreeState {
    leaf_index : UInt
    leaf_encryption_priv : Bytes
    signature_priv : Bytes
    node_privs : Map[UInt, Bytes]
    }

    Local member's TreeKEM private state: leaf index, leaf encryption private key, signature private key, and private HPKE keys for ancestor nodes on its direct path.

    PrivateTreeState::clear_node_privs

    fn PrivateTreeState::clear_node_privs(self : PrivateTreeState) -> Unit

    PrivateTreeState::copy

    PrivateTreeState::new

    fn PrivateTreeState::new(leaf_index : UInt, leaf_encryption_priv : Bytes, signature_priv : Bytes) -> PrivateTreeState

    PrivateTreeState::private_key_for_node

    fn PrivateTreeState::private_key_for_node(self : PrivateTreeState, node : UInt) -> Bytes?

    Lookup our private HPKE key for node (leaf or ancestor parent node).

    PrivateTreeState::set_leaf_encryption_priv

    fn PrivateTreeState::set_leaf_encryption_priv(self : PrivateTreeState, new_sk : Bytes) -> Unit

    PrivateTreeState::set_node_priv

    fn PrivateTreeState::set_node_priv(self : PrivateTreeState, node : UInt, sk : Bytes) -> Unit

    PrivateTreeState::set_path_secret

    fn PrivateTreeState::set_path_secret(self : PrivateTreeState, suite :
    CipherSuite
    , node : UInt, path_secret : Bytes) -> Unit raise
    MlsError

    Set private key for node derived from path_secret.

    ProcessedUpdatePath

    pub struct ProcessedUpdatePath {
    decrypted_path_secret : Bytes
    commit_secret : Bytes
    new_tree : RatchetTree
    new_private_state : PrivateTreeState
    }

    Result of processing a received UpdatePath (RFC 9420 §7.6).

    RatchetTree

    pub struct RatchetTree {
    nodes : Array[
    TreeNode
    ?]
    }

    RatchetTree::add_leaf

    RFC 9420 §12.1.1 Apply an Add proposal's LeafNode to the tree, returning the assigned leaf index.

    RatchetTree::copy

    fn RatchetTree::copy(self : RatchetTree) -> RatchetTree

    RatchetTree::create_update_path

    fn RatchetTree::create_update_path(self : RatchetTree, suite :
    CipherSuite
    , group_id : Bytes, priv_state : PrivateTreeState, leaf_secret : Bytes, hpke_seed : Bytes, excluded_leaves : Array[UInt], build_group_context : (Bytes) -> Bytes raise
    MlsError
    ) -> CreatedUpdatePath raise
    MlsError

    Create a fresh UpdatePath from priv_state.leaf_index (RFC 9420 §7.6). leaf_secret is the fresh N_h-byte leaf secret; hpke_seed seeds deterministic ephemeral HPKE encryptions for each copath ciphertext.

    RatchetTree::decode

    RatchetTree::encode

    RatchetTree::filtered_direct_path

    fn RatchetTree::filtered_direct_path(self : RatchetTree, leaf_index : UInt) -> Array[(UInt, UInt)] raise
    MlsError

    RFC 9420 §4.1.2 Filtered direct path of leaf_index: returns array of (parent_node, copath_node) for every parent whose copath resolution is non-empty.

    RatchetTree::from_nodes

    Construct a RatchetTree from raw decoded nodes, extending with trailing blanks to the full power-of-2 binary tree size required by RFC 9420 §7.1.

    RatchetTree::leaf_at

    fn RatchetTree::leaf_at(self : RatchetTree, leaf_index : UInt) ->
    LeafNode
    ?

    RatchetTree::leaf_signature_key

    fn RatchetTree::leaf_signature_key(self : RatchetTree, leaf_index : UInt) -> Bytes raise
    MlsError

    Lookup the signature public key of a non-blank LeafNode.

    RatchetTree::merge_update_path

    Merge a received UpdatePath from sender_leaf into a copy of tree, verifying leaf signature, filtered direct path length, and top-down parent hash.

    RatchetTree::n_leaves

    fn RatchetTree::n_leaves(self : RatchetTree) -> UInt

    RatchetTree::n_nodes

    fn RatchetTree::n_nodes(self : RatchetTree) -> UInt

    RatchetTree::new_single

    Create a single-member RatchetTree containing one initial LeafNode.

    RatchetTree::node_at

    RatchetTree::node_encryption_key

    fn RatchetTree::node_encryption_key(self : RatchetTree, node : UInt) -> Bytes raise
    MlsError

    Lookup the HPKE encryption public key of a non-blank node (Leaf or Parent).

    RatchetTree::node_tree_hash

    RFC 9420 §7.8 Tree hash of a specific node.

    RatchetTree::node_tree_hash_excluding

    fn RatchetTree::node_tree_hash_excluding(self : RatchetTree, suite :
    CipherSuite
    , node : UInt, excluded_leaves : Array[UInt]) -> Bytes raise
    MlsError

    RFC 9420 §7.8 Compute the tree hash of node, optionally excluding excluded_leaves (used for computing original_sibling_tree_hash in parent-hash verification).

    RatchetTree::process_update_path

    fn RatchetTree::process_update_path(self : RatchetTree, suite :
    CipherSuite
    , group_id : Bytes, sender_leaf : UInt, update_path :
    UpdatePath
    , excluded_leaves : Array[UInt], priv_state : PrivateTreeState, build_group_context : (Bytes) -> Bytes raise
    MlsError
    ) -> ProcessedUpdatePath raise
    MlsError

    Process a received UpdatePath as member priv_state.leaf_index. build_group_context(new_tree_hash) builds the provisional GroupContext bytes used as HPKE context when decrypting UpdatePathNode.

    RatchetTree::remove_leaf

    fn RatchetTree::remove_leaf(self : RatchetTree, removed_leaf : UInt) -> Unit raise
    MlsError

    RFC 9420 §12.1.3 Apply a Remove proposal: blank leaf + direct path, then shrink right-blank halves.

    RatchetTree::resolution

    fn RatchetTree::resolution(self : RatchetTree, node : UInt) -> Array[UInt] raise
    MlsError

    RFC 9420 §7.4 Resolution of a node in the ratchet tree.

    RatchetTree::to_truncated_nodes

    Return the trimmed node array (no trailing blanks) for RFC 9420 §12.4.3.3 serialization.

    RatchetTree::tree_hash

    RFC 9420 §7.8 Root tree hash of the ratchet tree.

    RatchetTree::update_leaf

    fn RatchetTree::update_leaf(self : RatchetTree, sender_leaf : UInt, new_leaf :
    LeafNode
    ) -> Unit raise
    MlsError

    RFC 9420 §12.1.2 Apply an Update proposal from sender_leaf: replace leaf & blank direct path.

    RatchetTree::verify_all_leaf_signatures

    fn RatchetTree::verify_all_leaf_signatures(self : RatchetTree, suite :
    CipherSuite
    , group_id : Bytes) -> Unit raise
    MlsError

    Verify signatures on all non-blank leaves in the tree (RFC 9420 §7.2 / §12.4.3.1).

    RatchetTree::verify_parent_hashes

    RFC 9420 §7.9.2 Verify parent-hash integrity of every non-blank parent node in the tree.

    compute_parent_hash

    fn compute_parent_hash(suite :
    CipherSuite
    , encryption_key : Bytes, parent_hash : Bytes, original_sibling_tree_hash : Bytes) -> Bytes raise
    MlsError

    RFC 9420 §7.9 Compute ParentHash = Hash(ParentHashInput).

    derive_node_key_pair

    fn derive_node_key_pair(suite :
    CipherSuite
    , path_secret : Bytes) -> (Bytes, Bytes) raise
    MlsError

    Derive a node's HPKE (priv, pub) pair from its path_secret (RFC 9420 §7.5).

    verify_leaf_signature

    fn verify_leaf_signature(suite :
    CipherSuite
    , leaf :
    LeafNode
    , group_id : Bytes?, leaf_index : UInt?) -> Unit raise
    MlsError

    RFC 9420 §7.2 Verify the signature on a single LeafNode.