For the complete documentation index, see llms.txt. This page is also available as Markdown.

Messages

This page defines the protocol message taxonomy and the normative wire-format rules for exchanging messages between two paired participants. Pairings are Owner ↔ Helper and ReplicaSource ↔ ReplicaDestination; every member of a replica group then shares one group channel. All protocol messages (except ContactMessage) are carried inside a DeRecMessage envelope.

Field names and tag numbers below are taken from the .proto files in lib-derec/protobufs/. Every SDK ships those files and a compiled descriptor set so you can generate your own code from them — see Schema distribution.

Message Taxonomy

ContactMessage

ContactMessage is the sole protocol message that is not wrapped in DeRecMessage; it is transferred out-of-band (e.g., QR code).

Fields

Field
Description

contactMode

Selects how the encryption material is delivered — InlineKeys, HashedKeys, or NoKeys. See Contact modes below.

mlkemEncapsulationKey eciesPublicKey

Public encryption material for a trusted session. Present only in InlineKeys mode; absent in HashedKeys and NoKeys.

contactBindingHash

48-byte SHA-384 commitment to the encryption keys. Present only in HashedKeys mode.

channelId

Channel identifier for the pairing session (transient — see the note under PairResponseMessage)

nonce

Pairing session nonce

timestamp

Message creation time

supportedTransports

Every endpoint the contact creator can be reached on, in its own preference order. MUST carry at least one entry. Replaces the singular transportProtocol (tag 7, reserved).

fingerprintCommitment

The creator's 32-byte commitment to the fingerprint nonce it reveals in PairResponseMessage.fingerprintNonce. Present only in InlineKeys mode, and required there; in HashedKeys and NoKeys it travels in PrePairResponseMessage.fingerprintCommitment and MUST be absent here.

Contact modes

ContactMessage supports three delivery modes for the public encryption material, selected by contactMode:

  • InlineKeys (default, 0) — both mlkemEncapsulationKey and eciesPublicKey are present. The recipient proceeds directly to PairRequestMessage. Existing contacts with no contactMode set parse as InlineKeys by the proto3 default, so this is wire-compatible with pre-mode contacts.

  • HashedKeys (1) — only contactBindingHash is present; both key fields are absent. The contact is small enough for a QR code or short URL. The recipient first runs a PrePairRequest / PrePairResponse exchange to fetch the actual keys, then verifies them against the hash before sending PairRequestMessage. The hash binding gives the same MITM resistance as inline keys even though the keys travel over the (unauthenticated) transport.

  • NoKeys (2) — no key material and no hash; the contact carries only channelId, nonce, and supportedTransports. The contact creator generates key material on the fly when the matching PrePairRequest arrives, and the scanner accepts the returned keys without a hash check. Because there is no cryptographic binding, NoKeys is only appropriate when the out-of-band delivery channel is fully trusted, and an application offering it MUST rate-limit inbound PrePairRequests and expire outstanding NoKeys contacts. See Trust & Threat Model.

Constraints

  • nonce MUST match the nonce carried in the subsequent PrePair*, PairRequestMessage, and PairResponseMessage for the same pairing session

  • channelId bootstraps the pairing session; both sides rotate to a derived long-term channel id once pairing completes (see PairResponseMessage)

  • supportedTransports is where the first PrePairRequestMessage (HashedKeys / NoKeys) or PairRequestMessage (InlineKeys) is delivered. The recipient filters the entries through its transport policy and records every survivor in the creator's order; it does not pick one. Which survivor to dial is the application transport's choice. If none survives, pairing fails locally with NoUsableEndpoint — see TransportProtocol.

DeRecMessage Envelope

All protocol messages other than ContactMessage are sent as a serialized DeRecMessage.

Fields

Field
Description

protocolVersionMajor protocolVersionMinor

Protocol major and minor version. The current protocol version is 0.0. See Versioning.

sequence

Monotonic per-channel message sequence number, intended for ordering, duplicate detection and replay protection. The reference library does not implement these checks yet: it may set sequence but never checks it on inbound envelopes. Replay protection currently relies on timestamp.

channelId

Channel identifier

timestamp

Envelope creation time: the send time, equal to the inner message's own timestamp. Envelopes older than the inbound-message timeout (default 300 s) are dropped and reported as MessageIgnored with reason Expired. After decryption the receiver checks envelope.timestamp == inner.timestamp; a message whose two timestamps differ, or where either or both are absent, is dropped as MessageIgnored with reason TimestampMismatch, and nothing is stored or sent back. The sender stamps one value in both places on every message, replies and ErrorResponseMessage included.

message

Encrypted serialized MessageBody

traceId

Correlation token. See traceId below.

Notes

  • The message field contains encrypted bytes, except on the PrePair* leg (see Envelope and security)

  • After decryption, message MUST deserialize into DeRecMessage.MessageBody

  • Exactly one inner message type is carried per envelope

  • The reference library stamps the protocol version on every envelope it produces and does not check it on inbound envelopes

Channel ciphertext layout

On an established channel, message is:

under the channel's 32-byte shared key. The nonce is drawn fresh from the operating system's random generator for every message; the receiver reads it from the first 12 bytes. A nonce must never repeat under the same key. Pairing envelopes use the pairing-envelope encryption instead, and the PrePair* leg is plaintext.

traceId

traceId correlates a response with the request that produced it, across concurrent requests and out-of-order delivery.

  • Request. The reference orchestrator draws one random token per start call and stamps it on every request that call sends, so a fan-out to several peers is one trace. The token is also reported on the matching *Started event and on ActionRequired.

  • Response. The responder MUST copy the request's traceId verbatim. The library does this in every response producer.

  • Zero (the protobuf default) means no correlation was requested. Responders still echo it.

  • Plaintext. The envelope is not encrypted, so traceId is visible on the wire. It is an opaque random handle and carries no identity; an observer could already correlate request and response by channelId and timing.

