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

Flows

This page captures the core DeRec sub-protocol flows: Pairing, Sharing, Verification, Discovery, Recovery, ReplicaDiscovery, UnpairReplica, Unpair, and UpdateChannelInfo. The last section, Timeouts and tick(), covers the deadlines every flow is subject to.

ReplicaDiscovery and UnpairReplica are replica-only: both require a configured replica_id (otherwise Error::ReplicaIdNotConfigured) and operate on the replica group rather than on Helper channels.

Requests and responses

Every request that arrives on an authenticated channel is answered exactly once, even when handling it fails; a request counts as answered once its response is handed to the transport. A failure is not an error from process or accept: the call returns RequestFailed among its other events, carrying the status and memo sent, or to be sent. With auto_respond_on_failure on, the library answers; with it off (the default), nothing is sent until the application passes the event's token to reject. Protocol refusals — PairingRefused, ShareRefused, ReplicaSecretRefused — are answered in both modes. A message that fails to decrypt, an expired message, any response (an ErrorResponseMessage included), any other failure of the pairing handshake and a replica group's removal notice are never answered. See Replying to the peer on failure.

Matching a response to its request is the application's concern. The library does not check that a response answers a request this device sent. A response that would change stored state is applied only against the flow that asked for it: a GetShareResponse against a recovery in progress for that Secret and version, a VerifyShareResponse against the outstanding challenge on that channel, an UnpairResponse against an unpair this side started, a replica discovery answer against a discovery in progress, and a StoreShareResponse only while its sharing round is open and still waiting on that Helper. A replica catch-up is applied by the same newer-than-held rule as a pushed copy. Every other response is reported as it arrives, unmatched: ShareConfirmed, ShareRejected, SecretsDiscovered, ChannelInfoUpdated, ChannelInfoUpdateRejected and ErrorResponseReceived. See Matching responses to requests.

Pairing

Pairing starts with an out-of-band transfer of a ContactMessage (channel id, nonce, contact mode, the creator's supportedTransports, and the mode's key material). The scanner then sends PairRequestMessage and receives PairResponseMessage; after this, future messages for that secretId can be both decrypted and signature-verified upon receipt.

Contact-delivery modes

DeRec pairing supports three contact-delivery modes, all arriving via the same out-of-band channel and selected by the contactMode field on ContactMessage:

  • InlineKeys (default) — the ContactMessage carries the creator's ML-KEM-1024 encapsulation key (1568 bytes) and ECIES public key directly in the contact payload. Single round-trip: ContactMessage (out-of-band) → PairRequestMessage → PairResponseMessage. The contact is about 1.7 KB; use this mode when the out-of-band channel can carry that (NFC, deep links, direct messaging).

  • HashedKeys — the ContactMessage carries only a 48-byte SHA-384 commitment (contactBindingHash) to the keys instead of the keys themselves. The scanner fetches the real keys via a plaintext PrePairRequestMessage / PrePairResponseMessage round-trip before sending the PairRequestMessage, then verifies the published keys against the contact's binding hash. Use when the out-of-band channel is size-constrained (QR codes).

  • NoKeys — the ContactMessage carries no key material and no binding hash, only channelId, nonce, and supportedTransports. Like HashedKeys it uses a plaintext PrePairRequest / PrePairResponse round-trip, but the contact creator generates the key pair on the fly when the PrePairRequest arrives, and the scanner accepts the returned keys without a hash check. Because nothing in the contact binds the keys, a NoKeys channel is held ChannelStatus::Pending and cannot carry protocol traffic until the fingerprint cross-confirmation below succeeds — that comparison is what replaces the missing commitment. Use when the out-of-band channel is a human one: hand-typed, dictated over the phone, or an institutional email. The creator MUST rate-limit inbound PrePairRequests and expire outstanding contacts on a short timer.

In every mode the contact creator draws a random 32-byte fingerprint nonce, publishes a commitment to it with its keys (ContactMessage.fingerprintCommitment in InlineKeys, PrePairResponseMessage.fingerprintCommitment in HashedKeys and NoKeys), and reveals it in PairResponseMessage.fingerprintNonce once the scanner's PairRequestMessage has fixed the handshake key. The channel key is derived from the handshake key and the nonce, so neither side can choose its contribution to steer the fingerprint. The scanner refuses a nonce that does not open the commitment with PairingError::FingerprintCommitmentMismatch (code 48), and the pairing does not complete. See Fingerprint commitment and channel key.

After the cryptographic handshake completes, the channel's status depends on both the pairing kind and the contact mode:

Pairing
Contact mode
Status after handshake

Owner ↔ Helper

InlineKeys / HashedKeys

Paired — usable immediately

Owner ↔ Helper

NoKeys

Pending — gated on the fingerprint

ReplicaSource ↔ ReplicaDestination

any

Pending — gated on the fingerprint

A Pending channel fails closed: it is not a ProtectSecret target, it is not used as a recovery source, and inbound messages on it are dropped and reported as MessageIgnored { reason: PendingVerification }.

InlineKeys sub-flow

As an example of how an out-of-band ContactMessage transfer could be achieved, the contact can be serialized with request::encode_contact, base64-encoded, and turned into a QR code that the counterparty's app scans. The scanner turns the bytes back into a contact with request::decode_contact. Both helpers validate the contact; use them rather than calling prost directly.

The pairing primitives refuse a peer whose ParameterRange does not overlap their own with PairingError::IncompatibleParameterRange — see Parameter-range negotiation. Through the orchestrator, a responder that refuses a PairRequestMessage under a protocol rule — a non-overlapping or malformed parameter range (INCOMPATIBLE_PARAMETER_RANGE) or a replica id already in the group (REPLICA_ID_CONFLICT) — answers with that status whatever auto_accept or auto_respond_on_failure says, creates no channel, and reports PairingRefused from process. Its memo is what the requester reads, for example `shareSize` range [10, 500] does not overlap the accepted range [1000, 5000]. The initiator's pairing fails with non_ok_status, carrying that status and memo. A responder whose PairResponse send fails reports PairingCompleted followed by RequestFailed with action_kind Pairing and responded: true.

HashedKeys sub-flow

In HashedKeys mode the ContactMessage is small enough to fit in a QR code: it carries a 48-byte SHA-384 commitment to the keys instead of the keys themselves. The scanner retrieves the real public keys with a plaintext PrePairRequest / PrePairResponse exchange, verifies them against the commitment, and only then proceeds with the normal PairRequest / PairResponse round-trip.

