Pure MoonBit IETF MLS (RFC 9420) end-to-end encrypted group messaging protocol engine: TreeKEM, Secret Tree, Key Schedule, framing, and stateful Group API.
| ID | RFC 9420 CipherSuite | KEM | AEAD | Hash | Signature | Status |
|---|---|---|---|---|---|---|
| 0x0001 | MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519 | X25519 | AES-128-GCM | SHA-256 | Ed25519 | Supported & IETF verified |
| 0x0002 | MLS_128_DHKEMP256_AES128GCM_SHA256_P256 | P-256 | AES-128-GCM | SHA-256 | ECDSA-P256 | Supported & IETF verified |
| 0x0003 | MLS_128_DHKEMX25519_CHACHA20POLY1305_SHA256_Ed25519 | X25519 | ChaCha20-Poly1305 | SHA-256 | Ed25519 | Supported & IETF verified |
| 0x0004 | MLS_256_DHKEMX448_AES256GCM_SHA512_Ed448 | X448 | AES-256-GCM | SHA-512 | Ed448 | Supported & IETF verified |
| 0x0006 | MLS_256_DHKEMX448_CHACHA20POLY1305_SHA512_Ed448 | X448 | ChaCha20-Poly1305 | SHA-512 | Ed448 | Supported & IETF verified |
| 0x0005 | MLS_256_DHKEMP521_AES256GCM_SHA512_P521 | P-521 | AES-256-GCM | SHA-512 | ECDSA-P521 | Out of scope (mooncry lacks P-521) |
| 0x0007 | MLS_256_DHKEMP384_AES256GCM_SHA384_P384 | P-384 | AES-256-GCM | SHA-384 | ECDSA-P384 | Out of scope (mooncry lacks P-384) |
moon update
moon add Ridge-Lab/moonmlsimport {
"Ridge-Lab/moonmls",
"Ridge-Lab/moonmls/types",
}let suite = @types.CipherSuite::MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519
// 1. Alice creates a new group (Epoch 0)
let alice = @moonmls.Group::create(suite, b"team-room", b"alice", alice_seed)
// 2. Bob publishes a signed KeyPackage
let bob_kp = @moonmls.generate_key_package(suite, b"bob", bob_seed)
// 3. Alice adds Bob in Epoch 1 and sends him the Welcome
let c1 = alice.commit(
inline_proposals=[Add(bob_kp.key_package)],
commit_leaf_seed,
commit_hpke_seed,
)
let bob = @moonmls.Group::join_from_welcome(c1.welcome.unwrap(), bob_kp)
// 4. End-to-end encrypted messaging (PrivateMessage)
let wire = alice.encrypt_application(b"Hello Bob over RFC 9420!")
let dec = bob.decrypt_application(wire)
assert_eq(dec.plaintext, b"Hello Bob over RFC 9420!")moon run --target wasm-gc examples/basicMoonMLS basic: epoch=1, members=2, wire=179 bytes
Verified epoch_authenticator=1441b383ffd8a864c4cc6f1311df32ee5255309e32f3dea8481d478e11738aaf
Decrypted 37 bytes from leaf 0 gen 0moon run --target wasm-gc examples/group_lifecycleMoonMLS lifecycle: CS3 epoch=4, active_members=4, exporter=24b0ff199d5c034d2149bf2b0b9fb7c7moon run --target wasm-gc examples/ciphersuitesPASS CS1 (X25519/AES128GCM/SHA256/Ed25519): auth=273a7cebc996a7ec...
PASS CS2 (P256/AES128GCM/SHA256/ECDSA-P256): auth=1e8a11eee04fb577...
PASS CS3 (X25519/ChaCha20Poly1305/SHA256/Ed25519): auth=276cbcc7135c00ca...
PASS CS4 (X448/AES256GCM/SHA512/Ed448): auth=387316e907084acd...
PASS CS6 (X448/ChaCha20Poly1305/SHA512/Ed448): auth=a7f959520da006e2...# Interactive RFC 9420 CLI demo (Add, E2EE, PCS Update, External Commit, Exporter)
node scripts/moonmls.mjs demo --suite 1
# Generate a KeyPackage
node scripts/moonmls.mjs keygen --identity alice --suite 3
# Inspect any RFC 9420 MLSMessage wire hex
node scripts/moonmls.mjs inspect <hex>
# Build and serve the zero-upload Browser TreeKEM Studio (http://127.0.0.1:4173/)
npm run web:build
npm run web:serve# Quick profile: fmt, check --target all, unit/security tests, 3 examples, CLI, 12 fault-injection tests, web build & Studio tests
python scripts/verify.py --profile quick --targets js wasm wasm-gc
# Full profile: adds all 16 official IETF RFC 9420 test-vector suites (auto-fetched at pinned SHA) + benchmarks + moon package check
python scripts/verify.py --profile full --targets js wasm wasm-gc --fetch-ietf| Suite | Passed | Failed | Skipped (CS5/7) | Coverage |
|---|---|---|---|---|
| tree-math.json | 10 | 0 | 0 | LBBT math for tree sizes 1..255 |
| deserialization.json | 14 | 0 | 0 | Minimal QUIC varint & rejection rules |
| crypto-basics.json | 5 | 0 | 2 | RefHash, ExpandWithLabel, DeriveSecret, DeriveTreeSecret, Sign/Encrypt |
| secret-tree.json | 15 | 0 | 6 | Handshake/Application ratchets & sender_data keys |
| key-schedule.json | 5 | 0 | 2 | Multi-epoch Key Schedule & Exporter |
| psk_secret.json | 55 | 0 | 22 | PSK secret extraction & chaining |
| transcript-hashes.json | 5 | 0 | 2 | Confirmed & Interim Transcript Hashes |
| message-protection.json | 5 | 0 | 2 | PublicMessage & PrivateMessage protection/unprotection |
| welcome.json | 5 | 0 | 2 | Welcome decrypt & GroupInfo verification |
| tree-operations.json | 5 | 0 | 0 | Add / Update / Remove tree mutations |
| tree-validation.json | 70 | 0 | 28 | Resolution, tree hashes, parent hashes, leaf signatures |
| treekem.json | 22 (55 full) | 0 | 22 | UpdatePath creation & processing across tree topologies |
| messages.json | 300 | 0 | 0 | 5,100 canonical wire struct roundtrips (all 17 types) |
| passive-client-welcome.json | 40 | 0 | 16 | End-to-end passive Welcome joins (with & without PSK) |
| passive-client-handling-commit.json | 65 | 0 | 26 | End-to-end passive Commit processing (Proposals, UpdatePath, External) |
| passive-client-random.json | 1 | 0 | 0 | 200 consecutive randomized multi-member epochs |
| Total (16 / 16 suites) | 622 | 0 | 130 | 100% pass rate on all supported suites |
pub struct DecryptedWelcome {
group_secrets : GroupSecrets
group_info : GroupInfo
psk_secret : Bytes
}pub struct Group {
suite : CipherSuite
context : GroupContext
ratchet_tree : RatchetTree
priv_state : PrivateTreeState
secrets : EpochSecrets
secret_tree : SecretTree
interim_transcript_hash : Bytes
pending_proposals : Map[Bytes, (Proposal, Sender)]
pending_update_privs : Map[Bytes, Bytes]
external_psks : Map[Bytes, Bytes]
resumption_psks : Map[UInt64, Bytes]
}fn Group::decrypt_application(self : Group, msg : MLSMessage) -> DecryptedApplication raise MlsErrorfn Group::encrypt_application(self : Group, plaintext : Bytes, authenticated_data? : Bytes, reuse_guard? : Bytes, padding_len? : Int) -> MLSMessage raise MlsErrorfn Group::join_external(group_info : GroupInfo, identity : Bytes, seed : Bytes, leaf_secret_seed : Bytes, hpke_seed : Bytes, external_tree? : Bytes?) -> (Group, MLSMessage) raise MlsErrorfn Group::join_from_welcome(welcome_msg : MLSMessage, kp_bundle : KeyPackageBundle, external_tree? : Bytes?, external_psks? : Map[Bytes, Bytes]) -> Group raise MlsErrorfn Group::propose(self : Group, proposal : Proposal, reuse_guard? : Bytes, encrypted? : Bool) -> (MLSMessage, Bytes) raise MlsErrorfn Group::propose_update(self : Group, new_key_seed : Bytes, reuse_guard? : Bytes, encrypted? : Bool) -> (MLSMessage, Bytes) raise MlsErrorpub(all) struct KeyPackageBundle {
key_package : KeyPackage
init_priv : Bytes
encryption_priv : Bytes
signature_priv : Bytes
}fn decrypt_welcome(suite : CipherSuite, welcome : Welcome, kp : KeyPackage, init_priv : Bytes, lookup_psk : (PreSharedKeyID) -> Bytes raise MlsError) -> DecryptedWelcome raise MlsErrorfn generate_key_package(suite : CipherSuite, identity : Bytes, seed : Bytes, not_before? : UInt64, not_after? : UInt64, extensions? : Array[Extension]) -> KeyPackageBundle raise MlsErrorfn verify_group_info(suite : CipherSuite, group_info : GroupInfo, signer_pub : Bytes, joiner_secret : Bytes, psk_secret : Bytes) -> EpochSecrets raise MlsErrorInstall
Download zipPure MoonBit IETF MLS (RFC 9420) end-to-end encrypted group messaging protocol engine: TreeKEM, Secret Tree, Key Schedule, framing, and stateful Group API.