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

    HashRatchet

    pub struct HashRatchet {
    suite :
    CipherSuite

    secret : Bytes
    next_generation : UInt
    out_of_order : Map[UInt, RatchetKeyNonce]
    max_forward_distance : UInt
    }

    Stateful hash ratchet for a single leaf and channel (handshake or application). Consumed generations are erased to enforce forward secrecy and prevent replay.

    HashRatchet::key_nonce_for_generation

    fn HashRatchet::key_nonce_for_generation(self : HashRatchet, generation : UInt) -> RatchetKeyNonce raise
    MlsError

    Obtain and consume the key/nonce for a specific generation (supporting bounded out-of-order delivery while rejecting replayed/expired generations).

    HashRatchet::new

    fn HashRatchet::new(suite :
    CipherSuite
    , initial_secret : Bytes, max_forward_distance? : UInt) -> HashRatchet

    HashRatchet::next_generation

    fn HashRatchet::next_generation(self : HashRatchet) -> UInt

    HashRatchet::next_key_nonce

    Advance the ratchet by one generation for sending the next message.

    RatchetKeyNonce

    pub(all) struct RatchetKeyNonce {
    key : Bytes
    nonce : Bytes
    generation : UInt
    } derive(Eq,
    Debug
    )

    Derived per-message AEAD key and base nonce for a specific generation.

    SecretTree

    pub struct SecretTree {
    suite :
    CipherSuite

    n_leaves : UInt
    nodes : Array[Bytes?]
    handshake_ratchets : Array[HashRatchet?]
    application_ratchets : Array[HashRatchet?]
    max_forward_distance : UInt
    }

    RFC 9420 §9 Secret Tree rooted at an epoch's encryption_secret. Node secrets are lazily derived on demand and erased once both children are derived (or once a leaf splits into handshake/application ratchets).

    SecretTree::key_nonce_for_generation

    fn SecretTree::key_nonce_for_generation(self : SecretTree, leaf_index : UInt, content_type :
    ContentType
    , generation : UInt) -> RatchetKeyNonce raise
    MlsError

    Consume the receiving key/nonce for (leaf_index, content_type, generation).

    SecretTree::new

    fn SecretTree::new(suite :
    CipherSuite
    , encryption_secret : Bytes, n_leaves : UInt, max_forward_distance? : UInt) -> SecretTree raise
    MlsError

    SecretTree::next_key_nonce

    Consume the next sending key/nonce for (leaf_index, content_type).

    DEFAULT_MAX_FORWARD_DISTANCE

    let DEFAULT_MAX_FORWARD_DISTANCE : UInt

    sender_data_key_nonce

    fn sender_data_key_nonce(suite :
    CipherSuite
    , sender_data_secret : Bytes, ciphertext : Bytes) -> (Bytes, Bytes) raise
    MlsError

    RFC 9420 §6.3.2 sender_data_key and sender_data_nonce derivation.

    Source Files