Primitive callers can read and set it without touching the encrypted payload: derec_message::read_trace_id and derec_message::apply_trace_id. The *::request::produce primitives emit traceId = 0.

PairRequestMessage & PairResponseMessage

First message sent from pairing initiator to pairing responder after out-of-band ContactMessage transfer.

SenderKind

SenderKind identifies the logical role of the sender. Pairings form by matching complementary kinds:

Kind
Complementary kind

Owner

Helper

ReplicaSource

ReplicaDestination

The kind on a PairRequestMessage is the initiator's own role. For a replica pairing, the device joining the group scans the existing member's contact and initiates as ReplicaDestination.

  • Owner — initiates ProtectSecret, VerifyShares, Discovery, RecoverSecret, and Unpair. There is no protocol-level distinction between an Owner pairing for the first time and an Owner re-pairing in recovery mode.

  • Helper — accepts the Owner-initiated flows above.

  • ReplicaSource / ReplicaDestination — the two sides of a replica pairing: the member admitting a device, and the device joining. After the first Secret sync every member can publish and drive Helper flows as the Owner, while each keeps a persisted ReplicaRole within the group — exactly one member is the Source. See Replica roles.

Each peer's SenderKind is recorded on the channel at pairing time and the protocol enforces flow directionality against it. Owner-side flows (ProtectSecret, VerifyShares, Discovery, RecoverSecret, Unpair) require every targeted channel's peer to be a Helper; anything else is a RoleMismatch error before a request goes out. Inbound messages are gated the other way around: a helper-bound StoreShareRequest (no replicaId) is honored only on a channel whose peer paired as Owner, and an inbound request from a peer whose role does not permit it is a failed request, answered REJECTED. A replica-bound one (carrying replicaId) is handled on the group channel by any member, whatever its ReplicaRole — every member publishes.

Fields — PairRequestMessage

Field
Description

senderKind

Role of initiator

mlkemCiphertext

ML-KEM ciphertext for responder bootstrap

eciesPublicKey

Initiator ECIES public key

communicationInfo

Application-defined identification info

nonce

Pairing session nonce

parameterRange

Advertised supported operating range (see ParameterRange)

timestamp

Message creation time

supportedTransports

Every endpoint the initiator can be reached on, in its own preference order. MUST carry at least one entry. Same semantics as ContactMessage.supportedTransports. Replaces transportProtocol (tag 8, reserved).

Fields — PairResponseMessage

Field
Description

result

Pairing result

communicationInfo

Application-defined identification info

nonce

Pairing session nonce

parameterRange

Advertised supported operating range (see ParameterRange)

timestamp

Message creation time

channelId

Derived long-term channel id both parties switch to after pairing — see Channel id rotation

fingerprintNonce

The 32-byte nonce the contact creator committed to in fingerprintCommitment. Present only when result.status == Ok. See Fingerprint commitment and channel key

Fingerprint commitment and channel key

The contact creator draws a random 32-byte fingerprint nonce and publishes a commitment to it together with its keys: in ContactMessage.fingerprintCommitment (InlineKeys) or in PrePairResponseMessage.fingerprintCommitment (HashedKeys, NoKeys).

It reveals the nonce only in PairResponseMessage.fingerprintNonce, after the requester's PairRequestMessage has fixed the handshake key. Both parties then derive the channel key:

The channel key encrypts every later message on the channel, feeds the channel id rotation below, and is what the fingerprint is computed from.

The requester MUST recompute the commitment from the creator's keys and the revealed nonce, and reject the response — closing the would-be channel — if it does not match. The reference library fails such a response with PairingError::FingerprintCommitmentMismatch (code 48, fingerprint_commitment_mismatch). A missing or malformed commitment or nonce is an invalid message: InvalidContactMessage (code 41) for an InlineKeys contact without a commitment, InvalidPairResponseMessage (code 43) for a PrePairResponseMessage without one or a PairResponseMessage without a nonce. See Error Handling.

Channel id rotation

The channelId in the ContactMessage and PairRequestMessage only bootstraps the handshake. Once the shared key is derived, the responder computes a long-term channel id and returns it in PairResponseMessage.channelId:

where originalChannelId is the contact-time id and sharedKeyBytes is the freshly-derived channel key. Both parties rotate to this value and use it on every subsequent envelope.

Two properties follow:

  • Validation. The initiator MUST recompute the same hash from its own derivation of the shared key and reject the response — closing the would-be channel — if it does not match. This binds the rotated id to a correctly completed handshake.

  • Unlinkability. The derived id travels only once, encrypted inside the pairing envelope, and depends on the shared key. A passive observer who saw the out-of-band contact or the pre-rotation traffic cannot link the exposed contact-time id to the long-running session. This is a confidentiality property only; it does not defend against an active man-in-the-middle who completes the handshake and derives the same key.

CommunicationInfo

CommunicationInfo carries application-defined identifying metadata about a participant — the kind of human-readable context the receiver can display to help the user identify and confirm the counterparty.

Field
Description

communicationInfoEntries

List of key-value entries. Each entry is one piece of identifying information for the sender.

Each entry's key is an application-defined identifier (e.g. "name", "email", "phone"), and exactly one of stringValue / bytesValue MUST be set. The protocol does not interpret or validate keys or values — the entries are opaque to DeRec.

Applications SHOULD use common keys where possible ("name", "email", "phone", etc.) to improve cross-implementation UX, but no global registry is enforced.

Reserved derec.* namespace

The protocol never inspects keys or values in CommunicationInfo except for entries whose key is under the derec.* namespace, which are reserved for the protocol itself.

Currently defined:

  • derec.replica_id — decimal-encoded u64. Carries the sender's stable replica identity on replica-mode pairing envelopes. Auto-injected on outbound replica pairings and auto-extracted on inbound, populating the peer member's replica_id. Per-pairing-kind validation: replica pairings (ReplicaSource / ReplicaDestination) MUST carry it; non-replica pairings (Owner / Helper) MUST NOT.