Steps:

  1. The contact creator calls create_contact with contact_mode = HashedKeys. The library generates the ML-KEM-1024 + ECIES key pair, computes

    and emits a ContactMessage carrying only contactBindingHash (no mlkemEncapsulationKey, no eciesPublicKey).

  2. The ContactMessage is delivered out-of-band as in InlineKeys mode (e.g. QR code).

  3. The scanner decodes the ContactMessage, sees contactMode == HASHED_KEYS, and calls request::produce_pre_pair_request(own, &contact) to issue a plaintext PrePairRequestMessage to the endpoints advertised in the contact. The PrePair leg is plaintext because no shared key exists yet, and the keys it asks for cannot themselves be used for encryption.

  4. The creator extracts the request (request::extract_pre_pair), validates the echoed nonce against the original contact, and replies via response::produce_pre_pair with a PrePairResponseMessage carrying the actual mlkemEncapsulationKey and eciesPublicKey, and the fingerprintCommitment to the fingerprint nonce it drew with the keys.

  5. The scanner extracts the response (response::extract_pre_pair) and calls response::process_pre_pair(&contact, &response), which recomputes the SHA-384 binding hash over the keys it just received (using the nonce and channelId from the original ContactMessage) and compares against contactBindingHash. On mismatch it fails with Error::Pairing(PairingError::PrePairHashMismatch). A response without a 32-byte fingerprintCommitment fails as PairingError::InvalidPairResponseMessage. On success the result carries the keys, the nonce and the fingerprint_commitment.

  6. The scanner builds an InlineKeys-shaped contact from the verified keys and the fingerprint_commitment, and continues with the normal PairRequestMessage / PairResponseMessage round-trip exactly as in the InlineKeys sub-flow; the PairResponseMessage nonce is checked against that commitment. The orchestrator does this step automatically. Code that builds the contact itself from a PrePair result must copy the commitment in, or the pair response fails.

NoKeys sub-flow

NoKeys mode reuses the same plaintext PrePairRequest / PrePairResponse round-trip as HashedKeys, with two differences:

  1. The ContactMessage carries neither the keys nor a contactBindingHash — only channelId, nonce, and supportedTransports. The creator does not generate a key pair at contact-creation time; create_contact returns secret_key: None and the orchestrator persists the contact itself (SecretKind::PairingContact) so the inbound request can be matched against it.

  2. When a PrePairRequest arrives whose nonce matches the outstanding contact, the creator calls response::produce_pre_pair_no_keys(channel_id, &request), which generates the ML-KEM-1024 + ECIES key pair and the fingerprint nonce on the fly, puts the fingerprintCommitment in the response, and returns the key material alongside the response envelope; the creator MUST persist it. The scanner accepts those keys through response::process_pre_pair_no_keys(&contact, &response) — there is no contactBindingHash to check against, only the echoed nonce and the response shape, the commitment included — and proceeds to the normal PairRequest / PairResponse round-trip with a contact that carries the keys and the fingerprint_commitment.

Because the returned keys are unbound, an active man-in-the-middle on the plaintext PrePair leg can substitute its own keys during the handshake. The protocol closes this by refusing to use the channel until the pair is confirmed out of band: a NoKeys channel is held ChannelStatus::Pending until both sides compare the human-readable fingerprint derived from the established shared key and it matches. A man-in-the-middle ends up holding a different channel key with each side, so the two sides derive different fingerprints and the comparison fails. The fingerprint commitment keeps it from making them agree by search: on each leg the nonce is fixed before the scanner contributes to the handshake key and revealed only after, so a man-in-the-middle cannot try contributions offline until one yields the fingerprint of its other leg, and each attempt matches with a chance near 10⁻¹⁶. This is what HashedKeys gets from its contactBindingHash, and what NoKeys can get no other way. The fingerprint is available as a primitive, primitives::pairing::fingerprint(shared_key), for callers that drive pairing without the orchestrator.

The out-of-band channel still carries real weight: it must be authentic enough that the contact reached the intended party, and the creator remains a key-minting oracle for anyone presenting a matching nonce. Rate-limiting inbound PrePairRequests per channelId and expiring outstanding contacts on a short timer are still MUSTs. See Trust & Threat Model.

Transport endpoints

Each side advertises all of its own endpoints, in its own preference order and at most one per protocol: in supportedTransports on ContactMessage, PairRequestMessage and PrePairRequestMessage, and later on UpdateChannelInfoRequestMessage. Recognised schemes are exactly https://, http://, grpcs:// and grpc://; see TransportProtocol.

The receiver does not pick one. It filters the peer's offers through its own transport policy — structural validation plus the plaintext scheme policy set by with_unsafe_connection — drops a repeated protocol (the earlier entry is kept), and records every survivor, in the peer's order. The library ranks nothing: DeRecTransport::send receives the whole list, and the application's transport decides which endpoint to dial and whether to fall back (the SequentialFailover adapter is the default). Which transports the receiver serves itself has no bearing on which of the peer's endpoints it records.

If no offer survives, the error is Error::NoUsableEndpoint { offered }. At pairing time it is terminal: delivery is push-only, so a peer that cannot be reached cannot be sent a rejection either.

The own list follows the same rules everywhere it is set (with_own_transports, set_own_transports): non-empty, at most one entry per protocol (TransportValidationError::DuplicateProtocol otherwise), and every entry an endpoint the application actually serves — listing one it does not makes pairing succeed and replies vanish. See Dev environment setup for the plaintext rules.

Parameter-range negotiation

Each party advertises the range of operating parameters it supports — share size, verification cadence, share-update interval, and unresponsive-peer timeouts — as a ParameterRange on its PairRequestMessage / PairResponseMessage. A value of 0 means "no bound", and a range is well-formed when every min and max is >= 0 and min <= max unless max is 0; build() rejects a malformed local range with InvalidInput naming the field. During the handshake the two ranges are checked for overlap, a max of 0 overlapping any min: if any field's [min, max] interval is disjoint from the peer's, or the peer's range is malformed, pairing is rejected with INCOMPATIBLE_PARAMETER_RANGE and no channel is established. The responder reports the refusal as PairingRefused.

Beyond the overlap check, only share sizes are enforced: a Helper refuses a share outside its own minShareSize / maxShareSize with SIZE_LIMIT_EXCEEDED, and an Owner sets aside a recovery share above its own maxShareSize. The reference library does not compute a single agreed range, persist it onto the Secret, or enforce the other parameters — see the note under ParameterRange in Messages. Treat them as advisory.

Channel-id rotation on completion

The channelId carried in the ContactMessage and PairRequestMessage only bootstraps the handshake. In the PairResponseMessage the responder returns a long-term channelId derived from the channel key — SHA-384(originalChannelId || channelKey) — and both sides rotate to it for all subsequent traffic. The scanner recomputes the same value from its own key derivation and rejects the response if it does not match. Because the derived id depends on the shared key and travels only once (encrypted), a passive observer of the contact or the pre-rotation traffic cannot link the exposed contact-time id to the long-running session. See Channel id rotation in Messages for the full derivation and validation.

Fingerprint cross-confirmation

Two kinds of channel are gated on the fingerprint: every replica pairing (ReplicaSource ↔ ReplicaDestination), whatever the contact mode; and every NoKeys pairing, Owner ↔ Helper included. InlineKeys and HashedKeys Helper channels are Paired at handshake completion and are not gated — see Why InlineKeys and HashedKeys Helper channels skip this gate.

The cryptographic handshake produces a SharedKey but does not by itself authenticate the peer against any out-of-band identity. The two gated cases have different reasons for needing that authentication:

  • Replica channels — a successfully-handshaken peer receives the full Secret on the first sync round, so accepting a man-in-the-middle at that point hands the entire Secret to an unknown party. No threshold bounds the damage.

  • NoKeys channels — nothing in the contact commits to the keys, and the PrePair leg that publishes them is plaintext. The fingerprint comparison is the substitute for the commitment the other two modes carry.

