TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/openmls/openmls/llms.txt
Use this file to discover all available pages before exploring further.
RatchetTree represents the complete public state of an MLS group’s tree structure. It contains all leaf and parent nodes in the tree and is used for synchronizing tree state across group members.
Overview
The ratchet tree is a left-balanced binary tree where:- Leaf nodes (even indices) represent group members
- Parent nodes (odd indices) contain shared secrets for subgroups
- Blank nodes represent vacant positions in the tree
Structure
Vector of optional nodes in array representation of the binary tree. Even indices are leaf nodes, odd indices are parent nodes.
RatchetTreeExtension
The ratchet tree can be included in GroupInfo messages via the RatchetTreeExtension:Creating RatchetTreeExtension
Tree Validation
When creating a RatchetTree from nodes, several validations are performed:1. No Trailing Blank Nodes
Ratchet trees must not have trailing blank nodes:2. Node Type Validation
- Even indices must be LeafNodes (or blank)
- Odd indices must be ParentNodes (or blank)
3. Signature Verification
All leaf nodes in the tree are signature-verified during import:Creating from Nodes
The ciphersuite to use for signature verification
Crypto provider for signature operations
Vector of unverified nodes
Group ID for leaf node verification
Verified ratchet tree or error if validation fails
RatchetTreeIn (Unverified)
The deserialized, unverified form of a ratchet tree:Verification
Ciphersuite for verification
Crypto provider
Group identifier
Verified ratchet tree
Exporting Ratchet Tree
Export the current tree state:- Includes all nodes up to the rightmost full leaf
- Trims trailing blank nodes
- Contains only public information
Tree Indexing
Nodes are indexed in array representation:Computing Tree Root
Tree Operations
Finding Free Leaf
Find the next available position for adding a member:Iterating Leaves
Iterating Parents
Finding Blank Nodes
Wire Format
The ratchet tree is serialized as:Example: Processing Ratchet Tree
Errors
The ratchet tree has no nodes
The ratchet tree has trailing blank nodes (invalid per spec)
A leaf node has an invalid signature
A node has the wrong type for its index (e.g., parent at even index)
Best Practices
- Always Verify: Use
into_verified()when processing received ratchet trees - Trim Blanks: Exported trees automatically trim trailing blanks
- Cache Results: Tree operations can be expensive, cache when possible
- Validate Context: Ensure group_id matches when verifying
See Also
- LeafNode - Leaf node structure
- ParentNode - Parent node structure
- TreeSync - RFC 9420 TreeSync specification