Nordhavn / specs / convene / core / EncryptedMessage

convene / coredata

EncryptedMessage

Purpose

The message as it travels — the only form in which a message exists off a member's device. The envelope is deliberately naked: an epoch key id so a reader knows which key opens it, and the sealed payload. Nothing else — not who it is for, not which group it belongs to, not who sent it. It is not posted to a shared feed; a fresh copy is sealed for each recipient and dropped into that recipient's own inbox, so no two recipients ever hold the same bytes and the swarm sees no feed that clusters a group. Who wrote it, what it says, which message it is, and what it follows all live inside the seal; the identity that orders it is the sealed Message's own MessageId, minted once and the same in every recipient's copy however differently each copy is sealed.

Attributes

Invariants

Operations

unseal

Given the epoch's GroupKey, recovers the content, yielding the Message the sealed payload seals; fails when the given key is not the key that sealed it — a message is readable whole or not at all. Result: the Message it seals; fails when the key is not the one that sealed it

Scenarios

An envelope is an epoch and a sealed payload, nothing more

Given: key id "k-0163" and a sealed payload When: an EncryptedMessage is created Then: it is accepted and reads back under key id "k-0163" — it names no recipient, no group, no sender

An envelope without an epoch is rejected

Given: an empty key id and a sealed payload When: an EncryptedMessage is created Then: the creation is rejected because the key id is empty

The epoch's key recovers the message

Given: the GroupKey "k-0163", and an accepted EncryptedMessage with key id "k-0163" whose sealed payload is that key's sealing of a Message "m-8001" by anne.bruun carrying a Writing of "The hearing moved to Thursday." When: unseal is performed with that key Then: the yielded message carries id "m-8001", author anne.bruun, and the writing "The hearing moved to Thursday."

Another key recovers nothing

Given: the GroupKey "k-0163", a GroupKey "k-0264" with different material, and an accepted EncryptedMessage with key id "k-0163" whose sealed payload is the first key's sealing of a Message carrying a Writing of "The hearing moved to Thursday." When: unseal is performed with the second key Then: the unsealing fails because the given key is not the key that sealed the payload — nothing of the message is recovered

spoken of by