In both cases the orchestrator holds the channel in ChannelStatus::Pending until both sides confirm out-of-band that they share the same channel key.

  • After the handshake, a gated channel is stored with ChannelStatus::Pending. Protocol traffic arriving on it is dropped and reported as DeRecEvent::MessageIgnored { channel_id, reason: IgnoreReason::PendingVerification, trace_id }. Nothing is stored and nothing is sent back, and a dropped message is not replayed once the channel is confirmed.

  • Each side independently computes a deterministic 16-digit fingerprint over the channel key, which is derived from the handshake key and the creator's committed nonce. Both sides arrive at the same fingerprint string (e.g. "1234-5678-9012-3456").

  • The application surfaces its locally-computed fingerprint to the user via protocol.get_fingerprint(channel_id) and presents it for human comparison against the peer's fingerprint — side-by-side on two devices, or relayed via voice / video / in-person.

  • After the user confirms a match, each side calls protocol.verify_fingerprint(channel_id, peer_fingerprint) with the fingerprint string it observed on the peer.

  • The orchestrator recomputes the local fingerprint and compares it against the supplied value. A match returns Ok(()). A mismatch fails with Error::FingerprintMismatch (code 17, fingerprint_mismatch, category pairing): the two sides hold different keys, which is what a man-in-the-middle on the pairing produces.

  • A mismatch revokes the Pending pairing. The comparison is authoritative, so the orchestrator deletes the channel's Pending records, its channel key and its pairing material. A second comparison on that channel then fails because no channel key remains; the devices must pair again. A channel already Paired is never touched by a comparison; removing it is an Unpair.

  • On match, the orchestrator promotes every Pending row on the channel to Paired, not just the confirmed peer. On a group channel that is every pending member and this device's own row, so the whole group becomes usable at once and the roster stays reconstructible from the stores.

  • If the promotion made a Helper or a Destination member other than this device usable, the orchestrator publishes the current Secret snapshot to it: that peer was not an eligible target when the pairing-time publish ran, so it was skipped there. A device with no snapshot still publishes an empty one to a promoted Destination, since the payload carries the roster; a promoted Helper is sent nothing in that case. This is the only push the peer gets before the next explicit ProtectSecret.

On a replica destination, confirming is the decision to adopt the group's vault. Once the channel is Paired, the source's publish is installed into this device's stores as it arrives, with no further prompt. Ask the user whether to adopt the vault before calling verify_fingerprint; to decline, never confirm, and the channel stays Pending, unused, until expired-channel cleanup removes it together with its channel key.

Confirmation on the two devices is not simultaneous. If the source confirms first, its publish reaches a destination that is still Pending, which reports it as MessageIgnored and drops it; it is not replayed. A replica destination should therefore run start(ReplicaDiscovery) after its own verify_fingerprint succeeds, to pull the state it may have missed.

Why InlineKeys and HashedKeys Helper channels skip this gate

Both modes already commit to the keys — InlineKeys carries them in the contact, HashedKeys carries a SHA-384 commitment the scanner checks the fetched keys against. A fingerprint comparison would catch nothing the contact did not already catch, so the orchestrator does not withhold the channel for one. On top of that, the threshold-of-shares assumption bounds the damage a single rogue Helper (or a MITM impersonating one) can do: fewer than t colluding peers can reconstruct nothing.

Applications may still run get_fingerprint / verify_fingerprint on such a channel as a belt-and-braces check — the call works and returns a meaningful answer: Ok(()) on a match, FingerprintMismatch on a mismatch. It does not change the state of a Paired channel either way, and the orchestrator will process traffic on the channel whether or not the application ever calls it. Act on a mismatch by unpairing.

Sharing

Once Owner and Helpers are paired, the Owner splits the current Secret into shares using a threshold secret-sharing scheme and distributes one committed share to each Helper. Each share carries one or more subshares: one by default, or the Helper's weight when the Owner gives it more (see Weighted helpers below). The same flow also fans out the full Secret to every paired Replica so the Owner identity stays synchronized across all its devices. The threshold t is counted in subshares, not Helpers: when the paired Helpers' combined weight is below t, no split runs and Helpers receive nothing; the Secret still reaches any paired Replica destinations.

The two paths use the same wire envelope (StoreShareRequestMessage) but a different shareAlgorithm discriminator:

  • shareAlgorithm = 0 → the share field carries one committed share of the Secret for a Helper.

  • shareAlgorithm = 1 → the share field carries the encoded full Secret for a Replica.

See the StoreShareRequestMessage section in Messages for the field details and the Secret payload for the structure delivered to Replicas.

Weighted helpers

A ProtectSecret round gives each paired Helper a weight: the number of subshares its share carries. t counts subshares, not Helpers, so with every Helper at weight 1 the two coincide. Every weight must be at least 1 and below t, so no single Helper's share ever carries enough subshares to recover alone.

Weights are sticky. ProtectSecret.weights is the full assignment, not a patch: a paired Helper the map does not name gets weight 1, and an empty map resets every Helper to 1. Each round writes the weight it resolved for every paired Helper to that Helper's channel record (HelperChannel.weight) before anything is sent, and reports it as weight on ProtectSecretStarted / ProtectSecretFailed. Publishes the library starts on its own — after pairing completes, after a fingerprint is confirmed — reuse the stored weights; a newly paired Helper starts at 1. The roster carries the weights (HelperInfo.weight), so restore and replica hydration put them back.

There is no getter or setter: weights change only through start(ProtectSecret), and the application reads them from its own channel store. The intended workflow:

  1. Before start(ProtectSecret), the application shows the user each paired Helper's stored weight and passes the user's final choice as the whole map.

  2. Every other start(ProtectSecret) the application makes — a republish after editing the secrets, the publish after restore — passes the stored weights unchanged. A Helper left out returns to 1, which silently undoes the user's choice.

