kolo-mls gives groups end-to-end encryption by the Messaging Layer Security protocol (RFC 9420, with the architecture in RFC 9750) for cipher suite 0x0001 (X25519, AES-128-GCM, SHA-256, Ed25519), written on the Go standard library only. Only the current members of a group can read its messages: the history of a group is a chain of epochs, and each epoch starts with a commit that gives fresh secrets only to the members of that epoch. Every device is one member (a leaf of the group's tree), and its identity is a kolo-id device certificate chain. The group's admin devices decide each epoch's commit through kolo-braid, and the application carries the commits (for example over kolo-gossip) and keeps them on pins (kolo-pin), so that a device that was offline can catch up. The application also delivers the welcome for a new member; kolo-mls does not wire it to any carrier. Kolo's own formats around MLS use kolo-codec.
The root package kolomls is the MLS core, with the group state kept in a Store you provide. A Kolo group adds the packages cred (the credential of a kolo-id device), settle (the rules of a member device: a commit is applied only with signatures from a quorum of settlers) and braid (the admins' side over kolo-braid), and backendstore keeps groups in a kolo-store backend.
The application supplies five things: an Authenticator that checks credentials (in a Kolo group, cred.Authenticator, whose Expect function is the check of whether a person may be in the group; without one, any person the admins add is accepted), a Policy with the application's rules (in a Kolo group, settle.Policy), a Store that holds the group state (MemStore in memory, or backendstore.New on a kolo-store backend), a clock and the calls the library asks for at the times it returns (it has no timers), and at least two admin devices.
One epoch change, settled by the admins
The braid holds only the admin devices, and every member applies a Commit only with a quorum of settler signatures.
- At epoch n each member device is one leaf of the group's ratchet tree. The group's braid holds only the admin devices, and the settlers are among them.
- An admin makes a Commit, here removing device D. It keeps the Commit bytes on pins and writes a reference to them in the admins' braid: the group, the epoch and the hash of the Commit.
- The settlers vote from the braid's settled order: the first reference not yet decided wins with a quorum of accept votes. Three settlers under the majority rule need two.
- The settlers sign the decided Commit under the context kolo-mls/commit-settled/v0. A quorum of these signatures makes the settled commit, which an admin keeps on pins.
- The application carries the Commit and the signatures to the members. Each member applies the Commit only with signatures from a quorum of the epoch's settlers, and moves to epoch n + 1 with fresh secrets. The removed device D cannot compute them.
- When a Commit adds a member, its welcome is sent only after the settler signatures exist. The application delivers it to that member, who joins with the welcome, the settled commit and the encrypted tree from pins.
Install
go get github.com/ciranda-dev/kolo-mlsIt needs Go 1.26 or newer and is pure Go: no cgo and nothing to install. The root package imports the standard library only; cred, settle, braid and backendstore also pull Kolo modules (kolo-id, kolo-codec, kolo-braid, kolo-store). A member device (settle, with cred and the core) needs only the core, kolo-id and kolo-codec. The admin side (braid) runs on kolo-braid and backendstore on a kolo-store backend; kolo-store's on-disk backend builds with CGO_ENABLED=0 (with cgo on, it links a C compression library). kolo-mls is tagged v0.1.0: to pin it, run go get github.com/ciranda-dev/kolo-mls@v0.1.0.
Quick start
Two members in memory: alice creates a group with a KeyPackage of her own, adds bob with his KeyPackage, the ratchet tree goes to him next to the Welcome, and she sends him one message. Credentials are basic and checked by a small directory that binds each name to one key (an Authenticator), an envelope (Envelope) binds each message's generation into its authenticated data (RFC 9750 section 8.6), and the Policy adds no rule beyond RFC 9420. This is examples/basic of the repository; run it with go run ./examples/basic in a clone.
// Command basic creates an MLS group of two members in memory: alice creates it,
// adds bob with his KeyPackage and a Welcome, and sends him one message.
package main
import (
"bytes"
"crypto/ed25519"
"encoding/binary"
"errors"
"fmt"
"io"
"log"
"os"
kolomls "github.com/ciranda-dev/kolo-mls"
)
// directory is a small Authentication Service: it accepts a basic credential
// only with the signature key registered for its identity.
type directory map[string]ed25519.PublicKey
func (d directory) Validate(c kolomls.Credential, signatureKey []byte, _ kolomls.Event) error {
key, ok := d[string(c.Identity)]
if c.Type != kolomls.CredentialBasic || !ok || !bytes.Equal(key, signatureKey) {
return errors.New("basic: unknown identity or signature key")
}
return nil
}
func (d directory) Successor(prev, next kolomls.Credential) error {
if !bytes.Equal(prev.Identity, next.Identity) {
return errors.New("basic: identity changed")
}
return nil
}
func (d directory) ClientID(c kolomls.Credential) ([]byte, error) { return c.Identity, nil }
// generation binds the generation of each PrivateMessage into its signed
// authenticated data, so a member cannot replay another member's message
// under a later generation (RFC 9750 section 8.6). Kolo groups use
// settle.Envelope.
type generation struct{}
func (generation) Wrap(gen uint32, aad []byte) ([]byte, error) {
return append(binary.BigEndian.AppendUint32(nil, gen), aad...), nil
}
func (generation) Unwrap(gen uint32, ad []byte) ([]byte, error) {
if len(ad) < 4 || binary.BigEndian.Uint32(ad) != gen {
return nil, errors.New("basic: authenticated data of another generation")
}
return ad[4:], nil
}
// rfcOnly adds no rule to those of RFC 9420.
type rfcOnly struct{}
func (rfcOnly) CheckProposal(kolomls.ProposalView) error { return nil }
func (rfcOnly) CheckCommit(kolomls.CommitView) error { return nil }
func (rfcOnly) CheckJoin(kolomls.JoinView) error { return nil }
func main() {
if err := run(os.Stdout); err != nil {
log.Fatal(err)
}
}
// keyPackage registers a new signature key for name in d, which binds a
// name to one key, and returns a KeyPackage whose private keys go in st.
func keyPackage(st kolomls.Store, d directory, name string) ([]byte, error) {
if _, ok := d[name]; ok {
return nil, fmt.Errorf("basic: %s is already registered", name)
}
pub, priv, err := ed25519.GenerateKey(nil)
if err != nil {
return nil, err
}
d[name] = pub
c := kolomls.Credential{Type: kolomls.CredentialBasic, Identity: []byte(name)}
return kolomls.NewKeyPackage(st, kolomls.KeyPackageOptions{Credential: c, SignatureKey: priv})
}
// config is the Config of the groups, with d as their Authentication
// Service.
func config(d directory) kolomls.Config {
return kolomls.Config{Authenticator: d, Policy: rfcOnly{}, Envelope: generation{}}
}
func run(w io.Writer) error {
d := directory{}
cfg := config(d)
aliceStore, bobStore := kolomls.NewMemStore(), kolomls.NewMemStore()
aliceKP, err := keyPackage(aliceStore, d, "alice")
if err != nil {
return err
}
alice, err := kolomls.Create(aliceStore, kolomls.CreateOptions{Config: cfg, KeyPackage: aliceKP})
if err != nil {
return err
}
defer alice.Close()
bobKP, err := keyPackage(bobStore, d, "bob")
if err != nil {
return err
}
pc, err := alice.Commit(kolomls.CommitOptions{Add: [][]byte{bobKP}})
if err != nil {
return err
}
tree, err := pc.RatchetTree()
if err != nil {
return err
}
if err := alice.ApplyPending(); err != nil {
return err
}
bob, err := kolomls.Join(bobStore, pc.Welcome(), tree, kolomls.JoinOptions{Config: cfg})
if err != nil {
return err
}
defer bob.Close()
msg, err := alice.Encrypt([]byte("hello, bob"), nil)
if err != nil {
return err
}
res, err := bob.Process(msg)
if err != nil {
return err
}
ea, err := alice.EpochAuthenticator()
if err != nil {
return err
}
eb, err := bob.EpochAuthenticator()
if err != nil {
return err
}
fmt.Fprintf(w, "bob read %q in epoch %d\n", res.Application, res.Epoch)
fmt.Fprintf(w, "members: %d\n", len(bob.Tree().Members()))
fmt.Fprintf(w, "same epoch authenticator: %t\n", bytes.Equal(ea, eb))
return nil
}It prints:
$ go run ./examples/basic
bob read "hello, bob" in epoch 1
members: 2
same epoch authenticator: trueA Kolo group uses cred, settle and braid instead: the credential is a kolo-id device certificate, a commit is applied only with signatures from a quorum of settlers, and the admins decide each epoch through kolo-braid. Good to know explains epochs, commits, admins and settlers.
Formats
MLS messages use the encoding of RFC 9420, whose notation is the presentation language of RFC 9846 section 3, not kolo-codec. This is a deliberate exception to the rule that Kolo's network formats use kolo-codec: the official test vectors and other implementations require the RFC encoding. Kolo's own envelopes around MLS messages use kolo-codec. The only cipher suite is 0x0001, MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519, built on crypto/hpke, crypto/ecdh, crypto/hkdf, crypto/ed25519, crypto/aes, crypto/cipher, crypto/sha256 and crypto/hmac, with no new primitive. External commits, external proposals and ReInit are parsed and checked for syntax, then refused by policy with a typed error.
| Format | Where | Contents, in kolo-codec |
|---|---|---|
Kolo credential, type 0xF001 (cred) | the credential of a leaf | a uvarint version (0), the kolo-id device certificate as bytes and the device's 64-byte signature over the binding |
Roles extension, type 0xF002 (settle) | a GroupContext extension | a uvarint version (0), the 32-byte group ID of the admins' braid, a uvarint quorum rule (1 Majority, 2 TwoThirds), then the admin device keys and the settler device keys, each a count and 32-byte keys in strictly increasing order |
Generation envelope (settle) | the authenticated data of every PrivateMessage in a Kolo group | a uvarint version (0), the uvarint generation and the application's authenticated data as bytes |
Settled commit (settle) | carried by the application, and pins | the string kolo-mls/settled-commit/v0, the signed part below, a uvarint count of signatures and, for each, the settler's 32-byte device key and 64-byte signature, keys strictly increasing |
Braid entries (braid) | the admins' braid | a commit reference, a vote and a signature share, below |
The binding that a device signs is a uvarint version (0), the uvarint cipher suite, the leaf's 32-byte MLS signature key and the SHA-256 of the device certificate. The credential is at most 581 bytes (cred.MaxBody): a version (1), the certificate's length (2), the largest certificate with its approver parent (514) and the signature (64). The device key never signs MLS bytes itself: each leaf has its own MLS signature key.
The signed part of a settled commit is a uvarint version (0), the 32-byte group ID as bytes, the uvarint epoch, four 32-byte values (the SHA-256 of the Commit's MLSMessage, of the GroupContext of the epoch, of the GroupContext of the next epoch and the group ID of the braid) and the uvarint settled position of the commit's reference. Every settler signs it with its device key, and a member applies the commit only with valid signatures of a quorum of the epoch's settlers.
The three braid entries start with the strings kolo-mls/commit-ref/v0, kolo-mls/commit-vote/v0 and kolo-mls/commit-sig/v0 and carry the writer's device certificate as bytes. A reference adds the group ID, the epoch and the SHA-256 of the Commit. A vote adds the same, the SHA-256 of the context before, a bool (accept or reject) and a uvarint reason. A signature share adds the signed part above and the settler's 64-byte signature. kolo-log signs the entries, as for every braid entry.
On pins, the keys (settle.ObjectKey, SettledKey, TreeKey and ArchiveKey) start with kolo-mls/object/ (a Commit, under the hex SHA-256 of its MLSMessage), kolo-mls/settled/ and kolo-mls/tree/ (a settled commit and an encrypted ratchet tree, each under the hex group ID and the epoch) and kolo-mls/archive/ (the archived messages of an epoch, under the hex group ID, the epoch and the hex SHA-256 of the message). The encrypted tree (settle.SealTree and settle.OpenTree) is AES-128-GCM: the key and the nonce are exported from the epoch (RFC 9420 section 8.5) under the labels kolo-mls/ratchet-tree/v0 and kolo-mls/ratchet-tree-nonce/v0 with the sealing admin's device key as context, the group ID and the epoch are the additional data, and the result is that 32-byte device key followed by the ciphertext.
Two signatures are Kolo's own, each with its own Ed25519ctx context string, so a signature made for one purpose never verifies as another: kolo-mls/leaf-key/v0 (cred.LeafKeyContext, the device's signature over the binding) and kolo-mls/commit-settled/v0 (settle.SettledContext, a settler's signature over a settled commit). This signature scheme is Kolo's own design and is not in any RFC.
Encrypted messages are padded to the Padmé length, at most about 12% longer (RFC 9420 sections 6.3 and 15.1).
Key packages, their leaves and welcomes carry random GREASE values (RFC 9420 section 13.5), so that peers that refuse unknown values show up early, and unknown values received are ignored where section 13.4 says so. One independent implementation refuses a GREASE extension in a leaf, a KeyPackage or a GroupInfo, contrary to RFC 9420 sections 13.4, 13.5 and 17.3, so it refuses these key packages and welcomes. kolo-mls follows the RFC.
API reference
The API reference is generated from the Go source and is in English.
Package kolomls is group end-to-end encryption by the MLS standard (RFC 9420) for cipher suite 0x0001, on the Go standard library only. Packages cred, settle and braid add the Kolo credential, the rules of a Kolo group's member devices and its admins' side over kolo-braid; backendstore keeps groups in a kolo-store Backend.
A member makes a KeyPackage with NewKeyPackage and starts a group with Create. Group.Commit adds members, ApplyPending makes the Commit the new epoch, and each added member enters with Join from the Welcome and the ratchet tree. Group.Encrypt and Group.Process carry the messages. State lives in a Store the caller provides; NewMemStore is the in-memory one.
Experimental. The API may change before v1.0.0.
Constants
const (
// CredentialBasic is the type of a basic credential (RFC 9420 section 5.3).
CredentialBasic = tree.CredentialBasic
// CredentialX509 is the type of an x509 credential (RFC 9420 section 5.3).
CredentialX509 = tree.CredentialX509
// PSKExternal is the type of an external PSK (RFC 9420 section 8.4).
PSKExternal = schedule.PSKExternal
// PSKResumption is the type of a resumption PSK (RFC 9420 section 8.4).
PSKResumption = schedule.PSKResumption
// UsageApplication is the resumption usage for an application (RFC 9420 section 8.4).
UsageApplication = schedule.UsageApplication
// UsageBranch is the resumption usage for a branch (RFC 9420 section 8.4).
UsageBranch = schedule.UsageBranch
// DefaultOutOfOrderTolerance is the Config default for OutOfOrderTolerance.
DefaultOutOfOrderTolerance = secrettree.DefaultOutOfOrderTolerance
// DefaultMaxForwardDistance is the Config default for MaxForwardDistance.
DefaultMaxForwardDistance = secrettree.DefaultMaxForwardDistance
)const DefaultKeyPackageLifetime = 84 * 24 * time.HourDefaultKeyPackageLifetime is the default lifetime of a new KeyPackage, which starts one hour before its creation.
const DefaultMaxLeafLifetime = 84*24*time.Hour + time.HourDefaultMaxLeafLifetime is the default bound on not_after - not_before of a key_package leaf: 84 days and one hour.
const DefaultMaxTreeBytes = 128 << 20DefaultMaxTreeBytes is the default bound on a ratchet tree a joiner accepts.
const DefaultPastEpochWindow = 10 * time.SecondDefaultPastEpochWindow is how long the previous epoch stays readable for late application messages after a Commit is applied.
Variables
var (
// ErrMalformed reports input that is not the canonical encoding.
ErrMalformed = errs.ErrMalformed
// ErrTooLong reports a vector longer than a variable-size length can hold.
ErrTooLong = errs.ErrTooLong
// ErrInvalidArgument reports a key, size, index or count out of range.
ErrInvalidArgument = errs.ErrInvalidArgument
// ErrUnsupported reports a valid value this implementation does not support.
ErrUnsupported = errs.ErrUnsupported
// ErrDecrypt reports a failed decryption.
ErrDecrypt = errs.ErrDecrypt
// ErrInvalidTree reports a ratchet tree that breaks a rule of RFC 9420.
ErrInvalidTree = errs.ErrInvalidTree
// ErrInvalidCommit reports an UpdatePath or Commit that breaks a rule of RFC 9420.
ErrInvalidCommit = errs.ErrInvalidCommit
// ErrTooFarAhead reports a generation beyond the forward bound of a ratchet.
ErrTooFarAhead = errs.ErrTooFarAhead
// ErrTooOld reports a generation below the out-of-order window of a ratchet.
ErrTooOld = errs.ErrTooOld
// ErrReplay reports a generation whose key was already used.
ErrReplay = errs.ErrReplay
// ErrGenerationExhausted reports a ratchet that has used every generation.
ErrGenerationExhausted = errs.ErrGenerationExhausted
// ErrWrongGroup reports a message for another group.
ErrWrongGroup = errs.ErrWrongGroup
// ErrWrongEpoch reports a message for a past epoch.
ErrWrongEpoch = errs.ErrWrongEpoch
// ErrFutureEpoch reports a message for an epoch the group has not reached.
ErrFutureEpoch = errs.ErrFutureEpoch
// ErrSignature reports a signature that does not verify.
ErrSignature = errs.ErrSignature
// ErrMembershipTag reports a PublicMessage whose membership tag does not verify.
ErrMembershipTag = errs.ErrMembershipTag
// ErrConfirmationTag reports a confirmation tag that does not match.
ErrConfirmationTag = errs.ErrConfirmationTag
// ErrInvalidLeaf reports a LeafNode that breaks a rule of RFC 9420 section 7.3.
ErrInvalidLeaf = errs.ErrInvalidLeaf
// ErrInvalidKeyPackage reports a KeyPackage that breaks a rule of RFC 9420 section 10.1.
ErrInvalidKeyPackage = errs.ErrInvalidKeyPackage
// ErrInvalidProposal reports a proposal that breaks a rule of RFC 9420 section 12.1.
ErrInvalidProposal = errs.ErrInvalidProposal
// ErrInvalidWelcome reports a Welcome or GroupInfo that breaks a rule of RFC 9420 section 12.4.3.
ErrInvalidWelcome = errs.ErrInvalidWelcome
// ErrUnknownProposal reports a Commit that references a proposal this member does not hold.
ErrUnknownProposal = errs.ErrUnknownProposal
// ErrPSKNotFound reports a pre-shared key this member does not hold.
ErrPSKNotFound = errs.ErrPSKNotFound
// ErrKeyPackageNotFound reports a Welcome for none of this client's key packages.
ErrKeyPackageNotFound = errs.ErrKeyPackageNotFound
// ErrCredential wraps an error of the Authenticator.
ErrCredential = errs.ErrCredential
// ErrPolicy wraps an error of the Policy.
ErrPolicy = errs.ErrPolicy
// ErrPendingProposals reports application data sent while proposals are
// cached: a Commit must come first (RFC 9420 section 12.4).
ErrPendingProposals = errs.ErrPendingProposals
// ErrPendingCommit reports a second pending Commit, or none where one is needed.
ErrPendingCommit = errs.ErrPendingCommit
// ErrRemoved reports a group this member was removed from.
ErrRemoved = errs.ErrRemoved
// ErrNotFound is what a Store returns for an absent key.
ErrNotFound = errs.ErrNotFound
// ErrStore wraps an error of the Store.
ErrStore = errs.ErrStore
// ErrGroupExists reports a group id this client already uses.
ErrGroupExists = errs.ErrGroupExists
// ErrUnknownSender reports a message from a leaf that is blank.
ErrUnknownSender = errs.ErrUnknownSender
// ErrClosed reports a Group used after Close.
ErrClosed = errs.ErrClosed
)Functions
func DeleteKeyPackage
func DeleteKeyPackage(st Store, keyPackage []byte) errorDeleteKeyPackage deletes the private keys of an unused KeyPackage of this client, given as an encoded MLSMessage.
func NewKeyPackage
func NewKeyPackage(st Store, o KeyPackageOptions) ([]byte, error)NewKeyPackage creates a KeyPackage with fresh init and leaf keys, stores its private keys in st for Join, and returns it as an encoded MLSMessage (RFC 9420 section 10). It seeds one group: Create and Join that use it must not run concurrently.
Types
type Authenticator
type Authenticator interface {
// Validate checks that c is valid and binds signatureKey, a copy.
Validate(c Credential, signatureKey []byte, ev Event) error
// Successor checks that next may replace prev in a member's leaf.
Successor(prev, next Credential) error
// ClientID returns the identity of the client c presents; two leaves
// with equal ids are the same client (RFC 9420 section 12.2).
ClientID(c Credential) ([]byte, error)
}Authenticator is the application's Authentication Service (RFC 9420 section 5.3.1). Its answers must be the same on every member, since members that decide differently split the group (RFC 9750 section 6.5).
type Batch
type Batch struct {
Put []KV
Delete [][]byte
}Batch is a set of writes that a Store applies atomically: the deletes, then the puts. No key is in both.
type Capabilities
type Capabilities = tree.CapabilitiesCapabilities are the versions, cipher suites, extensions, proposals and credential types a leaf supports (RFC 9420 section 7.2).
type CommitOptions
type CommitOptions struct {
// Add are the KeyPackages to add, each an encoded KeyPackage.
Add [][]byte
// Remove are the leaf indices to remove.
Remove []uint32
// PSKs are pre-shared keys to inject; a nil nonce means 32 random bytes.
PSKs []*PSKID
// Extensions are the new GroupContext extensions when SetExtensions is
// set.
Extensions []Extension
// SetExtensions adds a GroupContextExtensions proposal with Extensions,
// which may be empty.
SetExtensions bool
// References are the ProposalRefs of cached proposals to include.
References [][]byte
// NoPath omits the UpdatePath where RFC 9420 section 12.4 allows it; it
// excludes Leaf and SignatureKey.
NoPath bool
// Leaf is a template for the committer's new leaf (credential,
// capabilities, extensions, signature key); nil keeps the current one.
Leaf *LeafNode
// SignatureKey is the private key of Leaf.SignatureKey when it changes.
SignatureKey ed25519.PrivateKey
// RatchetTree puts the ratchet_tree extension in the GroupInfo.
RatchetTree bool
// AuthenticatedData is the Commit's authenticated_data.
AuthenticatedData []byte
}CommitOptions say what a Commit carries besides the cached proposals it includes by reference.
type CommitView
type CommitView struct {
// Committer is the leaf index of the committer.
Committer uint32
// CommitterLeaf is the committer's current leaf.
CommitterLeaf *LeafNode
// Proposals are the committed proposals in order.
Proposals []ProposalView
// Path is the committer's new leaf, nil without a path.
Path *LeafNode
// Context is the GroupContext of the epoch the Commit is sent in.
Context *GroupContext
// Tree is the tree of that epoch.
Tree TreeView
}CommitView is a Commit as the Policy sees it, before it is applied; every field is a copy or a read-only view.
type Config
type Config struct {
// Authenticator validates credentials; it is required.
Authenticator Authenticator
// Policy adds the application's rules; it is required.
Policy Policy
// PSKs returns pre-shared keys; nil means none is available.
PSKs PSKStore
// MaxLeafLifetime bounds the lifetime of key_package leaves; zero means
// DefaultMaxLeafLifetime and a negative value no bound.
MaxLeafLifetime time.Duration
// Now gives the time for the lifetime check of leaves this member sends
// and for the previous-epoch window; nil means time.Now.
Now func() time.Time
// ResumptionPSKs is the number of past epochs whose resumption PSK is
// kept besides the current one; zero keeps the current one only and a
// negative value is refused.
ResumptionPSKs int
// OutOfOrderTolerance is the size of the window of generations a
// receiver keeps per sender and ratchet, the newest one read included,
// so OutOfOrderTolerance - 1 older generations stay readable (RFC 9420
// section 15.3); zero means DefaultOutOfOrderTolerance, 1
// reads messages in order only, and values above 65536 (1 << 16) are
// refused.
OutOfOrderTolerance uint32
// MaxForwardDistance is how many generations one message may move a
// sender's ratchet forward (RFC 9420 section 15.3); zero means
// DefaultMaxForwardDistance, so the smallest bound is 1, and values above
// 65536 (1 << 16) are refused.
MaxForwardDistance uint32
// PastEpochWindow is how long the previous epoch stays readable for late
// application messages of members that stay, after a Commit is applied
// (RFC 9420 section 12.4.2); zero means DefaultPastEpochWindow and a
// negative value keeps no previous epoch. Now is its clock; the caller
// calls Group.ExpirePastEpoch when the window ends.
PastEpochWindow time.Duration
// PrivateHandshakes sends proposals and Commits as PrivateMessage and
// refuses those of other members sent as PublicMessage; otherwise they
// are sent as PublicMessage and both are accepted.
PrivateHandshakes bool
// Envelope wraps and checks the authenticated data of every
// PrivateMessage. Nil leaves it unchanged, as the RFC test vectors
// need, and then a member can replay another member's signed content
// under a later generation and use up that generation (RFC 9750 section
// 8.6); applications set one.
Envelope Envelope
}Config holds the parameters every operation of a group uses. For the bounds, zero means the default and a negative value no bound.
type CreateOptions
type CreateOptions struct {
Config
// GroupID is the new group's id; nil means 32 random bytes (RFC 9420
// section 11).
GroupID []byte
// KeyPackage is a KeyPackage of this client made by NewKeyPackage on the
// same Store; its leaf becomes the creator's leaf and Create deletes its
// private keys, as Join does, so no Join may use it at the same time.
KeyPackage []byte
// Extensions are the GroupContext extensions of epoch 0.
Extensions []Extension
}CreateOptions are the parameters of Create.
type Credential
type Credential = tree.CredentialCredential is an MLS Credential (RFC 9420 section 5.3): Type, with Identity for a basic or Kolo credential and Certificates for an x509 chain.
type Envelope
type Envelope interface {
// Wrap returns the authenticated data to send at generation gen for the
// application's aad.
Wrap(gen uint32, aad []byte) ([]byte, error)
// Unwrap checks the authenticated data of a PrivateMessage received at
// generation gen, before its key is consumed, and returns the
// application's aad.
Unwrap(gen uint32, authenticatedData []byte) ([]byte, error)
}Envelope binds the generation of a PrivateMessage into its signed authenticated data (RFC 9750 section 8.6: the signature does not cover the generation, so a member could re-encrypt another member's content under a new one).
type Event
type Event uint8Event names the moment a credential is checked (RFC 9420 section 5.3.1).
const (
// EventKeyPackage is a KeyPackage's leaf, checked before this member
// adds it or creates a group with it.
EventKeyPackage Event = iota + 1
// EventJoin is a leaf of the tree of a group this member joins.
EventJoin
// EventAdd is a leaf added by another member's Commit.
EventAdd
// EventUpdate is a leaf in an Update proposal.
EventUpdate
// EventCommitPath is the leaf of a Commit's UpdatePath.
EventCommitPath
)Credential events.
type Extension
type Extension = tls.ExtensionExtension is an MLS Extension (RFC 9420 section 13.4): Type and Data.
type Group
type Group struct {
// contains filtered or unexported fields
}Group is one member's view of an MLS group. It is not safe for concurrent use, and at most one Group per group id may be open on a Store; every change is one Store batch.
func Create
func Create(st Store, o CreateOptions) (*Group, error)Create starts a group with this member alone at epoch 0 (RFC 9420 section 11). Create of one group id must not run concurrently with another Create, Join or Open of it on the same Store, nor with a Create or Join that uses the same KeyPackage, or both may seed a group with it.
func Join
func Join(st Store, welcomeMsg, ratchetTree []byte, o JoinOptions) (*Group, error)Join processes a Welcome with this client's stored KeyPackage and joins the group (RFC 9420 section 12.4.3.1). ratchetTree is the encoded tree when the Welcome's GroupInfo does not carry it. Join of one group id must not run concurrently with another Create, Join or Open of it on the same Store, nor with a Create or Join that uses the same KeyPackage.
func Open
func Open(st Store, gid []byte, cfg Config) (*Group, error)Open loads group gid from st. Only one Group per group id may be open at a time; after a failed write, Open reads what the Store holds.
func (Group) Apply
func (g *Group) Apply(sc *StagedCommit) errorApply makes a staged Commit the current epoch in one Store batch that also deletes the old epoch and any pending Commit (RFC 9420 sections 9.2, 14). A Commit that removes this member deletes the group's records instead: Apply returns nil, Removed reports true and every later call returns ErrRemoved. A Commit that is not applied is discarded.
func (Group) ApplyPending
func (g *Group) ApplyPending() errorApplyPending makes this member's pending Commit the current epoch, once the Delivery Service has chosen it (RFC 9420 section 14).
func (Group) BranchPSK
func (g *Group) BranchPSK() (*PSKID, []byte, error)BranchPSK returns the id and value of the resumption PSK of the current epoch with usage branch and a fresh nonce, for the first Commit of a successor group and its joiners (RFC 9420 section 11.3).
func (Group) CachedProposals
func (g *Group) CachedProposals() [][]byteCachedProposals returns the references of the proposals cached in this epoch, this member's own included, in the order they arrived.
func (Group) Close
func (g *Group) Close()Close zeroes the secrets this Group holds in memory. Later calls that use a secret or change the group (Process, Apply, Commit, the Propose calls, Encrypt, Export, EpochAuthenticator, RatchetTree, ApplyPending, DiscardPending) return ErrClosed; GroupID, Epoch, OwnLeaf, GroupContext, Extensions and Tree, which hold no secret, keep returning the last epoch's values, CachedProposals is empty and Pending is nil.
func (Group) Commit
func (g *Group) Commit(o CommitOptions) (*PendingCommit, error)Commit creates a Commit of o and its Welcome (RFC 9420 section 12.4.1), stored apart until ApplyPending or DiscardPending; the group's state does not change.
func (Group) DiscardPending
func (g *Group) DiscardPending() errorDiscardPending deletes this member's pending Commit, when the Delivery Service chose another one (RFC 9420 section 14).
func (Group) Encrypt
func (g *Group) Encrypt(data, aad []byte) ([]byte, error)Encrypt protects application data as a PrivateMessage of the current epoch, with aad as its authenticated data (RFC 9420 section 6.3). It is refused while proposals are cached: a Commit comes first (RFC 9420 section 12.4).
func (Group) Epoch
func (g *Group) Epoch() uint64Epoch returns the current epoch.
func (Group) EpochAuthenticator
func (g *Group) EpochAuthenticator() ([]byte, error)EpochAuthenticator returns the epoch authenticator (RFC 9420 section 8.7).
func (Group) ExpirePastEpoch
func (g *Group) ExpirePastEpoch() (time.Time, error)ExpirePastEpoch deletes the previous epoch once its window has ended at Config.Now, and returns when the window of the one still kept ends, the zero time when none is kept. The library has no timers: the caller calls it again at that time.
func (Group) Export
func (g *Group) Export(label string, context []byte, length int) ([]byte, error)Export derives an exported secret (RFC 9420 section 8.5).
func (Group) Extensions
func (g *Group) Extensions() []ExtensionExtensions returns a copy of the GroupContext extensions of the current epoch.
func (Group) GroupContext
func (g *Group) GroupContext() []byteGroupContext returns the encoded GroupContext of the current epoch.
func (Group) GroupID
func (g *Group) GroupID() []byteGroupID returns the group id.
func (Group) OwnLeaf
func (g *Group) OwnLeaf() uint32OwnLeaf returns this member's leaf index.
func (Group) PeekSender
func (g *Group) PeekSender(msg []byte) (leaf, generation uint32, err error)PeekSender returns the sender's leaf and generation named in the sender data of a PrivateMessage of the current epoch, which uses up no key and proves nothing: anyone who holds the epoch's secrets can write it. Catch-up reads archived messages in this order.
func (Group) Pending
func (g *Group) Pending() *PendingCommitPending returns the stored pending Commit, nil when there is none.
func (Group) PendingLeaves
func (g *Group) PendingLeaves() []*LeafNodePendingLeaves returns copies of the leaves that the pending Commit adds or replaces, nil when there is no pending Commit.
func (Group) Process
func (g *Group) Process(msg []byte) (*Result, error)Process verifies a message of the current epoch: a proposal is cached, a Commit is staged and changes nothing until Apply, and application data is returned. A PrivateMessage uses up its key only once its signature and the Envelope accepted it, in the same Store batch as the proposal; a Commit's key is deleted with its epoch by Apply.
func (Group) ProposeAdd
func (g *Group) ProposeAdd(keyPackage []byte) ([]byte, error)ProposeAdd proposes to add the client of an encoded KeyPackage.
func (Group) ProposeGroupContextExtensions
func (g *Group) ProposeGroupContextExtensions(exts []Extension) ([]byte, error)ProposeGroupContextExtensions proposes to replace the GroupContext extensions.
func (Group) ProposePSK
func (g *Group) ProposePSK(id *PSKID) ([]byte, error)ProposePSK proposes to inject a pre-shared key; nonce nil means 32 random bytes (RFC 9420 section 12.1.4).
func (Group) ProposeRemove
func (g *Group) ProposeRemove(leaf uint32) ([]byte, error)ProposeRemove proposes to remove the member at leaf.
func (Group) ProposeUpdate
func (g *Group) ProposeUpdate(template *LeafNode) ([]byte, error)ProposeUpdate proposes to replace this member's leaf with a fresh encryption key; template, when not nil, gives a new credential, capabilities or extensions with the same signature key.
func (Group) RatchetTree
func (g *Group) RatchetTree() ([]byte, error)RatchetTree returns the encoded ratchet tree of the current epoch.
func (Group) Removed
func (g *Group) Removed() boolRemoved reports whether an applied Commit removed this member.
func (Group) Tree
func (g *Group) Tree() TreeViewTree returns a read-only view of the ratchet tree of the current epoch.
type GroupContext
type GroupContext = schedule.GroupContextGroupContext is the decoded GroupContext of an epoch (RFC 9420 section 8.1).
type JoinOptions
type JoinOptions struct {
Config
// MaxTreeBytes bounds the encoded ratchet tree, from the Welcome or
// given; zero means DefaultMaxTreeBytes and a negative value no bound.
MaxTreeBytes int
// Tree, when Join is given no tree and the Welcome carries none, returns
// the encoded ratchet tree; export derives a secret of the new epoch
// (RFC 9420 section 8.5), for a tree kept encrypted under it.
Tree func(export func(label string, context []byte, length int) ([]byte, error)) ([]byte, error)
}JoinOptions are the parameters of Join.
type JoinView
type JoinView struct {
// Context is the GroupContext of the group joined.
Context *GroupContext
// Tree is the group's tree.
Tree TreeView
// Signer is the leaf index of the member that signed the GroupInfo.
Signer uint32
// PSKs are the pre-shared keys of the Welcome.
PSKs []*PSKID
// InfoExtensions are the GroupInfo's extensions.
InfoExtensions []Extension
}JoinView is a group as the Policy sees it before a member joins it; every field is a copy or a read-only view.
type KV
type KV struct {
Key, Value []byte
}KV is one key and value of a Batch.
type KeyPackageOptions
type KeyPackageOptions struct {
// Credential is the client's credential.
Credential Credential
// SignatureKey signs the KeyPackage; its public key goes in the leaf.
SignatureKey ed25519.PrivateKey
// Capabilities of the leaf; version mls10, the cipher suite and the
// credential's type are added when missing.
Capabilities Capabilities
// LeafExtensions and Extensions are the leaf's and the KeyPackage's.
LeafExtensions []Extension
Extensions []Extension
// Lifetime is the time from now to the end of validity, which starts one
// hour before now; zero means DefaultKeyPackageLifetime.
Lifetime time.Duration
// Now gives the current time; nil means time.Now.
Now func() time.Time
}KeyPackageOptions are the parameters of NewKeyPackage.
type LeafNode
type LeafNode = tree.LeafNodeLeafNode is a member's leaf in the ratchet tree (RFC 9420 section 7.2).
type MemStore
type MemStore struct {
// contains filtered or unexported fields
}MemStore is a Store in memory, the reference for the Store contract and for tests; it copies every key and value, zeroes what it drops, and is safe for concurrent use.
func NewMemStore
func NewMemStore() *MemStoreNewMemStore returns an empty MemStore.
func (MemStore) Apply
func (s *MemStore) Apply(b Batch) errorApply applies the deletes, then the puts, of b; it refuses a batch with a key in both, which the Batch contract forbids.
func (MemStore) Clone
func (s *MemStore) Clone() *MemStoreClone returns a copy of s, as a disk image of it would hold.
func (MemStore) Get
func (s *MemStore) Get(key []byte) ([]byte, error)Get returns a copy of the value of key, or ErrNotFound.
type PSKID
type PSKID = schedule.PSKIDPSKID is a PreSharedKeyID (RFC 9420 section 8.4): ID for an external PSK; Usage, GroupID and Epoch for a resumption PSK.
type PSKStore
type PSKStore interface {
// PSK returns a copy of the value of id, which the caller owns and
// zeroes, or ErrNotFound.
PSK(id *PSKID) ([]byte, error)
}PSKStore holds the external and resumption pre-shared keys the application provides.
type PendingCommit
type PendingCommit struct {
// contains filtered or unexported fields
}PendingCommit is this member's Commit, stored apart from the group's state until ApplyPending or DiscardPending (RFC 9420 section 14).
func (PendingCommit) Commit
func (pc *PendingCommit) Commit() []byteCommit returns the Commit as an encoded MLSMessage.
func (PendingCommit) GroupContext
func (pc *PendingCommit) GroupContext() []byteGroupContext returns the encoded GroupContext of the epoch the Commit starts.
func (PendingCommit) RatchetTree
func (pc *PendingCommit) RatchetTree() ([]byte, error)RatchetTree returns the encoded ratchet tree of the epoch the Commit starts, for a Welcome whose tree goes out of band (RFC 9420 section 12.4.3.3).
func (PendingCommit) Welcome
func (pc *PendingCommit) Welcome() []byteWelcome returns the Welcome for the added members as an encoded MLSMessage, nil when the Commit adds nobody.
type Policy
type Policy interface {
// CheckProposal decides whether a received proposal is cached.
CheckProposal(v ProposalView) error
// CheckCommit decides whether a Commit is acceptable.
CheckCommit(v CommitView) error
// CheckJoin decides whether a Welcome is accepted, including the
// membership checks of a branch (RFC 9420 section 12.4.3.1).
CheckJoin(v JoinView) error
}Policy holds the application's rules on top of RFC 9420 (section 12.2: "An application may extend the above procedure by additional rules"). Like the Authenticator, it must decide the same way on every member.
type Proposal
type Proposal = message.ProposalProposal is a decoded proposal (RFC 9420 section 12.1); the field of its Type is set.
type ProposalView
type ProposalView struct {
// Sender is the leaf index of the proposer.
Sender uint32
// SenderLeaf is the proposer's current leaf.
SenderLeaf *LeafNode
// Proposal is the proposal itself.
Proposal *Proposal
// ByReference is set for a proposal a Commit includes by reference.
ByReference bool
// Cached is the number of proposals already cached in the epoch, so a
// Policy can bound the cache; it is zero inside a CommitView.
Cached int
// Tree is the tree of the epoch the proposal is sent in.
Tree TreeView
// FromSender is the number of proposals of the same sender already
// cached; zero inside a CommitView.
FromSender int
// Extensions are the GroupContext extensions of the epoch.
Extensions []Extension
}ProposalView is a proposal as the Policy sees it; every field is a copy.
type Result
type Result struct {
// Epoch is the epoch of the message: the current one, or the previous
// one for a late application message read inside the window.
Epoch uint64
// Sender is the leaf index of the sender.
Sender uint32
// ProposalRef is the reference of a proposal now cached.
ProposalRef []byte
// Commit is a Commit ready to Apply.
Commit *StagedCommit
// Application is the data of an application message.
Application []byte
// AuthenticatedData is the authenticated data of an application
// message, as the Envelope returns it when one is set.
AuthenticatedData []byte
}Result is what Process found in a message: a cached proposal, a staged Commit or application data.
type StagedCommit
type StagedCommit struct {
// contains filtered or unexported fields
}StagedCommit is another member's verified Commit; nothing changes until Apply (RFC 9420 section 14).
func (StagedCommit) Added
func (sc *StagedCommit) Added() []uint32Added returns the leaf indices the Commit adds.
func (StagedCommit) Committer
func (sc *StagedCommit) Committer() uint32Committer returns the committer's leaf index.
func (StagedCommit) Discard
func (sc *StagedCommit) Discard()Discard zeroes the secrets of a Commit that will not be applied.
func (StagedCommit) Extensions
func (sc *StagedCommit) Extensions() []ExtensionExtensions returns the GroupContext extensions of the new epoch, also when the Commit removes this member.
func (StagedCommit) GroupContext
func (sc *StagedCommit) GroupContext() []byteGroupContext returns the encoded GroupContext of the new epoch, nil when this member is removed.
func (StagedCommit) Leaves
func (sc *StagedCommit) Leaves() []*LeafNodeLeaves returns copies of the leaves of the new tree that the Commit adds or replaces, nil when it removes this member.
func (StagedCommit) Removed
func (sc *StagedCommit) Removed() []uint32Removed returns the leaf indices the Commit removes, in increasing order.
func (StagedCommit) RemovesSelf
func (sc *StagedCommit) RemovesSelf() boolRemovesSelf reports whether the Commit removes this member.
type Store
type Store interface {
// Get returns a copy of the value of key, which the caller owns, or
// ErrNotFound.
Get(key []byte) ([]byte, error)
// Apply writes b atomically and durably and keeps none of its slices:
// the library zeroes the values after Apply returns.
Apply(b Batch) error
}Store persists the state of groups and KeyPackages. Every consumed secret is deleted in the same write that records the advance (RFC 9420 section 9.2).
Apply must be atomic and durable: all of a batch or nothing. An error from Apply may still mean the batch was written (an acknowledgement lost), so a Group whose write failed refuses every later call, and the caller opens the group again to read what the Store holds. After a failed Create or Join, the caller opens the group id to learn whether it exists.
A Store serves several groups and goroutines and must be safe for concurrent use (MemStore is). At most one Group may be open per group id, since two would write diverging secret trees, and Create, Join and Open of one group id, or Create and Join that use one KeyPackage, must not run concurrently on one Store.
type TreeView
type TreeView struct {
// contains filtered or unexported fields
}TreeView reads a ratchet tree without changing it.
func (TreeView) Leaf
func (v TreeView) Leaf(l uint32) *LeafNodeLeaf returns a copy of the leaf at index l, nil when it is blank or past the tree.
func (TreeView) Members
func (v TreeView) Members() []uint32Members returns the indices of the non-blank leaves in increasing order.
Package cred
Package cred is the Kolo credential of an MLS leaf: credential type 0xF001 with a kolo-id device certificate and the device's signature over the leaf's MLS signature key, and the Authenticator that checks it (RFC 9420 section 5.3).
Constants
const DefaultMaxCached = 1 << 19DefaultMaxCached is the default bound on the client ids an Authenticator caches: more than the leaves of the largest tree a joiner accepts by default (kolomls.DefaultMaxTreeBytes over the smallest Kolo leaf, measured by TestCacheBound).
const LeafKeyContext = "kolo-mls/leaf-key/v0"LeafKeyContext is the context of the device's signature over a leaf's MLS signature key.
const MaxBody = 1 + 2 + maxCert + ed25519.SignatureSizeMaxBody is the largest credential body: version, the certificate with its length and the signature.
const Type = tree.CredentialKoloDeviceType is the credential type 0xF001 of a Kolo device, from the private-use range of RFC 9420 section 17.5.
Variables
var ErrCredential = errors.New("kolomls: invalid Kolo credential")ErrCredential reports a Kolo credential that does not decode or verify; kolo-id's errors are wrapped.
Functions
func Binding
func Binding(signatureKey []byte, cert *koloid.DeviceCert) []byteBinding returns the bytes the device signs for a leaf: the version, the cipher suite, the MLS signature key and the hash of the certificate, so a signature cannot move to another certificate of the same device key.
func New
func New(device *koloid.Identity, cert *koloid.DeviceCert, signatureKey ed25519.PublicKey) (kolomls.Credential, error)New returns the credential of device, certified by cert, for a leaf with signatureKey, signed by the device key.
func Revoked
func Revoked(c kolomls.Credential, revs []*koloid.Revocation) errorRevoked returns an error wrapping koloid.ErrCertRevoked when one of revs covers the certificate chain of c, nil otherwise; it does not check expiry. Settlers call it with the revocations at a settled position, so they decide alike (RFC 9750 section 6.5).
Types
type Authenticator
type Authenticator struct {
// Expect is the application's check of the person and device a leaf
// presents (the reference identifier of RFC 9420 section 5.3.1); nil
// accepts any person. It must answer the same on every member.
Expect func(person, device ed25519.PublicKey, ev kolomls.Event) error
// Revocations returns the revocations held for device of person, checked
// when this member adds a KeyPackage (kolomls.EventKeyPackage); nil holds
// none. Receivers do not check them in Validate, so that every member
// decides alike; see Revoked.
Revocations func(person, device ed25519.PublicKey) []*koloid.Revocation
// Now is the clock of the expiry check when this member adds a
// KeyPackage; required for that check.
Now func() time.Time
// MaxCached bounds the client ids kept; zero means DefaultMaxCached. The
// cache is emptied when it is full.
MaxCached int
// contains filtered or unexported fields
}Authenticator checks Kolo credentials for the core (RFC 9420 section 5.3.1). Its fields are set before first use; it is safe for concurrent use.
func (Authenticator) ClientID
func (a *Authenticator) ClientID(c kolomls.Credential) ([]byte, error)ClientID returns the device key: two leaves of one device are the same client.
func (Authenticator) Successor
func (a *Authenticator) Successor(prev, next kolomls.Credential) errorSuccessor checks that next keeps the person and the device of prev; the certificate and the MLS signature key may change (RFC 9420 section 5.3.1).
func (Authenticator) Validate
func (a *Authenticator) Validate(c kolomls.Credential, signatureKey []byte, ev kolomls.Event) errorValidate checks that c is a Kolo credential of a valid certificate chain whose device signed signatureKey for this cipher suite, and asks Expect.
type Credential
type Credential struct {
// Cert is the device certificate; trusted only after Validate.
Cert *koloid.DeviceCert
// Signature is the device's signature over the binding.
Signature []byte
}Credential is a decoded Kolo credential.
func Decode
func Decode(c kolomls.Credential) (*Credential, error)Decode decodes a Kolo credential, checking its structure but no signature.
func (Credential) Device
func (c *Credential) Device() ed25519.PublicKeyDevice returns the certified device key, nil without a certificate.
func (Credential) Encode
func (c *Credential) Encode() kolomls.CredentialEncode returns c as an MLS Credential, an empty one without a certificate.
func (Credential) Person
func (c *Credential) Person() ed25519.PublicKeyPerson returns the person key the certificate names, an unverified claim; nil without a certificate.
Package settle
Package settle holds the Kolo rules every member device of a Kolo group needs: the roles extension, the commit Policy, the authenticated data envelope, the settled-commit signatures and the decision of each epoch's Commit over the settled order of the admins' braid.
Constants
const (
DefaultMaxBufferedBytes = 16 << 20
DefaultMaxCatchUpBytes = 16 << 20
DefaultMaxCommitBytes = kolomls.DefaultMaxTreeBytes
)Default bounds of a Member: 16 MiB, the bound the admins' braid puts on entries that wait for an earlier one; a Commit at most the tree bound, since the KeyPackages it adds become the tree's leaves.
const RolesExtension uint16 = 0xF002RolesExtension is the GroupContext extension type of the roles, from the private-use range of RFC 9420 section 17.3.
const SettledContext = "kolo-mls/commit-settled/v0"SettledContext is the context of a settler's signature over a decided Commit.
Variables
var (
// ErrBuffered reports a message of the next epoch, kept until the
// Commit that starts that epoch is applied.
ErrBuffered = errors.New("kolomls: message of the next epoch kept for later")
// ErrRevokedSender reports an application message of a leaf whose
// certificate this device holds a revocation for; it is dropped.
ErrRevokedSender = errors.New("kolomls: message of a revoked device dropped")
// ErrHalted reports a Member that stopped on an equivocation; it stays
// stopped after it is opened again.
ErrHalted = errors.New("kolomls: member halted")
// ErrCatchUp reports archived messages of an epoch that catch-up could
// not read: a value past the bound, one that does not match its key or
// does not open, or a listing that pins got wrong. The epoch is still
// applied.
ErrCatchUp = errors.New("kolomls: epoch archive refused")
// ErrNotHeld reports a leave request received by a device that is not
// an admin; it is dropped, as only admins commit it.
ErrNotHeld = errors.New("kolomls: leave requests are held by admins only")
)var (
// ErrMissing reports a value that Pins does not hold.
ErrMissing = errors.New("kolomls: not on pins")
// ErrPinTooLarge reports a value on pins past the bound asked for.
ErrPinTooLarge = errors.New("kolomls: pinned data past the bound")
)var (
// ErrNotSettled reports a SettledCommit that does not settle the Commit
// given in this member's epoch: malformed, for another group, epoch,
// context or Commit, or with fewer than q valid settler signatures.
ErrNotSettled = errors.New("kolomls: commit not settled")
// ErrSettledMismatch reports a settled Commit that this member cannot
// follow: it fails MLS processing or leads to another GroupContext than
// the settlers signed. The member keeps its state.
ErrSettledMismatch = errors.New("kolomls: settled commit does not match")
// ErrEquivocation reports two settled Commits for one epoch.
ErrEquivocation = errors.New("kolomls: two settled commits for one epoch")
)var ErrEnvelope = errors.New("kolomls: invalid authenticated data envelope")ErrEnvelope reports authenticated data that is not a Kolo envelope of the message's generation.
var ErrRoles = errors.New("kolomls: invalid roles extension")ErrRoles reports a roles extension that does not decode or breaks a rule.
var ErrRule = errors.New("kolomls: Kolo group rule")ErrRule reports a proposal, Commit or Welcome that breaks a rule of Kolo groups (RFC 9420 section 12.2: "An application may extend the above procedure by additional rules").
var ErrSealedTree = errors.New("kolomls: encrypted tree does not open")ErrSealedTree reports an encrypted tree that does not open.
Functions
func ArchiveKey
func ArchiveKey(gid []byte, epoch uint64, msg []byte) stringArchiveKey is the key of an archived message of epoch of group gid.
func ArchivePrefix
func ArchivePrefix(gid []byte, epoch uint64) stringArchivePrefix is the prefix of the archived messages of epoch of group gid: the messages sent in it.
func Capabilities
func Capabilities() kolomls.CapabilitiesCapabilities returns the capabilities every Kolo leaf lists besides the version and the cipher suite.
func GetObject
func GetObject(ctx context.Context, p Pins, h [32]byte, max int) ([]byte, error)GetObject returns the MLSMessage with SHA-256 h, at most max bytes, from pins, checking the hash.
func GroupExtensions
func GroupExtensions(r *Roles) ([]kolomls.Extension, error)GroupExtensions returns the GroupContext extensions of a Kolo group: required_capabilities naming the Kolo credential and the roles extension (RFC 9420 section 11.1), and the roles.
func NewConfig
func NewConfig(a *cred.Authenticator, p *Policy, now func() time.Time) kolomls.ConfigNewConfig returns the configuration of a Kolo group with a and p: the Kolo credential and Policy, handshakes as PrivateMessage, the envelope, and the clock now, which the Kolo layer requires.
func ObjectKey
func ObjectKey(h [32]byte) stringObjectKey is the key of a Commit MLSMessage with SHA-256 h.
func OpenTree
func OpenTree(export func(label string, context []byte, length int) ([]byte, error), gid []byte, epoch uint64, sealed []byte) ([]byte, error)OpenTree decrypts a tree sealed by SealTree for epoch of group gid with the exporter of that epoch.
func PutObject
func PutObject(ctx context.Context, p Pins, msg []byte) ([32]byte, error)PutObject keeps an MLSMessage under its hash and returns the hash.
func Seal
func Seal(export func(label string, context []byte, length int) ([]byte, error), gid []byte, epoch uint64, sealer [32]byte, tree []byte) ([]byte, error)Seal is SealTree for a tree of epoch of group gid, sealed by device sealer with the epoch's exporter.
func SealTree
func SealTree(m *Member) ([]byte, error)SealTree returns the ratchet tree of m's epoch encrypted with AES-128-GCM (docs/design.md, "The Kolo layer"): the key and nonce are exported from the epoch (RFC 9420 section 8.5) for this sealer's device key, which leads the result, and the group id and epoch are the additional data. Two sealers never share a key, so a sealer that seals another tree reuses only its own nonce.
func SettledKey
func SettledKey(gid []byte, epoch uint64) stringSettledKey is the key of the SettledCommit of epoch of group gid.
func TreeKey
func TreeKey(gid []byte, epoch uint64) stringTreeKey is the key of the encrypted ratchet tree of epoch of group gid.
Types
type BranchPSK
type BranchPSK struct {
GroupID []byte
Epoch uint64
Value []byte
// contains filtered or unexported fields
}BranchPSK serves the resumption PSK of a group's last epoch, with usage branch, to the first Commit of its successor group and to its joiners (RFC 9420 section 11.3).
func (BranchPSK) ID
func (b *BranchPSK) ID() *kolomls.PSKIDID returns the PSK id with its nonce, for the successor's first Commit; nil for a BranchPSK not made by Member.BranchPSK.
func (BranchPSK) PSK
func (b *BranchPSK) PSK(id *kolomls.PSKID) ([]byte, error)PSK returns a copy of the value for the branch PSK of GroupID and Epoch.
type Envelope
type Envelope struct{}Envelope binds the generation of every PrivateMessage into its signed authenticated data: uvarint version 0, uvarint generation, bytes(aad) (RFC 9750 section 8.6: a member cannot replay another member's content under a new generation).
func (Envelope) Unwrap
func (Envelope) Unwrap(gen uint32, ad []byte) ([]byte, error)Unwrap checks that ad is the envelope of generation gen and returns the application's aad.
func (Envelope) Wrap
func (Envelope) Wrap(gen uint32, aad []byte) ([]byte, error)Wrap returns the authenticated data of generation gen for aad.
type Limits
type Limits struct {
MaxAdmins, MaxSettlers int
}Limits cap what a roles extension may hold; zero or less is no cap, and then only the size of the extension bounds the counts.
type Member
type Member struct {
// contains filtered or unexported fields
}Member is one device's side of a Kolo group: it applies only settled Commits (docs/design.md, "The Kolo layer"). It is not safe for concurrent use.
func CreateMember
func CreateMember(st kolomls.Store, co kolomls.CreateOptions, mo MemberOptions) (*Member, error)CreateMember creates a Kolo group; co.KeyPackage is made on st and co.Extensions must be GroupExtensions of the group's roles.
func JoinMember
func JoinMember(st kolomls.Store, welcome, settled []byte, sealedTree func(gid []byte, epoch uint64, max int) ([]byte, error), o kolomls.JoinOptions, mo MemberOptions) (*Member, error)JoinMember joins with a Welcome and the SettledCommit of its Commit; sealedTree returns the epoch's encrypted tree (SealTree).
func OpenMember
func OpenMember(st kolomls.Store, gid []byte, cfg kolomls.Config, o MemberOptions) (*Member, error)OpenMember opens the stored group gid with a configuration made by NewConfig; a Member that halted is refused with ErrHalted.
func (Member) AppliedLeaves
func (m *Member) AppliedLeaves() []*kolomls.LeafNodeAppliedLeaves returns copies of the leaves that the Commit this Member applied last added or replaced, with their credentials and signature keys; it is nil before the first Commit and when that Commit removed this device. A Commit is a PrivateMessage, so these leaves can be read only while their epoch is the current one (in OnEpoch or right after ApplySettled) and are not kept across OpenMember.
func (Member) ApplySettled
func (m *Member) ApplySettled(settled, commit []byte) ([]*kolomls.Result, error)ApplySettled applies the Commit that settled names for the current epoch (docs/design.md, "The Kolo layer") and returns the kept messages of the new epoch, now read.
func (Member) BranchPSK
func (m *Member) BranchPSK() (*BranchPSK, error)BranchPSK returns the branch PSK of the current epoch for a successor group (RFC 9420 section 11.3).
func (Member) CatchUp
func (m *Member) CatchUp(ctx context.Context, pins Pins) ([]*kolomls.Result, error)CatchUp applies, one epoch at a time, the settled Commits pins hold after the current epoch, reading each epoch's archive before its Commit, each sender's messages in order; archived messages it could not read are reported with ErrCatchUp at the end. MemberOptions.OnEpoch is called after each epoch.
func (Member) Close
func (m *Member) Close()Close closes the group.
func (Member) Commit
func (m *Member) Commit(o kolomls.CommitOptions) (*kolomls.PendingCommit, error)Commit makes a pending Commit of o; Kolo Welcomes never carry the tree.
func (Member) Device
func (m *Member) Device() ([32]byte, error)Device returns this device's key, as its own leaf names it.
func (Member) DiscardPending
func (m *Member) DiscardPending() errorDiscardPending drops this device's pending Commit.
func (Member) Encrypt
func (m *Member) Encrypt(data, aad []byte) ([]byte, error)Encrypt protects application data for the current epoch.
func (Member) Epoch
func (m *Member) Epoch() uint64Epoch returns the current epoch.
func (Member) EpochAuthenticator
func (m *Member) EpochAuthenticator() ([]byte, error)EpochAuthenticator returns the epoch authenticator (RFC 9420 section 8.7).
func (Member) ExpirePastEpoch
func (m *Member) ExpirePastEpoch() (time.Time, error)ExpirePastEpoch deletes the previous epoch once its window ended and returns when the window still kept ends, the zero time when none is; the caller calls it again then.
func (Member) Export
func (m *Member) Export(label string, context []byte, length int) ([]byte, error)Export derives an exported secret (RFC 9420 section 8.5).
func (Member) Extensions
func (m *Member) Extensions() []kolomls.ExtensionExtensions returns the GroupContext extensions of the current epoch.
func (Member) GroupContext
func (m *Member) GroupContext() []byteGroupContext returns the encoded GroupContext of the current epoch.
func (Member) GroupID
func (m *Member) GroupID() []byteGroupID returns the group id.
func (Member) Halted
func (m *Member) Halted() errorHalted returns the error that stopped this Member for good, nil while it runs.
func (Member) Leave
func (m *Member) Leave() ([]byte, error)Leave returns this device's proposal to remove itself; an admin commits the removal by value.
func (Member) Limits
func (m *Member) Limits() LimitsLimits returns the roles bounds of the group's Policy.
func (Member) MaxCommitBytes
func (m *Member) MaxCommitBytes() intMaxCommitBytes returns the bound on a Commit read from pins.
func (Member) OwnLeaf
func (m *Member) OwnLeaf() uint32OwnLeaf returns this device's leaf index.
func (Member) Pending
func (m *Member) Pending() *kolomls.PendingCommitPending returns this device's pending Commit, nil when there is none.
func (Member) PendingLeaves
func (m *Member) PendingLeaves() []*kolomls.LeafNodePendingLeaves returns the leaves that this device's pending Commit adds or replaces.
func (Member) Receive
func (m *Member) Receive(msg []byte) (*kolomls.Result, error)Receive processes an application message or a proposal. A message of the next epoch is kept (ErrBuffered) until ApplySettled starts that epoch; a Commit is refused.
func (Member) Removed
func (m *Member) Removed() boolRemoved reports whether a settled Commit removed this device.
func (Member) RevokedLeaves
func (m *Member) RevokedLeaves() []uint32RevokedLeaves returns the leaves this device holds a revocation for, so the application asks an admin to commit their removal.
func (Member) SelfUpdate
func (m *Member) SelfUpdate() ([]byte, error)SelfUpdate makes this device's key update, an empty Commit with a path, kept pending until a settled Commit decides the epoch; an admin references it with Admin.Refer.
func (Member) Stage
func (m *Member) Stage(commit []byte) (*kolomls.StagedCommit, error)Stage processes a Commit without applying it, for a settler's check; the caller discards the result.
func (Member) Store
func (m *Member) Store() kolomls.StoreStore returns the Store the group lives in.
func (Member) Tree
func (m *Member) Tree() kolomls.TreeViewTree returns a read-only view of the current tree.
type MemberOptions
type MemberOptions struct {
// MaxBufferedBytes bounds the next-epoch messages kept, the oldest
// dropped first; zero means DefaultMaxBufferedBytes and a negative value
// keeps none.
MaxBufferedBytes int
// MaxCatchUpBytes bounds the memory that reading one epoch's archive
// holds, not the epoch: it sets the keys listed and indexed at a time
// (the bytes of a key and of its index entry, at least one) and the
// size of one message, and an epoch with more messages is read in
// several passes. The Results CatchUp returns are not counted. Zero
// means DefaultMaxCatchUpBytes and a negative value no bound.
MaxCatchUpBytes int
// OnEpoch is called by CatchUp after each epoch it applies, with the
// Member in the new epoch, so the caller can read what only that epoch
// holds (Export, EpochAuthenticator). An error stops CatchUp and is
// returned wrapped. It is not called for the epoch that removes this
// device, and it must not call CatchUp or ApplySettled. Nil does nothing.
OnEpoch func(*Member) error
// MaxCommitBytes bounds a Commit read from pins; zero means
// DefaultMaxCommitBytes and a negative value no bound.
MaxCommitBytes int
// Revocations returns the revocations this device holds for device of
// person: messages of such leaves are dropped and RevokedLeaves lists
// them; settled Commits are still applied (RFC 9750 section 6.5).
Revocations func(person, device ed25519.PublicKey) []*koloid.Revocation
}MemberOptions are a Member's choices.
type Pins
type Pins interface {
// Put keeps value under key.
Put(ctx context.Context, key string, value []byte) error
// Get returns the value of key, an error wrapping ErrMissing when there
// is none, or one wrapping ErrPinTooLarge, before more than max bytes
// are read, when it is longer than max; max 0 or less is no bound.
Get(ctx context.Context, key string, max int) ([]byte, error)
// List returns the first max keys that start with prefix and sort after
// the key after (all of them when after is empty), in increasing order;
// max 0 or less is no bound. A caller reads on from the last key it got
// until an empty list.
List(ctx context.Context, prefix, after string, max int) ([]string, error)
// Delete removes key; a key that is not there is not an error.
Delete(ctx context.Context, key string) error
}Pins keeps what a Kolo group's devices fetch while they catch up: Commits by hash, SettledCommits by epoch and each epoch's archived messages for the life of the group, and encrypted trees by epoch while the latest or a Welcome that is not used yet names them (braid.Admin).
type Policy
type Policy struct {
// Limits bound the roles extension; the Member and the Admin of the
// group use these.
Limits Limits
// Predecessor, when set, allows joining a successor group of it with a
// branch PSK; nil refuses every branch.
Predecessor *Predecessor
// contains filtered or unexported fields
}Policy is the commit rule of Kolo groups (docs/design.md, "The Kolo layer"); NewConfig puts it in a group's Config. One Policy serves one group.
func (Policy) CheckCommit
func (p *Policy) CheckCommit(v kolomls.CommitView) errorCheckCommit applies the commit rule.
func (Policy) CheckJoin
func (p *Policy) CheckJoin(v kolomls.JoinView) errorCheckJoin checks a Welcome's SettledCommit and extensions, and allows a branch PSK only for a successor of Predecessor.
func (Policy) CheckProposal
func (p *Policy) CheckProposal(v kolomls.ProposalView) errorCheckProposal accepts only a member's own Remove, at most one cached per member, and only at admins, which commit the removal by value.
type Predecessor
type Predecessor struct {
// GroupID and Epoch name the old group's last epoch.
GroupID []byte
Epoch uint64
// Devices are the device keys of the old group's leaves.
Devices map[[32]byte]bool
// Roles are the old group's roles in that epoch.
Roles *Roles
// Braid is the group id of the successor braid; zero, for a device that
// is not in the braid, is not checked.
Braid [32]byte
// Revocations returns the revocations this device holds for device of
// person; a creator they cover is refused. Nil holds none.
Revocations func(person, device ed25519.PublicKey) []*koloid.Revocation
}Predecessor describes the group a successor group branches from (RFC 9420 section 11.3), as a member of it saw its last epoch.
func PredecessorOf
func PredecessorOf(m *Member, braid [32]byte) (*Predecessor, error)PredecessorOf describes m's current epoch for a successor group whose braid is braid. Set it in a Policy only once the old group's settler quorum is known to be lost for good.
type Quorum
type Quorum uint8Quorum is the rule that sets how many settlers must agree.
const (
// Majority needs floor(s/2) + 1 of s settlers.
Majority Quorum = 1
// TwoThirds needs floor(2s/3) + 1 of s settlers.
TwoThirds Quorum = 2
)Quorum rules, as the braid's.
type Roles
type Roles struct {
// Braid is the group id of the admins' braid.
Braid [32]byte
// Quorum is the settlers' quorum rule.
Quorum Quorum
// Admins and Settlers are device keys in strictly increasing order;
// Settlers is a non-empty subset of Admins.
Admins, Settlers [][32]byte
}Roles names the group's braid, its admin devices and its settler devices.
func DecodeRoles
func DecodeRoles(b []byte, l Limits) (*Roles, error)DecodeRoles decodes and checks the data of a roles extension.
func NewRoles
func NewRoles(braid [32]byte, q Quorum, admins, settlers []ed25519.PublicKey, l Limits) (*Roles, error)NewRoles returns the roles of a braid with admins and settlers in any order, checked as DecodeRoles checks them.
func RolesOf
func RolesOf(exts []kolomls.Extension, l Limits) (*Roles, error)RolesOf returns the roles extension of a GroupContext extension list.
func (Roles) Admin
func (r *Roles) Admin(device []byte) boolAdmin reports whether device is an admin.
func (Roles) Encode
func (r *Roles) Encode() []byteEncode returns the extension data of r.
func (Roles) Extension
func (r *Roles) Extension() kolomls.ExtensionExtension returns r as a GroupContext extension.
func (Roles) Q
func (r *Roles) Q() intQ returns how many settlers a settled Commit needs.
func (Roles) RejectQuorum
func (r *Roles) RejectQuorum() intRejectQuorum returns how many reject votes decide a reference: s - q + 1, so that one of the two outcomes is always reachable by s honest votes.
func (Roles) Settler
func (r *Roles) Settler(device []byte) boolSettler reports whether device is a settler.
type Settled
type Settled struct {
TBS TBS
Shares []Share
}Settled is a SettledCommit: the TBS and the settlers' signatures, signers in strictly increasing order.
func DecodeSettled
func DecodeSettled(b []byte, maxShares int) (*Settled, error)DecodeSettled decodes a SettledCommit with at most maxShares signatures, the settlers of the group; zero or less leaves only the size of b as the bound.
func (Settled) Check
func (s *Settled) Check(context, commit []byte, gid []byte, epoch uint64, roles *Roles, member func(device [32]byte) bool) errorCheck verifies that s settles commit in the epoch with the encoded GroupContext context and roles (docs/design.md, "The Kolo layer").
func (Settled) Encode
func (s *Settled) Encode() []byteEncode returns the SettledCommit that admins put on pins and gossip.
func (Settled) Valid
func (s *Settled) Valid(roles *Roles, member func(device [32]byte) bool) intValid returns the number of distinct settlers of roles whose signature verifies and that member reports as the device of a current leaf; signatures of other keys and invalid ones do not count.
type TBS
type TBS struct {
// GroupID and Epoch name the epoch the Commit was sent in.
GroupID []byte
Epoch uint64
// Commit is the SHA-256 of the Commit's MLSMessage.
Commit [32]byte
// ContextBefore and ContextAfter are the SHA-256 of the encoded
// GroupContext of the epoch and of the next one.
ContextBefore, ContextAfter [32]byte
// Braid is the group id of the admins' braid.
Braid [32]byte
// RefPosition is the settled position of the Commit's reference.
RefPosition uint64
}TBS is what each settler signs for the decided Commit of an epoch.
func DecodeTBS
func DecodeTBS(b []byte) (*TBS, error)DecodeTBS decodes the bytes a settler signs.
func (TBS) Encode
func (t *TBS) Encode() []byteEncode returns the bytes a settler signs.
Package braid
Package braid is the admin side of a Kolo group over the admins' braid: references, votes and signature shares, the decision of each epoch's Commit, tree serving and the successor group.
Constants
const DefaultFetchTimeout = 60 * time.SecondDefaultFetchTimeout is how long a settler waits for a candidate Commit on pins before it votes reject: 60 s, the message timeout of the stream layer the braid syncs on.
Variables
var (
// ErrRoster reports a roles change that does not match the braid's
// settled admins, settlers and quorum.
ErrRoster = errors.New("kolomls: roles do not match the braid")
// ErrNotApproved reports a roles change that adds a settler, changes
// the quorum rule or drops a device that is not revoked, without the
// application's approval.
ErrNotApproved = errors.New("kolomls: roles change not approved")
// ErrDecision reports a settled order whose decision is not the one
// this settler signed for the epoch.
ErrDecision = errors.New("kolomls: decision differs from the signed one")
)var ErrEntry = errors.New("kolomls: invalid braid entry")ErrEntry reports a braid entry body of kolo-mls that does not decode.
Functions
func Assemble
func Assemble(t *settle.TBS, shares []settle.Share, roles *settle.Roles) *settle.SettledAssemble returns the SettledCommit of t from shares, keeping one valid share per settler of roles, in signer order.
func Sign
func Sign(id *koloid.Identity, t *settle.TBS) ([]byte, error)Sign returns a settler's signature over t with its device identity.
Types
type Admin
type Admin struct {
// contains filtered or unexported fields
}Admin runs an admin device of a Kolo group over the admins' braid (docs/design.md, "The Kolo layer"). It is not safe for concurrent use.
func NewAdmin
func NewAdmin(id *koloid.Identity, b Order, m *settle.Member, o Options) (*Admin, error)NewAdmin runs the admin device id, the device of m's own leaf, over b; votes and shares are recorded in m's Store before they are written.
func (Admin) Commit
func (a *Admin) Commit(ctx context.Context, o kolomls.CommitOptions) ([]byte, error)Commit creates this admin's Commit of o, keeps it on pins and writes its reference. It returns the Welcome of the members it adds, to deliver with the SettledCommit once pins hold one for this Commit (RFC 9750 section 5.2.3). A failed write keeps the Commit pending: call Reference again.
func (Admin) Evidence
func (a *Admin) Evidence() [][32]byteEvidence returns the settlers this admin saw vote twice on one Commit or sign two TBS for one epoch, in key order.
func (Admin) Member
func (a *Admin) Member() *settle.MemberMember returns the admin's Member.
func (Admin) NextDeadline
func (a *Admin) NextDeadline() (time.Time, error)NextDeadline returns when the candidate this settler waits for on pins times out, the zero time when it waits for none; the caller calls Step then, also on an idle braid.
func (Admin) Refer
func (a *Admin) Refer(ctx context.Context, commit []byte) errorRefer keeps a member's own key update, an empty Commit with a path of the current epoch, on pins and writes its reference.
func (Admin) Reference
func (a *Admin) Reference(ctx context.Context) errorReference writes the reference of this admin's pending Commit again; a second reference to one Commit counts once. A Commit that adds members first marks its Welcome as unused on pins, which keeps the tree it names there (ReleaseWelcome).
func (Admin) ReleaseWelcome
func (a *Admin) ReleaseWelcome(ctx context.Context, epoch uint64) errorReleaseWelcome reports that the Welcome of this admin's Commit sent in epoch is used or will not be: the tree it names leaves pins unless it is the latest or another admin's unused Welcome names it. Call it for a Commit that was not decided too.
func (Admin) Step
func (a *Admin) Step(ctx context.Context) (*Applied, error)Step does what the braid's settled order asks of this admin in the current epoch (vote, sign, assemble and apply) and returns the change once applied. After an epoch change it keeps the new tree on pins and drops the previous one; if only that drop failed it returns the change with the error.
func (Admin) Succeed
func (a *Admin) Succeed(ctx context.Context, nb Order, st kolomls.Store, so SucceedOptions) (*Admin, []byte, error)Succeed starts the successor of a's group once its settlers are lost for good (RFC 9420 section 11.3), under nb with this admin as its only admin and settler, on st. It returns the new Admin, whose Step settles the first Commit, and that Commit's Welcome.
type Applied
type Applied struct {
// Epoch is the epoch the Commit was sent in.
Epoch uint64
// Settled and Commit are what members apply with ApplySettled.
Settled, Commit []byte
// Results are the kept messages of the new epoch, now read.
Results []*kolomls.Result
}Applied is the epoch change an Admin made.
type BraidOrder
type BraidOrder struct {
// contains filtered or unexported fields
}BraidOrder is the Order of a kolo-braid braid whose apply function feeds an Index, with the devices roster in the same view.
func NewBraidOrder
func NewBraidOrder(b *kolobraid.Braid, idx *Index, roster *devices.Store) *BraidOrderNewBraidOrder returns the Order of b; b and idx are required, roster nil holds no revocation.
func (BraidOrder) Append
func (o *BraidOrder) Append(ctx context.Context, body []byte) errorAppend writes a data entry.
func (BraidOrder) Entries
func (o *BraidOrder) Entries(gid []byte, epoch uint64) ([]Ref, []Vote, []Sig, error)Entries reads the settled view.
func (BraidOrder) ID
func (o *BraidOrder) ID() [32]byteID returns the braid's group id.
func (BraidOrder) Own
func (o *BraidOrder) Own(gid []byte, epoch uint64) ([]Vote, []Sig, error)Own reads the whole view, settled and tentative.
func (BraidOrder) Revocations
func (o *BraidOrder) Revocations(cert *koloid.DeviceCert) ([]*koloid.Revocation, error)Revocations reads what voids cert in the settled roster: the device's revocations and its issuer's.
func (BraidOrder) RevocationsAt
func (o *BraidOrder) RevocationsAt(ctx context.Context, position uint64, cert *koloid.DeviceCert) ([]*koloid.Revocation, error)RevocationsAt reads what voids cert in the roster right after the settled entry at position. Each call replays the braid from its last such read to position (kolo-braid's SettledAt), so callers keep the answers.
func (BraidOrder) Roster
func (o *BraidOrder) Roster() (admins, settlers [][32]byte, q int, err error)Roster reads the settled membership in one snapshot: the admins, and the seats and quorum of the settler config that settled it.
type Decision
type Decision struct {
// Decided is the epoch's Commit, nil while none is decided.
Decided *Ref
// Candidate is the first reference not yet decided, nil when there is
// none or once one is decided.
Candidate *Ref
// Voted holds the settlers whose vote on the candidate counted.
Voted map[[32]byte]bool
// Rejected are the Commits rejected before the candidate or decision.
Rejected [][32]byte
// Equivocators are the settlers that cast both an accept and a reject
// vote on one Commit, in key order.
Equivocators [][32]byte
}Decision is the state of an epoch's decision over its settled entries.
func Decide
func Decide(refs []Ref, votes []Vote, roles *settle.Roles, contextBefore [32]byte) DecisionDecide computes an epoch's decision from its settled references and votes in settled order; the rules are in docs/design.md, "The Kolo layer".
type Index
type Index struct {
// contains filtered or unexported fields
}Index keeps the kolo-mls entries of a braid in its view, by group, epoch and position, for the decision; it never touches MLS state, as a braid's apply function must not.
func NewIndex
func NewIndex(prefix []byte, roster *devices.Store) *IndexNewIndex returns an Index whose records live in the view under prefix; no other view key may start with it. Entries of a writer whose certificate roster revokes at the entry's position are rejected; a nil roster holds no revocation.
func (Index) Apply
func (x *Index) Apply(tx *kolobraid.Tx, e *kolobraid.Entry) (bool, error)Apply records e when it is a kolo-mls entry and reports false for every other entry. A body with a kolo-mls tag that does not decode, or whose writer's certificate is not valid or revoked at e's position, is rejected on every peer.
func (Index) Entries
func (x *Index) Entries(s *kolobraid.Snapshot, gid []byte, epoch uint64) (refs []Ref, votes []Vote, sigs []Sig, err error)Entries returns the kolo-mls entries of group gid and epoch in s, in the braid's order, or the storage error that cut the read short.
type Options
type Options struct {
// Pins keeps Commits, SettledCommits and trees; required.
Pins settle.Pins
// FetchTimeout is how long a settler waits for a candidate on pins;
// zero means DefaultFetchTimeout, a negative value is refused.
FetchTimeout time.Duration
// Now is the clock of FetchTimeout; required.
Now func() time.Time
// ApproveRoles is this settler's application deciding a roles change
// that adds a settler, changes the quorum rule or drops an admin or
// settler that is not revoked; nil refuses every such change.
ApproveRoles func(current, next *settle.Roles) bool
}Options are an Admin's choices.
type Order
type Order interface {
// ID returns the braid's group id, which the roles name.
ID() [32]byte
// Append writes body as this admin's next entry.
Append(ctx context.Context, body []byte) error
// Entries returns the settled kolo-mls entries of group gid and epoch
// in the braid's order.
Entries(gid []byte, epoch uint64) ([]Ref, []Vote, []Sig, error)
// Own returns this admin's votes and shares of group gid and epoch in
// the order, settled or not.
Own(gid []byte, epoch uint64) ([]Vote, []Sig, error)
// Revocations returns what voids cert in the settled roster.
Revocations(cert *koloid.DeviceCert) ([]*koloid.Revocation, error)
// RevocationsAt returns what voids cert in the roster right after the
// settled entry at position.
RevocationsAt(ctx context.Context, position uint64, cert *koloid.DeviceCert) ([]*koloid.Revocation, error)
// Roster returns the settled admins and settler seats, each in
// increasing order, and the settlers' quorum.
Roster() (admins, settlers [][32]byte, q int, err error)
}Order is the admins' braid as an Admin uses it. The read methods read local state and do not block.
type Reason
type Reason uint8Reason says why a settler votes against a Commit.
const (
ReasonNone Reason = 0
ReasonInvalid Reason = 1
ReasonUnavailable Reason = 2
)Vote reasons; an accept vote has none.
type Ref
type Ref struct {
// Position is the entry's settled position in the braid.
Position uint64
// Writer is the admin device that wrote it.
Writer [32]byte
// Commit is the SHA-256 of the Commit's MLSMessage.
Commit [32]byte
// Cert is the SHA-256 of the writer's device certificate the entry
// carries.
Cert [32]byte
}Ref is a settled commit-ref entry of one epoch: an admin's reference to a Commit kept on pins.
type Sig
type Sig struct {
Position uint64
Writer [32]byte
TBS settle.TBS
Signature [64]byte
// Cert is the SHA-256 of the writer's device certificate the entry
// carries.
Cert [32]byte
}Sig is a settled commit-sig entry: one settler's signature share.
type SucceedOptions
type SucceedOptions struct {
// Create is the creator's group options, with Create.KeyPackage made on the
// Store given to Succeed; its Extensions and Config.PSKs are set by Succeed
// and must be empty.
Create kolomls.CreateOptions
// KeyPackages are the members' fresh KeyPackages.
KeyPackages [][]byte
// Member and Admin are the new group's options.
Member settle.MemberOptions
Admin Options
}SucceedOptions are the parts of a successor group that its creator gives.
type Vote
type Vote struct {
Position uint64
Writer [32]byte
Commit [32]byte
ContextBefore [32]byte
Accept bool
Reason Reason
Cert [32]byte
}Vote is a settled commit-vote entry of one epoch.
Package backendstore
Package backendstore keeps the state of kolo-mls groups in a kolo-store Backend, such as its on-disk backend, under a key prefix: each group change is one atomic, durable Backend batch.
Types
type Store
type Store struct {
// contains filtered or unexported fields
}Store is a kolomls.Store on a kolo-store Backend. Deletion on disk is best effort: the Backend removes a key in the batch, but backups, snapshots and freed blocks may keep its bytes.
func New
func New(b kolostore.Backend, prefix []byte) *StoreNew returns a Store whose keys live in b under prefix; no other user of b may write keys that start with it.
func (Store) Apply
func (s *Store) Apply(b kolomls.Batch) errorApply writes the deletes and puts of b in one atomic, durable Backend batch, which keeps its own copies of the values.
func (Store) Get
func (s *Store) Get(key []byte) ([]byte, error)Get returns a copy of the value of key, or kolomls.ErrNotFound.
Good to know
Epochs and commits
- Each new epoch starts with a commit that gives fresh secrets only to the members of that epoch, so a removed member cannot compute the secrets of any later epoch. The cost of a commit grows with the logarithm of the group size, not with its size.
- Admins commit membership and group changes. A member commits only its own key update, and asks to leave with a proposal of its own removal, which an admin commits. Only admins hold such a request, at most one per member, since a held proposal stops a device from sending until a commit (RFC 9420 section 12.4).
- A commit carries its proposals by value. A commit that names any proposal by reference is refused, so every device holds what a commit needs whatever proposals it read.
- A member applies a commit only with signatures from a quorum of the epoch's settlers, after it checked the group, the epoch, the braid, the context before, the commit's hash and the context the commit leads to. A welcome for a new member is sent only after the settler signatures exist.
- A second settled commit for the epoch a member left stops that member for good (
settle.ErrHalted), also after a restart. A member that cannot follow a settled commit keeps its state and reports it (settle.ErrSettledMismatch); the library does not re-add such members. - A member that holds proposals commits them before it sends application data.
- External commits, external proposals and ReInit are refused.
Message keys
- In Kolo groups, proposals, commits and application messages all travel encrypted (MLS PrivateMessage). The core can also send proposals and commits in the clear (PublicMessage), as the RFC allows; application data is always encrypted.
- A received message uses up its key only after its signature checks out. A member can build a valid ciphertext under another member's key, since every member derives every key of the epoch, but cannot sign as that member. A commit keeps its key until it is applied, so a device that stops in between can read the commit again.
- Kolo binds the message's generation into the signed part of each encrypted message (the generation envelope), so an insider cannot replay another member's signed message under a later generation and use up that generation (RFC 9750 section 8.6). The core leaves this binding to the application (
Config.Envelope), and Kolo groups always set it (settle.Envelope): without it, that replay works. - Each key is deleted in the same storage write that records it as used, and an epoch's keys are deleted with the epoch, except that the previous epoch stays readable for 10 seconds after a commit, for late application messages of members that stay. The application's clock ends that window (
Config.PastEpochWindow). - A receiver keeps a window of 5 generations per sender, the newest one read included, so a message may arrive up to 4 generations behind the newest. One message may move a sender at most 1,000 generations ahead. Both are configurable up to 65,536 (
Config.OutOfOrderTolerance,Config.MaxForwardDistance). - If a storage write fails, the group refuses every call until it is opened again from storage, since the write may have happened.
Identity and devices
- One device is one leaf of the group's tree. The credential is a Kolo credential (
cred): the kolo-id device certificate chain plus the device's signature over the leaf's MLS signature key. - The leaf check verifies the certificate chain for the person the certificate names, refuses a small-order signature key, and then the application decides whether that person may be here (
cred.Authenticator.Expect). With no such check of its own (Expectis nil), any person is accepted: the admins chose to add the device and the settlers signed the commit. - Only the admin that adds a device checks the certificate's expiry and its revocations (
cred.Authenticator.NowandRevocations). Settlers check revocations against the braid's device roster as it stood right after the commit reference's settled position, whenever they read it, so they decide alike. A member that holds a revocation (settle.MemberOptions.Revocations) drops that device's messages but still applies settled commits. Every receiver accepts an expired certificate, as RFC 9420 section 5.3.2 recommends. - A new device of the same person joins as a new leaf. A revoked device is removed from the group by a commit. Removing a person removes every device of that person in one commit.
Admins and settlers
The same rules apply to a group of three and a group of thirty thousand.
- The group's braid holds only the admin devices, and the settlers are among them. Ordinary members are never braid members. The settler set is carried inside the group itself, in the roles extension (
settle.Roles), which only admins may change. - The settled order of the braid decides each epoch's one commit. The braid holds only a small reference to the commit (group, epoch and the hash of the commit bytes), a vote and a signature share. The application carries the commit bytes and the settler signatures (for example over kolo-gossip) and keeps them on pins.
- The first reference not yet decided wins with a quorum q of accept votes, or loses with s - q + 1 reject votes (s settlers), so the group goes on when settlers disagree about whether a commit was available. An admin's next reference counts only after its previous one was rejected, so one admin delays the group at most one fetch timeout at a time.
- A settler votes against a commit it could not fetch within a minute (on any fetch error). It accepts a change of the roles only when it names the braid's own admins, settler seats and quorum, and only with its own application's approval (
braid.Options.ApproveRoles; without it, every such change is refused) when the change adds a settler, changes the quorum rule or drops an admin or settler that is not revoked; adding an admin or dropping a revoked device needs none. - Every braid entry carries its writer's device certificate, and the braid's apply rejects an entry whose writer the devices roster revokes at that entry's own position, so a revoked admin or settler loses its references, votes and shares at one position for every peer, with no braid removal needed.
- A settler records each vote, share and first failed fetch before it writes, so a restart never casts a different vote or resets the timeout, and once it signed for an epoch it never votes or signs again in it.
- After each commit an admin keeps the ratchet tree on pins, encrypted under a key exported from the new epoch for that admin's device, with the group ID and epoch bound in. Admins on kolo-braid serve it to joiners.
- When the settlers are lost for good, a settler of the last epoch starts a successor group (
braid.Admin.Succeed) whose first commit carries a branch key of that epoch (RFC 9420 section 11.3). A member joins it only when its creator was a settler of the old group, is not revoked as far as the member knows, and every device in it was a member there. The application lets a member accept a successor only once the old quorum is known to be lost (settle.Policy.Predecessor; without it, every successor is refused).
What this design does not stop:
- s - q + 1 settlers that vote against everything stop every commit, their own removal included (with four settlers under the majority rule, two).
- An admin whose reference is ordered first can win epochs with commits that change nothing, until another admin removes it from the braid.
- An admin can remove honest settlers from the braid and stall the group.
- With one or two settlers, a stolen settler device can stall the group until a new group is made.
Catching up and history
- A person who joins a group later reads only the messages from the moment they joined. There is no history for them, and no history interface in the library.
- A person's own new device reads only from the moment it joins. kolo-mls has no transfer of history from another device of the same person; the application has to move the history itself. If all of a person's devices are lost, the recovery phrase restores the identity, not the messages.
- Devices that were in the group but offline catch up from pins: they fetch the commits after their last epoch with their settler signatures (
settle.Member.CatchUp), and the archived ciphertext of each epoch they belonged to, and move forward one epoch at a time. - Messages of the next epoch wait until its commit, the oldest dropped first past 16 MiB. A device that was away reads each epoch's archive one epoch at a time, in passes within 16 MiB of heap, so an epoch of any size is read whole; messages it could not read (a value that does not open, does not match its key or is past the bound) are reported (
settle.ErrCatchUp), never the epoch. Every read from pins asks for a bound, so hostile pins cannot hand a device more.
Idle devices
An idle device is never removed automatically. A device that is offline for a long time stays a member and catches up when it returns. The library itself removes no device. An application can show an inactive devices list so that a person or an admin can remove a device by hand.
This has costs. A forgotten device keeps its old key in the tree and keeps receiving new secrets, so if it is stolen later its holder can read what was sent after its last update until it is removed. Its disk keeps the secrets of its last epoch. And every commit of the group must stay available on pins for as long as the group lives.
Defaults
A zero value of a setting means its default, and the doc comment of each setting says what a negative value does (no bound, none kept, or refused); the roles limits and the identity cache take any value of zero or less as the default. Every bound is configurable except the ones the format itself fixes, and every default has a written source: the RFC, a published specification, or a measurement. Sizes are checked before any allocation, and no allocation is sized from an untrusted length. A setting named without a package belongs to the root package kolomls.
Messages and keys:
| Bound | Setting | Default | Why |
|---|---|---|---|
| Window of generations kept per sender, for out-of-order delivery | Config.OutOfOrderTolerance | 5 per sender and kind of message, the newest generation read included, so 4 older ones stay readable | memory and forward secrecy within an epoch; the value of a published MLS implementation |
| Ratchet steps forward for one message | Config.MaxForwardDistance | 1,000 | CPU against a hostile generation number; the value of the same implementation |
| Largest window or forward distance that can be configured | fixed | 65,536 | CPU per received message: one message that moves a ratchet that far and keeps every key costs about 0.15 s of CPU, measured |
| Previous epoch kept for late messages | Config.PastEpochWindow | 10 seconds after a commit is applied, the previous epoch only, for application messages of members that stay; a negative value keeps none | forward secrecy against late delivery; a published group media protocol keeps previous-epoch keys for 10 seconds; the caller's clock ends the window |
| Messages per sender per epoch | fixed | 2^32 - 1, the generation counter (RFC 9420 section 6.3.2) | nonce space |
| Resumption keys of past epochs kept | Config.ResumptionPSKs | none: only the current epoch's; a negative value is refused | forward secrecy of past epochs; RFC 9420 section 8.6 asks for a defined limit |
| Update interval of an online device | the application's policy | one per day | post-compromise security; the example in RFC 9420 section 3.2; a policy the application follows |
Sizes and decoding:
| Bound | Setting | Default | Why |
|---|---|---|---|
| Lifetime of a key package | KeyPackageOptions.Lifetime for a new key package; Config.MaxLeafLifetime for the bound a receiver checks (negative is no bound) | 84 days, starting one hour before creation for clock skew; leaves whose lifetime is longer than 84 days and one hour are refused | stale join keys; 84 days is the default of a published MLS implementation, and RFC 9420 section 7.2 requires a maximum |
| Size of an MLS message | the carrier's | follows the carrier library | memory, hostile input |
| Size of a welcome | the carrier's | set by the application that delivers it | memory |
| Ratchet tree bytes accepted when joining | JoinOptions.MaxTreeBytes | 128 MiB; a negative value is no bound | memory; measured: a group of 100,000 members with large credentials needs about 83 MB, and the costliest hostile tree measured holds about 7 bytes of memory per byte received, so the default bounds a join near 0.9 GiB |
| Kolo credential | fixed (cred.MaxBody) | 581 bytes | decoding; the largest device certificate with its approver parent (514), its length, a version and the device's signature, the format's own maximum |
| Client identities cached | cred.Authenticator.MaxCached | 524,288 | memory; more than the leaves of the largest tree a joiner accepts by default (the smallest Kolo leaf, measured at 471 bytes, gives at most 284,359 in 128 MiB); the cache is emptied when full |
| Proposals cached in an epoch | Policy.CheckProposal | left to the application's policy; Kolo groups cache only a member's own removal, at admins only, at most one per member and fewer than the group has members | memory; Kolo commits carry their proposals by value |
Roles and commits:
| Bound | Setting | Default | Why |
|---|---|---|---|
| Admins and settlers in a group's roles | settle.Policy.Limits.MaxAdmins and settle.Policy.Limits.MaxSettlers | none: zero or less is no cap, and a positive value is a cap the application chooses | memory and signature work per commit: a count past the keys the extension holds (32 bytes each) is refused, and the carrier bounds the extension; signature work is at most one check per settler |
| Signatures in a settled commit | follows the settlers bound | at most one per settler of the group | signature work per commit |
| References of one admin | fixed | one candidate at a time: an admin's next reference counts only after its previous one was rejected | liveness |
| Wait for a commit on pins before a settler votes against it | braid.Options.FetchTimeout | 60 seconds, on any fetch error; the caller's clock, kept across restarts; a negative value is refused | liveness of the group; the message timeout of the stream layer the braid syncs on |
| Roster reads at a reference's position | fixed | one per candidate leaf certificate and epoch, kept for the epoch, one at a time | CPU and storage; each read replays the braid from its last such read |
Catching up:
| Bound | Setting | Default | Why |
|---|---|---|---|
| Messages of the next epoch kept for later | settle.MemberOptions.MaxBufferedBytes | 16 MiB, the oldest dropped first; a negative value keeps none | memory; the bound the admins' braid puts on entries that wait for an earlier one. Later epochs are fetched again after catching up |
| Archived messages read per epoch while catching up | settle.MemberOptions.MaxCatchUpBytes | 16 MiB of heap for one pass, which is also the largest archived message; an epoch of any size is read in passes within it (about 54,000 messages per pass), each pass reading every message of the epoch, none skipped; a value past the bound, one that does not match its key or does not open, and a listing that pins got wrong are reported with an error while the epoch is still applied; a negative value is no bound | memory |
| Commit read from pins | settle.MemberOptions.MaxCommitBytes | 128 MiB; a negative value is no bound | memory; the tree bound, since the KeyPackages a Commit adds become the tree's leaves |
| Settled commit read from pins | follows the settlers bound | 512 bytes plus 96 per settler signature | memory; from the encoding |
| Encrypted tree read from pins | follows JoinOptions.MaxTreeBytes | the joiner's tree bound plus 48 bytes, asked of pins before the blob is read | memory |
Group size, members per person and the number of groups are not limits of the library. Idle devices are never removed automatically, and commits are kept on pins for as long as the group lives, because no device is evicted for being idle. The Kolo layer takes the application's clock (settle.NewConfig, braid.Options.Now) and refuses to run without one; the core uses Config.Now for the lifetime of the leaves it sends and the previous-epoch window, and falls back to the system clock when it is not set.
Security
- Someone who joins later reads only the messages from the moment they joined. There is no history for them and no history interface.
- A group changes only when a Commit is applied. In a Kolo group a device applies a Commit only with signatures from a quorum of the group's settler devices, so one admin device alone cannot split the group or change its members.
- If one of your devices is stolen, remove it: from then on it reads nothing new. A device you stop using is not removed by itself: it stays in the group and can read new messages when it comes back, so remove devices you no longer use.
- Keys are deleted after use, in the same write that records them as used, so a device that is stolen later cannot unlock old encrypted copies with the library's keys. Deleting from disk is best effort:
backendstoreremoves the keys in the batch, but backups, snapshots and freed blocks may keep their bytes, and a disk image taken before a deletion holds what it held then. A device that stays idle keeps the secrets of its last epoch on disk. - A message uses up its key only after its signature checks out. With the Kolo envelope, a member cannot replay another member's signed message under a later generation to use that generation up.
- No API returns an epoch secret:
Exportderives a secret for a label andEpochAuthenticatorreturns the epoch authenticator.Closezeroes the secrets held in memory. Private keys, seeds and epoch secrets are never logged and never put in an error message.
What MLS does not give:
- MLS gives no history for people who join later, and no way to read again what a device already consumed and deleted.
- MLS gives no protection of what a removed member already has.
- MLS gives no protection against a compromised Authentication Service. In Kolo that is the recovery phrase and the approver devices of kolo-id.
- MLS gives no delivery guarantee: whoever carries the messages can delay or drop them.
- MLS gives no protection against replay by insiders within an epoch, unless the application sets an
Envelope, as Kolo groups do (the generation envelope). - There is no defense against a malicious Commit that only some members can detect. A member that cannot follow a settled Commit keeps its state and reports
settle.ErrSettledMismatch. - There is no protection against denial of service. Settlers that vote against everything stop every commit, and an admin can remove honest settlers from the braid and stall the group; with one or two settlers a stolen settler device can stall the group until a successor group is made.
- The group ID, the epoch and the timing are visible on every message, and the transport shows which device sent it. Device linkability is accepted.
- A removal waits while fewer than a quorum of settlers are online. Keep at least two admin devices.
What the library expects of its caller:
- One
Group(orsettle.Member) per group id at a time on a Store, and never two copies of one device's state: two would write diverging secret trees.Create,JoinandOpenof one group id do not run at the same time. - A
StorewhoseApplyis atomic and durable, and safe for concurrent use when shared. A failed write makes the Group refuse every call until it is opened again. - A clock. The Kolo layer refuses to run without one; the core falls back to the system clock. The library has no timers: call
ExpirePastEpochandbraid.Admin.Stepagain at the times they return (Admin.NextDeadline). - An
Authenticatorand aPolicythat decide the same way on every member. Members that decide differently split the group (RFC 9750 section 6.5). - Deliver Commits to
Processin epoch order, one per epoch, and in a Kolo group only with their SettledCommit (settle.Member.ApplySettled). - Deliver referenced proposals before the Commit that names them, and a Welcome only after its Commit is settled and signed.
- Keep every message of a future epoch and deliver it again after catching up (
settle.Memberbuffers within a bound). - Keep every Commit, its SettledCommit and the encrypted tree on pins for the life of the group, and each epoch's archived messages while a member of that epoch may be behind.
- Call
ApplyPendingorDiscardPendingonce the Delivery Service has chosen the Commit for the epoch. - In a Kolo group, run the member loop (
Receive,ApplySettled,CatchUp,ExpirePastEpoch) on every device and the admin loop (Stepafter each braid event and atNextDeadline) on every admin device, and decide roles changes inbraid.Options.ApproveRoles.
Status
Experimental. The API may change before v1.0.0. Version 0.1.0 is tagged.
- Done: the RFC 9420 core for cipher suite 0x0001 (groups, KeyPackages, Welcomes with GREASE values, every proposal and Commit check, application messages, PublicMessage and PrivateMessage handshakes, the previous-epoch window, the Store with one atomic batch per change); the public API (the root package
kolomlsand the packagescred,settle,braidandbackendstore, withexamples/basic); the Kolo layer (the credential 0xF001, the roles extension 0xF002, the commit rule, the generation envelope, settled commits, the admin side on kolo-braid, member devices that catch up from pins, the encrypted tree for joiners and the successor group); and a cross-check against independent implementations. - Tested: the official MLS test vectors (fetched by
scripts/fetch-vectors.shat a pinned commit with their SHA-256 checked, and required byscripts/release-check.sh), unit and scenario tests in memory, theexamples/basicprogram checked by a test, on real braids and across processes on 127.0.0.1, fuzz targets for the decoders of the core and of the Kolo layer, and tests that fail when a validation rule is removed. - Not included: re-adding members that cannot follow a settled Commit (they are reported with
settle.ErrSettledMismatch). External commits, external proposals and ReInit are refused by policy. - Not verified: the time a removal takes to spread (the library does not bound it).
Errors
| Error | Message |
|---|---|
ErrClosed | kolomls: group closed |
ErrConfirmationTag | kolomls: invalid confirmation tag |
ErrCredential | kolomls: credential refused |
ErrDecrypt | kolomls: decryption failed |
ErrFutureEpoch | kolomls: message for a future epoch |
ErrGenerationExhausted | kolomls: generations exhausted |
ErrGroupExists | kolomls: group already exists |
ErrInvalidArgument | kolomls: invalid argument |
ErrInvalidCommit | kolomls: invalid commit |
ErrInvalidKeyPackage | kolomls: invalid key package |
ErrInvalidLeaf | kolomls: invalid leaf node |
ErrInvalidProposal | kolomls: invalid proposal |
ErrInvalidTree | kolomls: invalid ratchet tree |
ErrInvalidWelcome | kolomls: invalid welcome |
ErrKeyPackageNotFound | kolomls: key package not found |
ErrMalformed | kolomls: malformed encoding |
ErrMembershipTag | kolomls: invalid membership tag |
ErrNotFound | kolomls: not found |
ErrPSKNotFound | kolomls: pre-shared key not found |
ErrPendingCommit | kolomls: pending commit |
ErrPendingProposals | kolomls: proposals pending |
ErrPolicy | kolomls: refused by policy |
ErrRemoved | kolomls: removed from the group |
ErrReplay | kolomls: generation already used |
ErrSignature | kolomls: invalid signature |
ErrStore | kolomls: store failed |
ErrTooFarAhead | kolomls: generation too far ahead |
ErrTooLong | kolomls: vector longer than 2^30 - 1 bytes |
ErrTooOld | kolomls: generation too old |
ErrUnknownProposal | kolomls: unknown proposal reference |
ErrUnknownSender | kolomls: sender is not a member |
ErrUnsupported | kolomls: unsupported |
ErrWrongEpoch | kolomls: message for a past epoch |
ErrWrongGroup | kolomls: message for another group |
cred.ErrCredential | kolomls: invalid Kolo credential |
settle.ErrBuffered | kolomls: message of the next epoch kept for later |
settle.ErrCatchUp | kolomls: epoch archive refused |
settle.ErrEnvelope | kolomls: invalid authenticated data envelope |
settle.ErrEquivocation | kolomls: two settled commits for one epoch |
settle.ErrHalted | kolomls: member halted |
settle.ErrMissing | kolomls: not on pins |
settle.ErrNotHeld | kolomls: leave requests are held by admins only |
settle.ErrNotSettled | kolomls: commit not settled |
settle.ErrPinTooLarge | kolomls: pinned data past the bound |
settle.ErrRevokedSender | kolomls: message of a revoked device dropped |
settle.ErrRoles | kolomls: invalid roles extension |
settle.ErrRule | kolomls: Kolo group rule |
settle.ErrSealedTree | kolomls: encrypted tree does not open |
settle.ErrSettledMismatch | kolomls: settled commit does not match |
braid.ErrDecision | kolomls: decision differs from the signed one |
braid.ErrEntry | kolomls: invalid braid entry |
braid.ErrNotApproved | kolomls: roles change not approved |
braid.ErrRoster | kolomls: roles do not match the braid |
The table lists the sentinels of the root package and of cred, settle and braid, the last three with their package name. Test them with errors.Is. The library's own error messages start with kolomls:. ErrCredential, ErrPolicy and ErrStore wrap an error of the Authenticator, the Policy and the Store, and cred.ErrCredential wraps the errors of kolo-id.
References
- RFC 9420, The Messaging Layer Security (MLS) Protocol (Proposed Standard, July 2023).
- Takes: the protocol: framing, ratchet tree, TreeKEM, key schedule, proposals, commits, Welcome and the code points, for cipher suite 0x0001.
- Not implemented: other cipher suites. External commits, external proposals and ReInit are parsed and refused by policy.
- RFC 9750, The Messaging Layer Security (MLS) Architecture (Informational, April 2025).
- Takes: the roles of the Authentication Service and the Delivery Service and the security considerations that shape the design, including the generation binding of section 8.6.
- Not implemented: a Delivery Service or an Authentication Service of its own. It defines no protocol.
- RFC 9180, Hybrid Public Key Encryption (Informational, February 2022).
- Takes: the HPKE scheme RFC 9420 uses to encrypt secrets to a member's key (DHKEM(X25519, HKDF-SHA256), HKDF-SHA256, AES-128-GCM), through
crypto/hpke. - Not implemented: other KEMs, KDFs and AEADs.
- Takes: the HPKE scheme RFC 9420 uses to encrypt secrets to a member's key (DHKEM(X25519, HKDF-SHA256), HKDF-SHA256, AES-128-GCM), through
- RFC 9846, The Transport Layer Security (TLS) Protocol Version 1.3, section 3, "Presentation Language" (Proposed Standard, July 2026; obsoletes RFC 8446).
- Takes: the notation and encoding of every MLS structure. RFC 9420 was written against RFC 8446, whose section 3 defines the same language.
- Not implemented: the rest of TLS.
- MLS working group test vectors, repository
mlswg/mls-implementationsat commit2034fe72e0c805a683ba76165660c834f2a8142a.- Takes: the official test vectors the core must pass. The repository has no license file, so the vectors are fetched for testing and never copied into the kolo-mls repository.
- Not implemented: nothing; they are test input only.