PrePairRequestMessage & PrePairResponseMessage

The PrePair exchange is a plaintext round-trip that fetches the actual ML-KEM and ECIES public keys when the initial ContactMessage used contactMode == HashedKeys or contactMode == NoKeys — the two modes where the ContactMessage omits the public keys to fit in size-constrained out-of-band channels like QR codes.

The two modes differ in what the returned keys are checked against:

  • HashedKeys — the ContactMessage carries a contactBindingHash (48 bytes). The contact creator returns the keys it committed to at contact-creation time, and the scanner MUST validate them against the contactBindingHash before proceeding to send a regular PairRequestMessage.

  • NoKeys — the ContactMessage carries no keys and no hash. The contact creator generates key material on the fly when a PrePairRequest arrives with a matching nonce, and the scanner accepts the returned keys without a hash check, because there is no commitment to check against. The full trust burden falls on the out-of-band channel — see the Contact modes note and Trust & Threat Model.

Fields — PrePairRequestMessage

Field
Description

nonce

Echoed from the original ContactMessage.nonce. Mismatches indicate a stale or spoofed request; the receiver MUST refuse to serve the keys.

timestamp

Message creation time.

supportedTransports

Every endpoint at which the sender can receive the PrePairResponseMessage. MUST carry at least one entry. Replaces transportProtocol (tag 2, reserved).

Fields — PrePairResponseMessage

Field
Description

result

Operation result. On Ok, the two key fields and fingerprintCommitment below are present. On any non-Ok status, they MUST be absent.

mlkemEncapsulationKey

Serialized ML-KEM-1024 encapsulation key (1568 bytes). Present only on Ok.

eciesPublicKey

Serialized ECIES public key. Present only on Ok.

nonce

Echoed from the request for session correlation.

timestamp

Message creation time.

fingerprintCommitment

The creator's 32-byte commitment to the fingerprint nonce, computed over the two keys above exactly as ContactMessage.fingerprintCommitment defines. Present only on Ok. The receiver MUST refuse a response without one, and MUST later refuse a PairResponseMessage whose nonce does not open it.

Envelope and security

Both messages are carried inside a DeRecMessage envelope, but the envelope's message field carries the serialized PrePair*Message bytes unencrypted — no shared symmetric key exists at this point in the handshake.

Scanner-side validation on receipt of PrePairResponseMessage:

  1. Confirm result.status == Ok. On non-Ok, surface a typed error and do not proceed.

  2. In HashedKeys mode, recompute SHA-384(mlkemEncapsulationKey || eciesPublicKey || u64_be(nonce) || u64_be(channelId)) and verify it matches the original ContactMessage.contactBindingHash. In NoKeys mode there is no hash to check — this step is skipped.

  3. Confirm fingerprintCommitment is present and 32 bytes; refuse the response otherwise (InvalidPairResponseMessage, code 43). Keep it with the keys: the PairResponseMessage nonce is checked against it.

  4. Only after these checks pass, proceed to construct and send a normal PairRequestMessage.

ParameterRange

Fields

Field
Description

minShareSize maxShareSize

Minimum and maximum accepted share size

minTimeBetweenVerifications maxTimeBetweenVerifications

Minimum and maximum accepted verification interval

minTimeBetweenShareUpdates maxTimeBetweenShareUpdates

Minimum and maximum accepted share update interval

minUnresponsiveDeletionTimeout maxUnresponsiveDeletionTimeout

Minimum and maximum deletion timeout for unresponsive peer

minUnresponsiveDeactivationTimeout maxUnresponsiveDeactivationTimeout

Minimum and maximum deactivation timeout for unresponsive peer

A value of 0 means "no bound": min = 0 is no minimum and max = 0 is no maximum. A range is well-formed when, for every field, min and max are >= 0 and min <= max unless max is 0. The reference library checks its own configured range in build() and fails with InvalidInput naming the first malformed field.

TransportProtocol

Fields

Field
Description

uri

Transport endpoint

protocol

How to interpret uri and deliver to it: HTTPS (0) or GRPC (1)

A participant advertises a list of TransportProtocol entries wherever it says where it can be reached (supportedTransports) or where a response should go (replyToTransports). The list is in the sender's preference order and holds at most one entry per protocol: an endpoint is the address peers reach that protocol on, so a second entry for the same protocol contradicts the first.

Schemes

protocol

Accepted URI schemes

Delivery

HTTPS (0)

https://, http://

One push per message: an HTTP(S) request carrying the serialized DeRecMessage — see HTTPS binding

GRPC (1)

grpcs://, grpc://

Unary DeRecTransport.Send call — see gRPC transport service