Validation. start checks every entry before anything is sent or a version is consumed: each key must be a currently paired Helper channel of this secret, and 1 <= weight < t. An invalid entry fails as SharingError::InvalidWeight { channel_id, weight } (invalid_weight). Stored weights are checked the same way, so a stored weight that is no longer below the round's t fails the next publish with InvalidWeight and zero messages sent, library-initiated publishes included:

  • The pairing-time publish returns it from process (as a ProcessError carrying the message's events) or from accept. From accept, the pairing has completed and its response was sent, but PairingCompleted is not returned.

  • The fingerprint-time publish returns it from verify_fingerprint, after the channel has been promoted. A retried verify_fingerprint returns Ok(()) and publishes nothing.

In every case, start(ProtectSecret) with valid weights publishes.

Capping the total. Recovery cost grows quadratically with the total number of subshares (measured at about 0.2 s for 200, 5.5 s for 1,000 and 87 s for 4,000 subshares per attempt), while splitting stays cheap. with_max_subshares(max) caps a round's total: a round above it, library-initiated publishes included, fails in start as SharingError::TooManySubshares { subshares, max } (too_many_subshares) before anything is sent or a version is consumed. Unset means no cap; a cap below the threshold fails build() with InvalidInput. Recovery applies no cap.

Below the threshold. When the paired Helpers' total weight is below t, no split runs: Helpers receive nothing and no ProtectSecretStarted / ProtectSecretFailed is emitted for them, paired Replicas still receive the Secret, and the version still advances with the snapshot saved as latest. With no Replica paired, start returns Ok with no events; it is not an error. Weighted Helpers make this easier to reach: two Helpers at weight 2 against t = 3 (total 4) drop to a total of 2 when a publish leaves both out of the map, as a publish after restore does if it does not pass the stored weights. To tell the case apart, sum the weights about to be assigned (or the stored ones) against t before calling, or count the returned Helper events after.

SharingComplete.threshold_met is true when the confirmed Helpers' combined weight reaches the round's t; confirmed_count and failed_count count Helpers.

The threshold is recorded

ProtectSecret also takes threshold: Option<u32>. A round splits at, in order: the explicit threshold; otherwise the stored UserSecrets.threshold; otherwise the builder's with_threshold, which is only the starting t for a secret with nothing stored. Publishes the library starts on its own never pass one, so they use the stored t.

The resolved t must be at least 2 (SharingError::InvalidThreshold), above every resolved weight (InvalidWeight) and no greater than a with_max_subshares cap (InvalidInput), all checked before a version is chosen; a failing round writes and sends nothing. Every publish writes the t it used on its own snapshot, saved after distribution, so a round that fails before then leaves the previous t in place; a snapshot written before 0.0.9 reads as none. The roster carries t (Secret.threshold), and restore and replica hydration write it into the snapshot. To change t, pass threshold on start(ProtectSecret).

The Owner also records, on each proof it keeps of what it sent a Helper, the share's subshare count (Share.subshares) and the round's t (Share.threshold); a replica Destination's mirrored copies carry both, with the roster's t. Both are absent on a Helper's own stored share and on rows written before 0.0.9, and are never backfilled. Verification reports them.

Version retention

Every helper-bound StoreShareRequestMessage carries a keepVersion: the one version, other than the one being shared, the Helper keeps. Once the incoming share is stored, the Helper deletes every other version it holds on that channel (through DeRecShareStore::remove_versions). keepVersion = 0 keeps no other version, so a Helper holds at most two versions of a Secret; there is no way to keep every version. A request whose version is older than the newest one the Helper holds on the channel has its keepVersion ignored, so a delayed or replayed request cannot delete newer shares, and the version the request itself carries is never removed.

The Owner asks its share store once per round, before anything is sent: DeRecShareStore::keep_version(secret_id, version), where version is the version about to be distributed. Every round asks, including the publishes the library starts itself (pairing completion, fingerprint confirmation), and every Helper of the round receives the same answer. An answer equal to or greater than version fails the round with SharingError::InvalidKeepVersion (code 67, invalid_keep_version) before anything is sent; a Helper that receives such a request refuses it with FORMAT_ERROR and stores nothing. Replica pushes never consult keep_version and always send 0, and a replica Destination never deletes a version because of it.

Return the last valid version: the newest one whose SharingComplete reported threshold_met, or 0 before any did. The version being sent has not committed yet, and its round may never reach threshold, so the last committed version must stay. Only the application knows which versions committed. A version whose round is still open when the next one starts is deleted from every Helper that stores the next one, unless it is the version returned. See Owner keep version. Because a Helper answers Discovery from what it still stores, Discovery reports only retained versions.

For example, an Owner with seven Helpers:

  1. Sends v1 with keepVersion = 0. Every Helper stores it and answers.

  2. Sends v2 with keepVersion = 1. Only three Helpers answer, so v2 never reaches threshold. Those three hold v1 and v2.

  3. Sends v3 with keepVersion = 1, since v1 is still the last valid version. Every Helper answers. The three that hold v2 delete it; the other four hold only v1, which they keep. Every Helper ends with v1 and v3.

The Owner prunes its own proofs (the bytes it sent each Helper, kept for verification) to match. When a round settles a channel as failed (ShareRejected or a timeout), it deletes that channel's proof for the round's version; a late ShareConfirmed is still emitted but stores nothing. When a Helper confirms a version, the Owner deletes that channel's proofs other than the confirmed version and the round's keepVersion. A confirmation removes nothing while the Owner holds a newer proof for that channel, and a version whose round still waits on that Helper keeps its proof; a later confirmation removes what these leave behind. A confirmation that arrives after its round has closed removes nothing. A Helper that rejects the round keeps its older versions, and so does the Owner. A replica Destination never sees the Helpers' answers and keeps every proof it receives — see Proof storage on replicas.

Verification

Verification is a challenge-response protocol used by the Owner to check that a Helper retains the correct share. The Owner sends a random u64 nonce, drawn directly from the operating system's random generator; the Helper responds with a hash computed over the share contents and the nonce.

Every challenged channel ends with exactly one verdict event, and a failed check is reported, not just inferred:

  • The proof checks out — the Owner receives DeRecEvent::ShareVerified { channel_id, version, subshares, threshold }. subshares and threshold are read from the Owner's stored proof for that channel and version, so they describe the round that published the version, not the current configuration.

  • The proof is invalid — the Owner receives DeRecEvent::ShareVerifyInvalid { channel_id, version }. It is an event, not an error from process.

  • The Helper refuses — for example UNKNOWN_SHARE_VERSION when it holds no share for the challenged version, or TOO_FREQUENT, SIZE_LIMIT_EXCEEDED or REJECTED when the Helper's share store refuses the challenge in record_verification — and the Owner receives DeRecEvent::ShareVerifyRejected { channel_id, version, status, memo }. The challenge is consumed: re-checking that Helper takes a new VerifyShares round.

  • No verdict on this device — DeRecEvent::VerifySharesFailed { channel_id, version, reason, error }, with reason one of NoSharedKey, NoProof or DispatchFailed.

  • The Helper never answers — no event fires; failure is observable only through the absence of a verdict. No timeout closes an outstanding challenge.

The Owner checks answers against a proof it keeps of each Helper's share — the exact bytes it sent. A stored proof is either confirmed by its Helper or part of a sharing round still open: when a round settles a channel as failed (a rejection or a timeout), that channel's proof is deleted. Verify only versions whose round completed (SharingComplete). Starting verification on a channel with no proof sends nothing and emits VerifySharesFailed with NoProof immediately.

Judging a version's recoverability. Sum subshares over the version's ShareVerified events and compare the sum with their threshold. If either value is absent on any of those events (a proof written before 0.0.9), the result is unknown: an absent count is not 0 or 1.

What to do about a failed Helper (republish, unpair and re-pair another) is the application's decision.

Binding to the outstanding request

The challenge-response hash check above is not, on its own, enough to defeat replay: a VerifyShareResponseMessage is internally self-consistent — its nonce and hash are wire fields a captured envelope already carries — so a structurally well-formed response can be replayed against the Owner and still pass an isolated hash check. The library closes that gap by binding every inbound response back to the specific outstanding VerifyShareRequestMessage the Owner sent.

  • The Owner-side nonce is the binding anchor. When the Owner produces a VerifyShareRequestMessage via verification::request::produce, the library mints a fresh u64 nonce from the OS random generator, embeds it in the encrypted request, and surfaces it back through ProduceResult.nonce. The Owner retains (secret_id, version, nonce) alongside the outbound request so the nonce can be re-presented when the matching response arrives.

  • The Helper's response carries the same triple. A well-formed VerifyShareResponseMessage echoes secret_id, version, and nonce from the request, plus the SHA-384 proof hash = SHA-384(stored_share || nonce_be).

  • verification::response::process enforces the binding before the hash check. The library validates a response by calling verification::response::process(request, response, share_content). Before any cryptographic work happens, process checks each of response.nonce, response.secret_id, and response.version against the owner-retained request and returns Error::Verification(VerificationError::ResponseBindingMismatch { field, expected, got }) on the first disagreement — field is one of "nonce", "secret_id", "version". Only after the binding check passes does the SHA-384 computation run, and the digest is recomputed using the owner's nonce (request.nonce), not the helper-supplied response.nonce.

  • The orchestrator owns the retention. DeRecProtocol persists the outstanding challenge through its DeRecStateStore as a StateItem::PendingVerification keyed by channel_id. start(VerifyShares { secret_id, version, target }) saves it before sending the request envelope; on_response loads the pending challenge, then ignores a response that does not bind to it (MessageIgnored { reason: StaleResponse }, challenge kept). A missing result field is an error and also leaves the challenge in place. Only once binding and result both check out does on_response remove the challenge and decide the verdict: a non-OK status is ShareVerifyRejected; a missing proof is VerifySharesFailed { reason: NoProof }; otherwise the recovered VerifyShareRequestMessage is fed to verification::response::process, which decides ShareVerified or ShareVerifyInvalid. Because the challenge lives in the state store rather than process memory, the binding survives a restart when a durable backend is used. Application code driving the orchestrator never touches this state.

  • secret_id must be this instance's own. Verification challenges the Helpers holding this device's shares, so VerifyShares.secret_id has one legal value; any other is refused with Error::InvalidInput rather than ignored.

  • Replay arrives as NoOp. A response with no outstanding entry on its channel — because the entry was already consumed by an earlier response, or because no request was ever sent on this channel — is dropped as DeRecEvent::NoOp rather than processed.

  • A late answer is ignored, not consumed. Re-issuing start(VerifyShares) for the same channel overwrites any in-flight challenge, and the newer nonce wins. A response whose (nonce, secret_id, version) does not match the outstanding entry answers the replaced challenge: it is reported as DeRecEvent::MessageIgnored { reason: StaleResponse } and the entry is kept, so the current challenge's own answer still completes it.

  • A bound response consumes the entry and ends in one verdict. A non-OK status is ShareVerifyRejected, whether or not a proof is held; with no proof stored at that version, VerifySharesFailed { reason: NoProof }; otherwise the hash decides between ShareVerified and ShareVerifyInvalid. A response with no result is malformed: process returns an error and the entry is kept.

  • Primitive-direct callers. Applications that drive verification::request::produce and verification::response::process themselves (e.g. SDK parity tests, custom integrations that bypass the orchestrator) MUST retain the original VerifyShareRequestMessage and pass it back to process when the matching response arrives. The cryptographic contract is identical to the orchestrator path; only the retention machinery differs. See ProduceResult.nonce for the retention story.

target resolves to Paired Helper channels only. Target::All means every Paired Helper channel; an id in Single / Many that names a Pending or unknown channel is dropped, not refused.

Discovery

Discovery is owner-initiated: the Owner asks one or more paired Helpers to enumerate the (secretId, version) pairs they currently hold for this Owner. The Helper replies with the catalog grouped by secretId, each version paired with the human-readable versionDescription supplied when the share was stored. The catalog lists only the versions the Helper still retains — see Version retention.

Preconditions: a confirmed Owner ↔ Helper channel must already exist. Discovery does not require recovery mode — it works against any paired Helper. The Owner role initiates; the Helper role accepts and responds. Reject mode is supported: the Helper application may refuse to disclose its catalog, in which case it replies with a non-Ok response and no secretList content.

target resolves to Paired Helper channels only. Target::All means every Paired Helper channel; an id in Single / Many that names a Pending or unknown channel is dropped, not refused.

Discovery is most commonly the precursor an Owner uses to drive recovery — after re-pairing in recovery mode the Owner has no local record of what each Helper holds and must ask. But the flow is general-purpose: any time the Owner wants an inventory of a Helper's stored shares (routine audit, post-replica reconciliation, drift detection) it can run Discovery against an already-paired channel.

Helpers hold exactly one share per version

A Helper stores one share per (secretId, channelId, version) and knows nothing about replicas — replicaId is absent from helper-bound StoreShareRequestMessages entirely, and the Discovery catalog carries no writer identity. Concurrent writes at the same version are not stored side-by-side: the Helper keeps the first write it sees at a version, and a later write carrying different content is refused with VERSION_CONFLICT 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. A VERSION_CONFLICT therefore means a second writer published concurrently — typically the same user acting on two devices at once. Resolution is the application's: the round has failed and should be republished at a new version. See VERSION_CONFLICT in Messages and Replica conflict resolution.

Wire messages

Discovery uses two messages, both fully specified in the Messages section:

  • GetSecretIdsVersionsRequestMessage — essentially a ping carrying timestamp, plus replyToTransports (tag 4; empty means "reply to the endpoints on file", see routing replies) and an optional replicaId (tag 3) that is present only on the replica path (ReplicaDiscovery) and absent between Owner and Helper.

  • GetSecretIdsVersionsResponseMessage — carries result, secretList (a list of VersionList entries, each with a secretId and a list of VersionEntry values pairing version with versionDescription), timestamp, and an optional replicaId used only on the replica path.

See the field tables under GetSecretIdsVersionsRequestMessage / GetSecretIdsVersionsResponseMessage in Messages for the exact field shapes; they are not duplicated here.

Event surface

On the Helper side, the application sees an ActionRequired event carrying PendingAction::Discovery. Calling accept builds the response from the Helper's ShareStore (grouping the stored (secretId, version) pairs across all channels linked to the requesting channel) and sends it back. Calling reject(action, status, memo) sends a non-Ok response and discloses no catalog content.

On the Owner side, a successful response surfaces as DeRecEvent::SecretsDiscovered { channel_id, secrets } — one SecretVersionEntry per secretId, each containing the (version, description) pairs reported by that Helper.

Recovery

During recovery, the Owner pairs with Helpers again in "recovery mode" (pairing is the same mechanism; software may treat it differently). Once paired in recovery mode, the Owner can request the list of secret_ids and versions held by the Helper for that Owner, then request specific shares with start(RecoverSecret { secret_id, version }).

Each answer settles one of four ways:

  • Refused — the Helper replies with a non-OK status, for example UNKNOWN_SHARE_VERSION when it holds no share for that version. It surfaces as RecoveryShareRefused { channel_id, version, status, memo }; nothing is collected, no reconstruction is attempted, and recovery stays open for the other Helpers.

  • Corrupted on arrival — an OK response whose share does not decode for the requested secret and version, or that exceeds the Owner's own configured maxShareSize and is rejected before being parsed at all (both CorruptionReason::Malformed), or whose Merkle proof does not open to its own commitment root (CorruptionReason::InvalidProof). It surfaces as RecoveryShareCorrupted { channel_id, version, reason } and is not collected.

  • Collected — one share per channel. The collected shares are grouped by (commitment root, ciphertext) and the groups are tried largest first, ties going to the group whose first share arrived earliest; a group of one is never tried. The first group that reconstructs is the Secret. If none does yet, the Owner sees RecoveryShareReceived { channel_id, shares_received }, where shares_received counts collected shares only, and waits for more.

  • Recovered — a group reconstructed and the rebuilt bytes decoded as a Secret: SecretRecovered { secret }, preceded by one RecoveryShareCorrupted { reason: Inconsistent } per collected share outside the winning group. If the rebuilt bytes do not decode as a Secret, the Owner sees RecoveryShareError instead; a corrupted share never causes it.

An honest Helper never sends a corrupted share, so RecoveryShareCorrupted is a sign that the Helper is damaged or compromised. A corrupted share is set aside and never blocks recovery from the honest ones.

Channel linking is one-to-one

A recovering Owner reaches each Helper on a new channel, while the Helper stored its share under the old one. The Helper application, having judged that the new peer is the returning Owner, links the two channels in its ChannelStore; the library never writes links. On a GetShareRequest, the Helper loads the requested version across every channel linked to the one the request arrived on and answers with one share: the first whose secretId matches the request, in the order its share store returns. The library imposes no order, so the share store decides which share is served. GetSecretIdsVersionsRequest reads the same linked set and reports each (secretId, version) once.

This rests on one assumption: a Helper holds at most one share per Owner for a given secretId and version. Each new channel is linked to the single old channel it replaces. The library does not check it. If several channels holding shares for the same Owner are linked to one recovery channel — as happens when one guardian acts as several Helpers for the same Owner, which is discouraged — the Helper still answers with one share. When every recovery channel is answered from the same share, the Owner receives it more than once, counted once, and can fall below the threshold. The application resolves this: either links stay one-to-one, or its share store returns, for each requesting channel, the share intended for it first, in a deterministic order. See One share per Helper.

Restoring operational state

Reconstruction yields the Secret's data but not the live channels: recovery runs over throwaway recovery-mode channels, and SecretRecovered writes nothing. The application shows the recovered Secret to the user, or asks them, before committing it. A device recovering from loss then calls restore(secret, version), which:

  • re-establishes the canonical channels to every Helper and Replica named in the recovered Secret, writing each Helper's roster weight into its channel record. A communication_info of null on a roster entry reads as an empty map. A roster entry with no endpoints gets no channel and is reported as PeerNotRestored { channel_id, replica_id, reason: NoTransports }; the rest of the roster is restored.

  • commits the Secret snapshot at the recovered version, with the roster's threshold as its t (none when the roster predates it, so the builder's t applies). That write is the commit point: every key, id and role, skipped entries included, is validated before any store is written.

  • retires the recovery-mode channels, emitting Unpaired for each and UnpairFailed for any whose unpair request could not be sent (local state is dropped anyway).

