package mls // MLS secret tree (RFC 9420 §9). // Type definitions — crypto derivation methods go in secret_tree_crypto.mx. type ratchetLabel []byte var ( ratchetLabelHandshake = ratchetLabel("handshake") ratchetLabelApplication = ratchetLabel("application") ) func ratchetLabelFromContentType(ct contentType) ratchetLabel { switch ct { case contentTypeApplication: return ratchetLabelApplication case contentTypeProposal, contentTypeCommit: return ratchetLabelHandshake default: panic("unreachable") } } // secretTree holds tree node secrets for encryption key/nonce generation. type secretTree [][]byte func (tree secretTree) get(ni nodeIndex) []byte { secret := tree[int(ni)] if secret == nil { panic("empty node in secret tree") } return secret } func (tree secretTree) set(ni nodeIndex, secret []byte) { tree[int(ni)] = secret } type ratchetSecret struct { secret []byte generation uint32 }