No other scheme is recognised (ws://, file://, … are always rejected).

Validation

The library validates every TransportProtocol at the wire-bytes ingress. Each endpoint is judged on its own:

  • uri MUST be non-empty, at most 2048 bytes, and free of control characters (bytes < 0x20 or = 0x7F).

  • uri MUST start with a scheme belonging to the declared protocol.

  • protocol MUST be a discriminant this build defines.

Error (crate::transport::TransportValidationError)

Cause

EmptyUri

uri is empty

UriTooLong

uri exceeds 2048 bytes

ControlCharacters

uri contains a byte < 0x20 or = 0x7F

UnknownScheme

The scheme is none of https://, http://, grpcs://, grpc://

SchemeMismatch

The scheme is known but belongs to a different protocol

UnsupportedProtocol

protocol is a discriminant this build does not define, typically from a newer protocol revision

DuplicateProtocol

The same protocol appears twice in this device's own endpoint list. A duplicate in a peer's list is filtered instead, first entry wins.

Transport policy

Whether a plaintext endpoint (http://, grpc://) is acceptable is a separate, deployment-specific decision made by the receiver's transport policy, not by validation:

Endpoint

TLS (https://, grpcs://)

Plaintext, loopback host

Plaintext, any other host

This device's own

always

always

only with with_unsafe_connection(true)

Supplied by a peer

always

only with with_unsafe_connection(true)

only with with_unsafe_connection(true)

A peer's advertised list is filtered through this policy, and every survivor is recorded in the peer's order. The library does not choose among them; the application's transport receives the full list and stops at the first endpoint that succeeds. If no offered endpoint survives, pairing fails with Error::NoUsableEndpoint { offered }. That error is terminal: delivery is push-only, so a peer that cannot be reached cannot be sent a rejection either. See Transport endpoints and Dev environment setup.

The policy is a consistency check on the endpoints the protocol records and propagates. The library never opens a socket, so it cannot stop an application's own transport from sending plaintext.

gRPC transport service

GRPC endpoints are served by one service, defined in lib-derec/protobufs/grpc/derectransport.proto in the same org.derecalliance.derec.protobuf package as the messages:

  • Push-only. Send delivers one envelope and returns once the receiver has accepted it for processing. There is no inline reply.

  • Both sides serve. A responder answers by opening a new Send to the requester's own endpoint, so every participant reachable over gRPC must run a reachable server.

  • Correlation is by the envelope's traceId, not by the call.

  • No security of its own. Every DeRecMessage payload is already encrypted at the application layer; use grpcs:// for transport confidentiality of the envelope metadata.

The library ships the service definition only; it generates no client or server and opens no socket. Generate stubs from the shipped schema — see Schema distribution.

UnpairRequestMessage & UnpairResponseMessage

Requests that the other party ceases the DeRec relationship and deletes relationship data, subject to regulations or service agreements.

Fields — UnpairRequestMessage

Field
Description

memo

Human-readable reason

timestamp

Message creation time

replyToTransports

Endpoints for the response, this exchange only. Empty routes to the endpoints on file. See replyToTransports and routing replies.

replicaId

The replica-group member being removed — not the sender. See the callout below.

Fields — UnpairResponseMessage

Field
Description

result

Operation result

timestamp

Message creation time

StoreShareRequestMessage & StoreShareResponseMessage

This message has two uses, distinguished by shareAlgorithm:

  • To a Helper (shareAlgorithm = 0): the share field carries one committed share for the Secret at the given version. The Helper persists it indexed by (secretId, channelId, version) and does not introspect the bytes.

  • To a Replica (shareAlgorithm = 1): the share field carries the full encoded Secret payload — a snapshot of the entire Secret at the given version. The receiving Replica installs it locally. See the Secret payload section below for the structure.

Fields — StoreShareRequestMessage

Field
Description

share

Opaque share bytes (committed share for Helpers; encoded Secret for Replicas — see shareAlgorithm)

shareAlgorithm

Share encoding identifier — 0 = CommittedDeRecShare, 1 = full Secret payload

secretId

Identifier of the protected Secret

version

Version of the Secret being distributed

keepVersion

The one version, other than version, the Helper keeps on this channel; 0 keeps no other. MUST be below version. See keepVersion semantics. Always 0 on replica-bound messages.

versionDescription

Optional version label

timestamp

Message creation time

replyToTransports

Endpoints the receiver should answer on, this exchange only. Empty routes to the endpoints on file. See replyToTransports and routing replies.

replicaId

Stable per-device identifier of the member that sent this copy. Replica-bound messages only — see the callout below.

Fields — StoreShareResponseMessage

Field
Description

result

Operation result

secretId

Echoes the Secret identifier from the request

version

Echoes the version from the request

timestamp

Message creation time

replicaId

Identity of the member that produced this response. Present only when the request was replica-bound.

Helper-side admission

A Helper checks a helper-bound request before raising ActionRequired or auto-accepting it, and checks the share again when the StoreShare action is accepted, before anything is stored or removed:

Check
Status
Memo

share length outside the Helper's own minShareSize / maxShareSize (inclusive; max = 0 is no bound; no configured range, no check)

SIZE_LIMIT_EXCEEDED

"share size is outside the helper's accepted range"

share does not decode as a CommittedDeRecShare wrapping a DeRecShare

FORMAT_ERROR

The share does not verify against its commitment: no subshares, a repeated x, or a wrong Merkle path

VERIFICATION_FAILED

keepVersion is not below version

FORMAT_ERROR

"keepVersion must be below version"

When the action is accepted, a different share already stored at this version is refused with VERSION_CONFLICT. These refusals are answered whatever auto_respond_on_failure says, the Helper reports each as ShareRefused, and the Owner sees ShareRejected with the status. The Helper's share store may also refuse a new version on save, and a verification challenge on record_verification, with TOO_FREQUENT ("refused by the helper: too frequent"), SIZE_LIMIT_EXCEEDED ("refused by the helper: size limit exceeded") or REJECTED ("refused by the helper"); the Helper's call then returns NoOp. Frequency limits are the application's, enforced through its share store.

keepVersion semantics

keepVersion is how Helpers prune old versions. The reference library implements it as follows:

  • One version besides the incoming one. After the incoming share is stored, the Helper keeps it and keepVersion, and deletes every other version it holds on this channel. 0 keeps no other version, so a Helper holds at most two versions of a Secret. There is no keep-everything value.

  • Below version. A keepVersion equal to or greater than version is invalid: the Helper refuses the request with FORMAT_ERROR and stores nothing (see Helper-side admission). The Owner checks the same rule before sending, and fails its round with SharingError::InvalidKeepVersion (code 67, invalid_keep_version).

  • Applied after storing. The incoming share is never deleted, and a share refused at admission removes nothing. A keepVersion the Helper does not hold deletes the same versions as 0.

  • Only from the newest request. keepVersion is applied only when the request's version is at least as new as every version the Helper holds on the channel. A replayed or delayed older request has its keepVersion ignored, so it cannot delete newer shares.

The Owner asks its share store's keep_version(secret_id, version) once per round, before anything is sent, including the rounds the library starts itself, and sends every Helper the same answer. When a Helper confirms the version, the Owner deletes its own proofs for that channel other than the confirmed version and keepVersion. Replica pushes always send 0, and a replica Destination never deletes a version because of it. See Version retention and Owner keep version.

Secret payload

When shareAlgorithm = 1, the share field carries a serialized ReplicaSecretPayload — the full Secret at the given version plus the per-helper share map for the same round. Replica receivers decode it and install the result. This replica-sync form is protobuf — distinct from the gzip-JSON recoverable encoding used for the helper-quorum path; both carry the same Secret data model.

Field
Description

secret

The full Secret the sender is committing to this version.

shares

One entry per Helper that received a VSS share on this round, keyed by that Helper's channel_id. This is what lets a receiving member act in the source's place during recovery without re-running share collection.

shared_key

32-byte replica-group key. Present only on the first-sync round to a newly-paired Destination; empty on every subsequent round, and empty when the receiving Destination is the very first replica pair for this secretId.

version

The version secret and shares belong to. The receiver commits this version, not the enclosing message's: on a catch-up, GetShareResponseMessage.version echoes what the asker requested while the payload is whatever the answerer holds. 0 means the writer predates this field, and the receiver falls back to the enclosing message's version.

author_replica_id

The member that published version. The enclosing message's replicaId names the sender, which on a catch-up answer need not be the author. A receiver holding the same version compares authors: same author is a re-send, a different one is a conflict. Absent when the serving member's snapshot records no author (restored, or published before the device had an id).

The share map cannot live inside Secret itself: VSS shares are derived from the encoded Secret, so embedding them would be circular. It rides alongside instead.

Group-key handover

All replica channels for a given secretId converge on a single symmetric group key and one group channel. shared_key carries the key inside the encrypted payload only when the sender knows the receiver does not have it yet — the first copy an admitting member sends to a joiner. That copy travels on the freshly minted pairing channel under the pairing key; then both sides leave the pairing channel:

  • Admitter (sender) — moves the joiner's member row onto the group channel and drops the pairing channel's key as soon as the request is sent, so every later message to the joiner uses the group channel whether or not the acknowledgement arrives. Publishes sent before the joiner's ack already reach it.

  • Joiner (receiver) — hydrates onto the group channel, acknowledges there under the group key, and drops the pairing channel.

A member already in a group keeps its row on the group channel; the pairing channel belongs to the joiner alone. The roster's replicas.shared_key is authoritative.

On the first-ever replica pair the group key is implicitly the pair-handshake key: shared_key is left empty, no swap happens, and the channel key both sides already saved is the group key.

The Secret data model

These messages are defined in Rust (crate::protocol::types::{Secret, HelperInfo, UserSecret, Replicas, ReplicaInfo}) as prost messages rather than in a .proto file. Tags 2 and 3 on HelperInfo and tag 2 on ReplicaInfo are retired: they held the former single endpoint URI and a former name field.

Message
Field
Description

HelperInfo

channel_id

The Helper's long-term channel id.

shared_key

32-byte channel key negotiated at pairing.

communication_info

The Helper's CommunicationInfo as a flat map, copied at publish time. Opaque to the protocol.

transports

Every endpoint the Helper advertised, in its order.

weight

The number of subshares the Helper received in the round that wrote this roster, copied from its channel record. In the protobuf form a 0 comes from a writer that predates the field and reads as 1.

UserSecret

id

Application-defined identifier.

name

Human-readable label.

data

The secret bytes.

ReplicaInfo

replica_id

The member's stable identity and roster key.

role

The member's ReplicaRole. Exactly one member carries Source.

communication_info

Same opacity contract as HelperInfo.communication_info.

transports

Every endpoint the member advertised, in its order.

Field
Description

helpers

Snapshot of every paired Helper for this Owner identity, including the per-Helper Shared Key, transport endpoints, and channel id. This is what makes any Replica able to talk to those Helpers as the Owner identity.

secrets

The user-facing data the Owner identity is protecting — one entry per logical secret.

replicas

The replica group as a composite: the member roster plus the two things every member shares — one channel_id and one group key. Absent when this secretId has no replica setup.

threshold

The threshold t this version was split with, in subshares. Absent on a roster written before the threshold was recorded; the device's builder threshold then applies.

Replicas is a composite rather than a flat list because channel_id and shared_key are group-level, not per-member: every member is addressed on the same channel under the same key.

restore and replica hydration write each Helper's weight into the channel record they create and the roster's threshold into the user-secret snapshot, so the next publish on the recovering or receiving device splits the same way. In the recoverable JSON encoding both are additive under the v3 major: weight is omitted when 1 (an absent key reads as 1, a 0 is malformed) and threshold is omitted when absent (a value below 2 is malformed), so rosters written before 0.0.9 decode unchanged. On restore input, a Helper's or replica member's communication_info of null reads as an empty map, like an absent key.

See Secret for the conceptual treatment, including how version increments propagate.

CommittedDeRecShare (share algorithm 0)

When shareAlgorithm = 0 in a StoreShareRequestMessage, the share field carries the serialized CommittedDeRecShare message — one committed share bound to a Merkle-root commitment that lets the requester detect tampering during recovery.

Field
Description

deRecShare

Serialized DeRecShare for this specific Helper. See below.

commitment

Merkle root of the shares distributed in this round. SHA-256 hash; leaves and interior nodes are SHA-256 too. Every Helper receives the same commitment for a given (secretId, version) round.

merklePath

Bottom-up Merkle path from this share's leaf to the root, as a sequence of SiblingHash { isLeft, hash } entries. The isLeft flag records whether the sibling is the left child at each level.

merklePath lets the recovery-time verifier reconstruct the Merkle root from deRecShare alone and cross-check it against commitment. Distinct shares in the same round produce distinct leaves but a common root, so any tampering with a single Helper's stored bytes surfaces as a mismatch.

DeRecShare

DeRecShare is the inner share content wrapped by CommittedDeRecShare.deRecShare.

Field
Description

encryptedSecret

The recoverable Secret payload for this (secretId, version) round — the [version byte] · gzip(JSON) bytes described under DeRecSecret.secretData — encrypted with a per-round AES-256 key.

subshares

The subshares this Helper holds, at least one, in the order the Merkle leaf commits to. The number of subshares is the Helper's weight, and a weight is always below the threshold. A Helper's weight defaults to one; the Owner may give a more-trusted Helper more via ProtectSecret's weights. The weight is recorded on the Owner's channel record and reused by later rounds until a ProtectSecret assigns another — see Weighted helpers.

secretId

Identifier of the protected Secret, carried inside the share bytes so the share is bound to its secret.

version

Version number of the share. Recovery sets a share bound to another secret or version aside as Malformed.

Each Subshare is one evaluation y = f(x) of the sharing polynomial f, whose evaluation at 0 is the encryption key for encryptedSecret. x is a random non-zero element of the BW6-761 scalar field, and both x and y are encoded in arkworks compressed serialization (48 bytes, little-endian).

Sharing is done in the BW6-761 scalar field. The polynomial degree determines the recovery threshold — t distinct subshares, from any combination of Helpers, are needed to interpolate and reconstruct the key at x = 0.

The Merkle leaf for a share commits to its subshares in order: SHA-256(0x00 ‖ u64_be(k) ‖ for each subshare: u64_be(len(x)) ‖ x ‖ u64_be(len(y)) ‖ y), where k is the number of subshares. Internal nodes are SHA-256(0x02 ‖ left ‖ right), the tree has a fixed depth of 7, and unused leaf slots hold leaf hashes of random bytes. A share verifies only with a merklePath of exactly 7 entries. The distinct leaf and node tags and the length prefixes stop a Helper from passing off the two children of an internal node as a share's (x, y): a forged share fails verification and is reported as an invalid proof.

The fixed tree depth caps a round at 128 Helpers (one leaf each) — that is the only limit the scheme itself imposes. Neither the sum of all Helpers' weights nor the threshold t is capped at 128; a round may distribute far more than 128 subshares in total, as long as no more than 128 Helpers are involved.

DeRecSecret

DeRecSecret is the Owner-side representation of the material distributed to Helpers in one share-algorithm-0 round — the bytes to be protected, the sharing configuration, and the roster of Helpers with the parameters each Helper agreed to at pairing time.

Field
Description

secretData

The recoverable Secret for this round, encoded as [1-byte version] · gzip(JSON) (see the note below). Previously protobuf.

creationTime

Timestamp for this snapshot. Used for auditing, version tracking, and observability.

helperThresholdForRecovery

Minimum number of subshares required to reconstruct the Secret — the t of the threshold sharing scheme. Equal to a count of Helpers only when none carries extra weight.

helperThresholdForConfirmingShareReceipt

Minimum combined weight of Helpers that must acknowledge receipt of a new share version before older versions may be safely deleted.

helpers

Roster of Helpers participating in this share round, each with a HelperSpecificInfo. Length defines the total number of shares.

Every publish round produces a new version; the current Secret snapshot is what that round distributes. The threshold is changed by a publish: ProtectSecret with an explicit threshold — see The threshold is recorded.

secretData is the recoverable encoding, not protobuf. The bytes are [ 1-byte version ] · gzip(JSON) — a self-describing format so a Secret protected by one DeRec implementation can be recovered by another. New encodes write version byte 3; the decoder accepts 3 and 2 and rejects 1. In v3 each roster entry carries transports: [{ uri, protocol }] instead of v2's single transport_uri, and role is the string "Source" or "Destination". The JSON holds the Secret bag (helpers, secrets, optional replicas), with byte fields as base64 (RFC 4648 §4) and u64s as decimal strings. See Versioning for the version table. See Secret → Recoverable encoding for the concept and the protocol::types::secret module docs for the normative schema. Only this helper-recoverable payload uses gzip-JSON — the replica-sync Secret message and every other wire message stay protobuf.

HelperSpecificInfo

HelperSpecificInfo is one Helper's entry in DeRecSecret.helpers.

Field
Description

helper

SHA-384 hash of the Helper's public encryption key. Stable identifier for the Helper within the context of this Secret without exposing the raw key.

helperParams

Proto field reserved to record the ParameterRange agreed with this Helper at pairing time. Not yet populated or enforced by the reference library — see the note under ParameterRange.

VerifyShareRequestMessage & VerifyShareResponseMessage

Owner challenges Helper to prove it still retains a particular share version.

Fields — VerifyShareRequestMessage

Field
Description

secretId

Secret whose share is challenged

version

Share version being challenged

nonce

Random uint64 challenge nonce, drawn from the operating system generator

timestamp

Message creation time

replyToTransports

Endpoints the Helper should answer on, this exchange only. See replyToTransports and routing replies.

Fields — VerifyShareResponseMessage

Field
Description

result

Operation result. A Helper that does not hold the version answers UNKNOWN_SHARE_VERSION.

secretId

Echoed secret id

version

Share version

nonce

Echoed challenge nonce

hash

SHA-384(share || u64_be(nonce)), where share is the exact StoreShareRequestMessage.share bytes the Helper stored (the serialized CommittedDeRecShare)

timestamp

Message creation time

GetSecretIdsVersionsRequestMessage & GetSecretIdsVersionsResponseMessage

Used during recovery and routine inventory to request the list of secret IDs and stored versions a Helper currently holds for the requester.

The same message pair is reused, overloaded, on the replica path: during a ReplicaDiscovery each group member is asked which version it holds, and replies with the single (secretId, version) it serves.

Fields — GetSecretIdsVersionsRequestMessage

Field
Description

timestamp

Message creation time

replyToTransports

Ephemeral response endpoints for this exchange only — see replyToTransports and routing replies

replicaId

The replica-group member this message concerns. Present only on the replica path — see the callout below

Fields — GetSecretIdsVersionsResponseMessage

Field
Description

result

Operation result

secretList

List of secrets and versions

timestamp

Message creation time

replicaId

The replica-group member this message concerns. Present only on the replica path — see the callout below

Fields — VersionList

Field
Description

secretId

Secret identifier

versions

Stored share versions, each as a VersionEntry

Fields — VersionList.VersionEntry

Field
Description

version

Numeric version identifier

versionDescription

Human-readable description supplied by the Owner at share-storage time

The catalogue carries no writer identity. A Helper stores exactly one share per (secretId, channelId, version) and holds no replica identity at all. A second write at an existing version with different content is refused at store time with VERSION_CONFLICT rather than stored side-by-side for the requester to reconcile later. See Conflict resolution.

replicaId on this message pair does not contradict that: it names the member a ReplicaDiscovery exchange is about, and never travels on the owner ↔ helper path at all.

replyToTransports and routing replies

Every channel request — StoreShareRequest, VerifyShareRequest, GetSecretIdsVersionsRequest, GetShareRequest, UnpairRequest — carries repeated TransportProtocol replyToTransports. It replaces the singular replyTo, whose tag is reserved on each message. The field exists for a routing asymmetry: a Helper learns one peer's endpoints at pair time and never pairs separately with the other members of a replica group, so a member sending a request with the per-Helper Shared Key from the synced Secret cannot rely on the Helper's stored routing to reach it.

  • Empty — the receiver routes its response to the endpoints it has on file for the channel.

  • Non-empty — the receiver routes the response to the listed endpoints, in the order given, and does not persist them. Delivery to any one is success. Use UpdateChannelInfoRequestMessage for a permanent change.

The receiver filters the list through its transport policy like any peer-supplied endpoint, and every response it sends, a failure response included, goes only to the entries that pass. When none passes, the response falls back to the endpoints on file for the channel; a refused entry never receives the response.

How the reference library fills it:

  • With with_auto_reply_to(true), every request sent through start carries this device's full own endpoint list. Default false: requests leave it empty. Pairing is unaffected; it carries its endpoints in supportedTransports.

  • When this device belongs to a replica group, the helper leg of ProtectSecret and every VerifyShares challenge always carry this device's primary endpoint, whatever the setting, so the Helper answers the member that asked rather than the one that paired.

  • Replica-path GetSecretIdsVersions / GetShare requests in a ReplicaDiscovery always carry this device's primary endpoint.

  • Responders always honour an inbound list, regardless of their own setting.

See Helpers know the Owner, not the replicas for the conceptual treatment.

GetShareRequestMessage & GetShareResponseMessage

Requests a specific share by (secretId, shareVersion) from a Helper.

Fields — GetShareRequestMessage

Field
Description

secretId

Secret identifier (uint64)

version

Requested version

timestamp

Message creation time

replyToTransports

Ephemeral response endpoints for this exchange only — see replyToTransports and routing replies

replicaId

The replica-group member this message concerns. Present only on the replica path — see the callout above

Fields — GetShareResponseMessage

Field
Description

result

Operation result. A Helper that does not hold the requested version answers UNKNOWN_SHARE_VERSION.

committedDeRecShare

Returned share payload. On the replica path, a serialized ReplicaSecretPayload whose own version names the snapshot served.

shareAlgorithm

Share encoding identifier

timestamp

Message creation time

secretId

Echoed from the request so the Owner can correlate responses across concurrent recoveries without inspecting the share bytes

version

Echoed from the request, for the same correlation reason

replicaId

The replica-group member this message concerns. Present only on the replica path

UpdateChannelInfoRequestMessage & UpdateChannelInfoResponseMessage

UpdateChannelInfo is a maintenance flow that lets either party of an already-paired Helper channel propagate post-pairing changes to their CommunicationInfo and/or endpoint list without re-pairing. At least one of the two MUST be supplied.

Either the Owner or the Helper may initiate. The flow reaches Helper channels only; a replica group announces endpoint changes through its roster instead — see UpdateChannelInfo.

Fields — UpdateChannelInfoRequestMessage

Field
Description

communicationInfo

Updated communication info for the sender, or absent to leave unchanged. Presence — including with an empty entries list — instructs the receiver to replace its stored map for this channel with the supplied one. Absence leaves the stored map untouched.

supportedTransports

Every endpoint the sender can now be reached on, in its own preference order. Empty leaves the stored endpoints unchanged. Non-empty replaces the stored set outright and, unlike replyToTransports, is persisted. The receiver routes the response and all subsequent messages on this channel to the new endpoints. Replaces transportProtocol (tag 2, reserved).

timestamp

Message creation time.

Replacement semantics for communicationInfo: updates, additions, and deletions are all expressed by the difference between the receiver's current stored map and the supplied one. There is no per-entry delta payload.

On accept, the receiver filters the announced endpoints through its transport policy only, as in pairing; which transports it serves itself is irrelevant. If every announced endpoint is refused, the stored endpoints stay unchanged and the request fails with UNSUPPORTED_TRANSPORT_PROTOCOL, reported as RequestFailed. With with_auto_respond_on_failure enabled the library sends that status; otherwise the application answers by passing the event's token to reject. The refusal is deliverable because the old endpoints still work.

Interop with 0.0.5 and older. A peer running 0.0.5 or older refuses an UpdateChannelInfoRequestMessage that carries endpoints but no communicationInfo. To update endpoints on such a peer, send the current communicationInfo alongside.

Fields — UpdateChannelInfoResponseMessage

Field
Description

result

Operation result. On Ok, the receiver has persisted the supplied updates. On any non-Ok status, the receiver's state is unchanged.

timestamp

Message creation time.

Endpoint changeover discipline

When supportedTransports is updated, the receiver routes both its UpdateChannelInfoResponseMessage and every subsequent message on this channel to the new endpoints. This creates a hard dependency the initiator's application MUST satisfy:

  1. Bring up the new endpoints and start listening on them before issuing the request.

  2. Keep the old endpoints operational during the changeover — peers that have not yet processed the update still route to the old addresses, and in-flight messages from any peer may also target them.

  3. Retire the old endpoints only after every targeted peer has responded (or been observed to route to the new endpoints), plus a grace window for in-flight traffic.

ErrorResponseMessage

Sent back to the sender of a request that has no more specific response to carry the failure.

Fields

Field
Description

result

Error result

timestamp

Message creation time, equal to the envelope's timestamp like every other message

The reference library sends it for a message that decrypts under the channel key but whose body does not decode, or that carries a PairRequestMessage or PrePairRequestMessage on a paired channel: result is FORMAT_ERROR with the memo "message body could not be decoded". With auto_respond_on_failure off, nothing is sent until the application answers the failure's token — see Replying to the peer on failure.

A received ErrorResponseMessage is reported as ErrorResponseReceived and is never answered.

DeRecResult

All response messages carry a DeRecResult with a status and optional human-readable memo.

Fields

Field
Description

status

Result status

memo

Optional message

Result codes

Code
Name
Meaning

0

OK

Success

1

PARTIAL

Partially satisfied

2

FAIL

Generic failure. The reference library sends it, with the memo "request could not be processed", for a failure with no protocol meaning (a store backend error, an internal error), so no local error text reaches the peer

3

SIZE_LIMIT_EXCEEDED

Share outside the Helper's accepted size range, or refused by the Helper's share store (for example, a storage quota exhausted)

4

TOO_FREQUENT

Rate limiting — the Owner is storing shares or challenging the Helper faster than the Helper's share store allows

5

UNKNOWN_SECRET_ID

No such secretId at the receiver

6

UNKNOWN_SHARE_VERSION

The version was never stored, or has been deleted

7

DECRYPTION_FAILED

Cryptographic-layer failure — wrong key material or corrupted ciphertext

8

VERIFICATION_FAILED

Integrity or authenticity check failed, for example a share that does not verify against its commitment

9

FORMAT_ERROR

Protobuf parse failure, missing required field, structurally invalid message — including a body that does not decode under the channel key

10

REJECTED

A user or operator declined the request, the Helper's share store refused it, or the sender's role does not permit it

11

INCOMPATIBLE_PARAMETER_RANGE

The two ParameterRange values do not overlap on at least one field

12

UNSUPPORTED_TRANSPORT_PROTOCOL

A request on an established channel carried endpoints the receiver's transport policy refuses — typically an UpdateChannelInfo all of whose announced endpoints are refused

13

VERSION_CONFLICT

A share already exists at this (secretId, version) with different content

14

REPLICA_ID_CONFLICT

A replica pairing named a replicaId already in use in the group

99

REQUEST_TO_CLOSE

The Helper is asking the Owner to terminate the relationship

UNSUPPORTED_TRANSPORT_PROTOCOL (12)

Sent only on an already-established channel, when an UpdateChannelInfoRequestMessage announces endpoints and every one of them is refused by the receiver's transport policy. The reference library answers every failed request whose error is NoUsableEndpoint or a transport-validation error with this status. The receiver still holds the peer's previous working endpoints, which is what makes the refusal deliverable.

It is never sent during pairing. Delivery is push-only, so a party that cannot reach a peer cannot deliver a rejection to it either; a pairing whose offered endpoints are all refused fails locally with NoUsableEndpoint.

VERSION_CONFLICT (13)

Exactly one writer owns a version. A recipient stores the first write it sees at a version; a later write carrying different bytes is rejected with this status rather than overwriting or coexisting. A byte-identical re-send is an idempotent retry and returns OK.

Because a single writer always derives version as latest_version + 1, it can never rewrite one of its own versions with different content. Receiving this status therefore means a second writer published concurrently — typically the same user acting on two devices at once.

On the replica path the rule is by author, not bytes: a copy at the held version from the same author (author_replica_id) is a re-send and is acknowledged; one from a different author is refused with VERSION_CONFLICT and reported to the receiving application as ReplicaVersionConflict, which carries the incoming copy in secret and writes nothing; an older copy is also refused with VERSION_CONFLICT. The pushing member sees ReplicaSyncRejected with this status. In a simultaneous write both writers push to each other, so each typically receives the other's copy as ReplicaVersionConflict. ReplicaDiscovery does not deliver a rival same-version copy: it fetches only a strictly newer version. A device that receives this status must not publish again until the user has resolved the conflict — see What the application must do.

REPLICA_ID_CONFLICT (14)

A replica pairing named a replicaId that is already in use by another member of the group — including the recipient itself. Every member must be uniquely identified: the roster is keyed by replicaId, and messages between members are attributed by it. Two members sharing an id would overwrite each other's roster row and make every acknowledgement ambiguous.

replicaId is application-assigned, so a collision is a configuration fault — most often the same identity reused on two devices, such as a cloned device image. Resolution is the application's: assign a distinct id and pair again. The protocol cannot pick one, because it cannot know which device is meant to keep the original.

Reported before fingerprint verification: there is no point asking a user to confirm a pairing that cannot be completed.

0 is reserved as the "absent" sentinel for replicaId on the FFI and WASM boundaries and is rejected as an identity. Generate ids with generate_replica_id(), which never returns 0. In the TypeScript and React Native SDKs a replicaId is a decimal string, so ids above 2⁵³ survive JavaScript number handling; .NET uses ulong and Go uint64.

Last updated