restore returns events the application must handle like any other. After it, the device is an operational Owner with two caveats:

  • Restore does not adopt a replica identity. If the recovered roster has a replica group, the next publish needs a configured replica_id the roster names; without one it fails with Error::ReplicaIdNotConfigured and no share reaches any Helper.

  • Verification needs one publish first. restore writes no owner-side tracking shares, so start(VerifyShares) at the recovered version sends no challenge and reports every channel as VerifySharesFailed { reason: NoProof, .. }, because this device holds no reference bytes for that version. One ProtectSecret publishes recovered_version + 1 and writes the tracking shares that make verification work from then on. That publish passes the stored weights unchanged and no threshold, so it splits as the recovered version did; a Helper left out of its weights returns to weight 1.

See Protocol Lifecycle and the restore error surface.

ReplicaDiscovery

ReplicaDiscovery is the replica group's catch-up flow: it asks every other member which version it holds and, if some member is ahead, pulls that state and installs it. Replica-only — it requires a configured replica_id and at least one other group member.

A member is never partially behind. Every replica sync carries the whole Secret and the whole roster, so a stale member simply holds an older version, and any later publish brings it fully current. Convergence is therefore automatic while the group is writing. ReplicaDiscovery closes the remaining gap: a quiet group, where nobody has written since the member came back online, and a member whose fingerprint confirmation came after the source's publish (see Fingerprint cross-confirmation). The device that was away is the one that knows it was away, so it is the device that pulls — no durable per-member sync state is kept anywhere.

Nothing triggers this automatically. The library provides the mechanism; the application chooses when to run it (a user action, a timer, app start, a confirmed pairing).

The exchange reuses the discovery and get-share messages, overloaded on the replica path exactly as StoreShareRequestMessage already is:

  1. The asker sends GetSecretIdsVersionsRequestMessage to every other member, carrying its own replicaId and its primary endpoint in replyToTransports. A member it cannot reach is not waited on.

  2. Each member replies with the one (secretId, version) it holds — a member serves exactly one Secret, unlike a Helper. A member with no snapshot reports nothing and is counted as version 0.

  3. Once every asked member has answered, the asker compares the newest reported version with its own. If it is not newer, the flow ends. Otherwise the member holding it is asked for it via GetShareRequestMessage; ties resolve to the group's Source, then to the lowest replica_id.

  4. That member replies with the whole ReplicaSecretPayload under shareAlgorithm = SHARE_ALGORITHM_REPLICA_SECRET: the Secret, the roster, the share map (every Helper's committed share keyed by channel), and the payload version, which is the version the bytes belong to.

  5. The asker hydrates it at the payload's version, filing the share map as its own tracking shares, so it can verify the group's Helpers exactly as the publisher could. It reports ReplicaSecretInstalled (first copy) or ReplicaSecretReceived (update).

A member reporting an older version than the asker is ignored — the asker is already current with respect to it. The check never turns into a publish: a read-shaped operation that silently wrote to peers would surprise its caller, and that peer's own application is the right place to decide whether being behind matters.

The flow reports ReplicaDiscoveryComplete { local_version, group_version, fetched_from } once every member has answered. group_version is the newest version any member reported, and is 0 when no member answered. fetched_from names the member the state is being pulled from; the hydration event follows when its answer arrives. fetched_from is absent when this device was already current, and no hydration event follows.

A member that is reachable but never answers keeps the check open: no timeout closes it, and starting ReplicaDiscovery again replaces it.

Version conflicts

Two copies of the same version collide; the library reports the collision instead of merging. A member that receives a copy pushed by ProtectSecret at the version it already holds, from a different author, does not hydrate it: it surfaces as ReplicaVersionConflict { channel_id, from_replica_id, secret_id, version, held_author_replica_id, incoming_author_replica_id, secret }, carrying the rival's full state in secret, and nothing is written. The member refuses the push with VERSION_CONFLICT, and the publisher sees ReplicaSyncRejected. An older copy is also refused with VERSION_CONFLICT, but raises no event on the receiver (only NoOp).

ReplicaDiscovery fetches only when a member reports a version newer than the one this device holds, and a newer copy is applied. It therefore never fetches a same-version rival copy and never produces ReplicaVersionConflict. Until the conflict is resolved, the device must not publish again. See What the application must do.

Refused copies

A member checks a whole copy before writing anything, each share-map entry under the rules a Helper applies to a share. A pushed copy that does not decode or is not self-consistent is refused with FORMAT_ERROR, one carrying a share that does not verify with VERIFICATION_FAILED, whatever auto_respond_on_failure says. The member reports ReplicaSecretRefused, and the publisher sees ReplicaSyncRejected with that status. A copy served by a ReplicaDiscovery catch-up is checked the same way; when it is refused, nothing is written and nothing is answered, since the copy is itself the answer to this device's request. The member still reports ReplicaSecretRefused, with from_replica_id naming the member that served the copy.

UnpairReplica

UnpairReplica { replica_id, memo } removes a member from the replica group. Replica-only. replica_id names the member being removed: naming this device is a voluntary departure; naming another is an eviction. A replica_id that names no current member is rejected with Error::InvalidInput rather than silently doing nothing.

Any member may remove any member, the source included, so a lost or stolen source can be removed by the devices that remain. The library checks no role, and could not enforce one, since every member holds the same group key. The application should ask the user before starting this flow, above all when it names the source. The removed member is not asked, and gets no event when it is told to leave. The full lifecycle is in Replica removal.

Removing a replica is not the same operation as unpairing a Helper. Helper unpair deletes a channel record, which is correct because that channel serves exactly one peer. Every replica shares one group channel, so deleting it would sever the whole group. Replica removal is therefore a member-row edit, addressed by replica_id.

The safety invariant

A member tears down only when it has been told to leave and subsequently observes a newer version excluding it. Neither condition alone is sufficient.

Absence from a roster must never, by itself, instruct a member to destroy its copy of the Secret. A publisher that silently omitted a member would otherwise destroy that member's state instead of merely forgetting it. The "told to leave" flag is what keeps an omission bug non-destructive. A removal that is announced and then superseded by a roster that keeps the member leaves no trace.

This is also why the flagged member stays on the distribution list while being absent from the roster — that asymmetry is the mechanism by which an evictee learns it may tear down, and it needs no new message.

Teardown scope

The two sides remove different things:

Party
Removes

Departing member

the whole secret_id partition — group channel, every Helper channel, shares, secrets, user-secret snapshot — and emits SelfRemovedFromGroup { version }

Remaining member

one ReplicaMember row, and emits ReplicaRemoved { replica_id }

A remaining member must not touch the group channel, its key, or any Helper channel. The Secret survives on the remaining members and the Helpers.

The evictee acknowledges before tearing down. Dropping the group key first would leave it unable to encrypt its acknowledgement, failing the publisher's round against a member that behaved correctly.

Source succession

Removing the member that holds ReplicaRole::Source promotes another member. The successor is the first entry of the channel store's replica list that is neither the departing member nor itself flagged Unpairing. The removing device writes the promotion to its own store when it starts the flow, and the roster it publishes to complete the removal carries the new role.

The order is read exactly once, on the single device that runs the removal, and its conclusion travels as roster data. Every other member reads the role from the roster rather than re-deriving it, so implementations on different devices need not agree on order. See the ordering contract.

ReplicaSourceChanged fires on the device that chose the successor, naming it, and on the successor itself when the promoting roster arrives. A member that is neither is unaffected and gets no event — it reads the new source from the roster like any other field. Only the transition is reported; a roster restating an unchanged source is silent.

A source that is the group's only member leaves no successor: the removal proceeds and the group dissolves with it.

Unpair

Unpair ends an Owner ↔ Helper pairing and deletes the relationship data on both sides, subject to external constraints (regulation, service agreement). It is started with start(Unpair { channel_id, memo }).

Owner-initiated only. The initiating node must hold the Owner side of channel_id (its peer is a Helper); otherwise start returns Error::RoleMismatch before anything is sent. A Helper cannot tear down the relationship from the protocol layer; it can only refuse an incoming request. The receiving node likewise refuses an UnpairRequestMessage whose sender is not its Owner. Replica-group members leave through UnpairReplica, not this flow.

start sends one UnpairRequestMessage (memo, timestamp, replyToTransports) and returns UnpairStarted { channel_id, trace_id }. If the send fails, start returns Err instead; there is no *Failed event for this single-channel flow.

What happens to the initiator's local state is set at build time with with_unpair_ack(UnpairAck):

UnpairAck

Initiator behaviour

Required (default)

Keeps the channel, shares and secrets until the Helper answers Ok, then drops them and emits Unpaired. If no answer arrives within Timeouts::unpair_ack (default 60 s), the state is dropped anyway on the next process or tick and Unpaired fires. A non-Ok answer emits UnpairRejected { channel_id, status, memo } and drops nothing: the application decides whether to retry, escalate, or delete locally.

NotRequired

Drops local state right after the request is sent; Unpaired follows UnpairStarted in the same event list. A later answer is ignored.

On the Helper, the request surfaces as ActionRequired with PendingAction::Unpair. accept sends the Ok response, then drops the channel, its shares and its keys, and emits Unpaired. reject(action, status, memo) answers non-Ok and keeps everything.

A response arriving with no unpair outstanding for that channel — a replay, or an answer after the timeout already dropped the state — is a NoOp. UnpairFailed { channel_id, error } is emitted by restore when it cannot send the unpair for a recovery-mode channel it retires; local state is dropped anyway and Unpaired follows.

UpdateChannelInfo

UpdateChannelInfo is a maintenance flow that lets either party of an already-paired Owner ↔ Helper channel broadcast updated communicationInfo and/or transport endpoints to one or more paired peers, without re-pairing. The most common use case is moving to new transport endpoints while keeping the channel — and its established shared key — intact.

The flow is DeRecFlow::UpdateChannelInfo { target, communication_info, own_transports }:

  • communication_info: Option<HashMap<String, String>> — None leaves the peer's stored map untouched. Some(map) replaces it; an empty map clears it. Updates, additions and deletions are all expressed by the difference between the receiver's current map and the supplied one.

  • own_transports: Vec<TransportProtocol> — every endpoint this device can now be reached on, in its own preference order. Empty leaves the peer's stored endpoints untouched; non-empty replaces them outright.

At least one of the two must carry a change; an update with neither is refused with Error::InvalidInput, both by start and by the receiver.

Scope and symmetry

This is the only DeRec flow where either party may initiate: no role gate applies, so an Owner may update its Helpers and a Helper its Owner. It reaches Owner ↔ Helper channels only. target resolves against the node's Helper channel records, and only Paired ones: Target::All means every Paired channel of that kind, and an id in Single / Many naming a Pending or unknown channel is dropped, not refused. The replica group channel is never a target; a replica member announces changes by publishing instead — see On a replica member.

Every other flow (Sharing, Verification, Discovery, Recovery, Unpair) is initiated by the Owner identity; UpdateChannelInfo is the maintenance side-channel that breaks that rule because either side's contact metadata or transport endpoints may legitimately change.

Local-state update precondition (initiator)

The initiator MUST update its own local state before broadcasting the change, otherwise the local node and its peers will disagree about what communicationInfo and endpoints describe this node:

  1. Call protocol.set_communication_info(new_map) and/or protocol.set_own_transports(new_list) to mutate the local node's state. set_own_transports replaces the whole list and validates every entry before storing any: an empty list fails with Error::InvalidInput, a malformed entry or a repeated protocol with Error::Transport, and the previous list is kept.

  2. Then call protocol.start(DeRecFlow::UpdateChannelInfo { target, communication_info, own_transports }) to announce the change to the targeted peers.

Skipping step 1 leaves the local state inconsistent with what the peers are told.

Receiver-side accept does the mutation

When the application calls protocol.accept(action) for a PendingAction::UpdateChannelInfo, the orchestrator writes the new fields onto the receiver's stored channel record automatically. Announced endpoints are filtered by the receiver's transport policy only, exactly as a peer's endpoints are at pairing (see Transport endpoints): every survivor is recorded in the peer's order, and which transports the receiver serves itself plays no part. If no announced endpoint survives, the stored endpoints stay unchanged and accept reports a failed request with UNSUPPORTED_TRANSPORT_PROTOCOL as RequestFailed; the old endpoints still work, so the refusal is deliverable. The Ok response is sent to the endpoints just recorded, so it already targets the new addresses. Calling protocol.reject(action, status, memo) instead sends a non-Ok response and leaves the receiver's stored channel state unchanged.

Setter usage is asymmetric. The initiator calls set_communication_info / set_own_transports before broadcasting; the receiver does NOT call any setter — accept performs the mutation on the stored channel. The local-node setters exist for the initiating side only.

Endpoint-changeover discipline

When broadcasting new endpoints, each receiving peer routes its response (and all subsequent messages) to the NEW endpoints. The initiator MUST therefore:

  1. Bring up the new endpoints and start listening on them before calling start(UpdateChannelInfo).

  2. Keep the old endpoints operational during the changeover. Peers that have not yet processed the update still route to the old addresses; in-flight messages may also be targeted there.

  3. Retire the old endpoints only once every targeted peer has surfaced DeRecEvent::ChannelInfoUpdated (or DeRecEvent::ChannelInfoUpdateRejected), plus a grace window for in-flight traffic.

On a replica member

Replica members do not exchange UpdateChannelInfo. A member's endpoints and communication_info travel in the group roster, and a member's own row is refreshed from its current configuration each time it publishes; every member that receives the publish takes the roster as authoritative. A member that changes either one announces it in two steps:

  1. Call set_own_transports (and/or set_communication_info), then publish a new version with ProtectSecret — the same secrets are fine. Every replica records the member's new row, so any of them can take over immediately, and the Helpers receive a roster that is recoverable with the new values. To have the Helpers answer that round on the new endpoint, build the protocol with with_auto_reply_to(true): every round then carries replyToTransports set to the current own transports. There is no per-round reply-to on ProtectSecret. Without the flag, Helpers answer on the endpoint they hold, which is why the old one keeps serving.

  2. Run UpdateChannelInfo against the Helpers. A Helper cannot read the roster — it holds an encrypted share — so it learns the new endpoint only from this flow.

Until enough peers have the update, keep the old endpoint serving:

  • Advertise only the new endpoint, keep the old one serving. A device advertises at most one endpoint per protocol, so the old one is not listed; it simply keeps answering until peers stop using it.

  • Enough peers, not all. Wait until enough Helpers to recover the Secret, and the replicas the application relies on, have confirmed. Retry the rest; how long the old endpoint stays up is the application's decision.

  • A member that missed step 1 still holds the old row. If it publishes before catching up, its roster carries the old values back to everyone, and its version collides with the new one. It must not publish until it has caught up (see ReplicaDiscovery and Version conflicts).

Wire messages

UpdateChannelInfo uses two messages, both fully specified in the Messages section:

  • UpdateChannelInfoRequestMessage — carries optional communicationInfo and repeated supportedTransports (tag 4; empty means "unchanged"), at least one of which MUST carry a change, plus timestamp. It has no replyToTransports: supportedTransports already serves that role.

  • UpdateChannelInfoResponseMessage — carries result and timestamp.

See the field tables under UpdateChannelInfoRequestMessage / UpdateChannelInfoResponseMessage in Messages for the exact field shapes; they are not duplicated here.

Event surface

On the initiator, start returns one event per resolved target: UpdateChannelInfoStarted { channel_id, trace_id } when the request was sent, or UpdateChannelInfoFailed { channel_id, error } when it could not be; a failure does not stop the fan-out.

On the receiver side, the application sees DeRecEvent::ActionRequired { action: PendingAction::UpdateChannelInfo { channel_id, request, shared_key, trace_id } }. Calling accept persists the new fields onto the stored channel and replies Ok (routed to the newly recorded endpoints); calling reject replies non-Ok and leaves stored state unchanged.

On the initiator side, the peer's Ok response surfaces as DeRecEvent::ChannelInfoUpdated { channel_id }. A non-Ok response surfaces as DeRecEvent::ChannelInfoUpdateRejected { channel_id, status, memo }, where status is the peer's StatusEnum and memo is the peer's human-readable reason. ChannelInfoUpdated also fires on the receiver side once accept has persisted the update — so applications observing either end can treat the event as "this channel's stored metadata is now current."

Timeouts and tick()

Nothing in the protocol runs on its own clock. Deadlines are checked only inside process, before the inbound message is handled, and inside tick(), which does the same work with no message. An idle protocol with a stranded round never closes it.

Timeouts

crate::protocol::types::Timeouts holds four values, set together with with_timeouts. A field left unspecified keeps its default.

Field
Default
Governs

inbound_message

300 s

Staleness boundary for inbound envelopes: a message whose timestamp is older is discarded and reported as MessageIgnored { reason: Expired }. This is the replay-defence window.

sharing_round

60 s

How long a publishing round waits for a peer that has not answered.

unpair_ack

60 s

How long an Unpair initiator under UnpairAck::Required waits for the acknowledgement before dropping local state anyway.

expired_channels

ExpiredChannelCleanup::Enabled { timeout_in_secs: 300 }

When to remove channels still awaiting fingerprint confirmation. The only one that can be Disabled.

One second is the smallest effective unit, because wire timestamps carry whole seconds. Values below one second are clamped to one, so a zero cannot silently disable a timeout.

What each pass does

Every process call and every tick() call runs, in order:

  1. Expired-channel cleanup, if expired_channels is Enabled: every Pending Helper channel and every Pending replica member row (never this device's own row) older than the timeout is removed, with its channel key and pairing material: no key outlives the pairing it was agreed for. On a replica channel the key goes once no member is recorded on it, and this device's own Pending row goes with it when no peer remains. A store failure here is logged and does not fail the call.

  2. Sharing-round timeouts: every Helper still pending past sharing_round is failed with ShareRejected and its proof for the round's version is deleted, and every replica member still pending is reported ReplicaSyncFailed.

  3. Unpair-acknowledgement timeouts: local state is dropped for every unpair older than unpair_ack, with one Unpaired per channel.

  4. The round tally, which turns a fully settled round into SharingComplete (and ReplicaSyncComplete when the round had a replica leg) and clears its state row.

When process then fails on the message itself, the events produced by these steps travel on the error and are not reported again; see When process fails.

With expired_channels set to Disabled, the application drives cleanup itself with remove_expired_channels(older_than_secs), which returns the removed channel ids. It sweeps at the threshold it is given whatever the policy, is not clamped, and removes a channel only when its age is strictly greater than older_than_secs.

No timeout covers an outstanding VerifyShares challenge, a RecoverSecret collection, or a ReplicaDiscovery check: each stays open until it is answered.

Calling tick()

tick() returns the events it produced. It is idempotent: with nothing in flight it touches no state and returns an empty list. Store failures are swallowed the way process swallows them, so the work is retried on the next call. It mutates the same round state an inbound response does, so it must be serialized against process for the same secret_id.

Call it on a schedule — a timer task, a cron tick, a queue heartbeat — at a cadence shorter than sharing_round. A service that rebuilds the protocol per request has no background loop at all, so for it this is not optional. See Concurrency and scheduling for the per-SDK calls and setters.

Last updated