Secret synchronization
Every member of a replica group holds the same Secret. When the Secret changes on any one member, the others have to be told. This chapter covers the when and the how of that synchronization.
What a Secret looks like
At the protocol level a Secret is a self-contained structured object:
{
"secret_id": "...",
"version": "...",
"secret": {
"helpers": [],
"secrets": [],
"replicas": {
"channel_id": "...",
"shared_key": "...",
"members": [
{ "replica_id": "...", "transports": [], "role": "Source", "communication_info": {} }
]
}
}
}The full field-by-field treatment lives in Secret. What matters for this chapter is that the inner secret field is what changes over time, version increments whenever it does, and a sync round is driven by every such increment. replicas.members names every member, the publisher included, with its endpoints and its ReplicaRole.
When the Secret is synchronized
Every ProtectSecret publishes a new version, and every publish reaches every member. Any member may publish. It derives the version as the one it holds plus one, and sends the new state to every other Paired member — and to every member flagged as leaving, which is how a departing member learns its removal is complete (see Replica removal). There is no batching, no debounce, no opt-out.
The same round fans out the Helper-side VSS shares, so the threshold-recovery path stays consistent with the new Secret. The Helper fan-out is documented in Flows / Sharing; this chapter covers the replica side.
A publish also refreshes the publisher's own roster row from its current configuration — its own transports and communication_info. That is how a member announces a new endpoint to the group: replica members do not exchange UpdateChannelInfo, which reaches helper channels only. A member that changes its endpoint publishes, then runs UpdateChannelInfo against the Helpers. See UpdateChannelInfo.
How the Secret is synchronized
The publishing member sends a StoreShareRequestMessage to every other member. This is the same wire message Helpers receive on the share-distribution path — what differs is what travels in the message's share field:
On a Helper channel,
sharecarries a single VSS share.On a replica channel,
sharecarries aReplicaSecretPayload: the whole Secret — the structured object above — plus the per-Helper share map for the same round, theversion, and the publisher'sauthor_replica_id.
Every member is addressed on one shared group channel, so the channel cannot say who sent a message. Each replica-bound request carries the sender's replicaId, and each acknowledgement carries the responder's replicaId — that is how the publisher tracks the round per member rather than treating two acknowledgements as indistinguishable. A receiver accepts a replicaId only on the channel that member is recorded on and refuses the message otherwise, so a paired Helper cannot pass as a member on its own channel. See Replica-group membership is bound to the channel.
On the receiving member
The receiver compares the incoming version with the one it holds — see Conflict resolution for the full table. A newer version, or a first copy, is applied: the library hydrates it into the stores and acknowledges it, and the application has nothing to install. There is no per-field merge, no diff, no negotiation between members — the publisher's view of the Secret at that version becomes the new state.
Hydration writes:
every Helper channel in the roster, with its key and its weight;
the per-Helper share map, as this device's own owner-side tracking shares under its own partition, at the publisher's
(channel_id, version)keys. That is what lets a member verify the Helpers: a verification proof is computed over the exact bytes a Helper holds, and the map is where a non-publishing member gets them. Each share map entry is checked by the rules a Helper applies to a share;every member, on the group channel, with the role the roster gives it — this device's own row included;
the group key;
the user-secret snapshot at that version, with its
author_replica_idand the roster's thresholdt.
The whole copy is checked before anything is written. A copy that does not decode or is not self-consistent — for example, a share map naming a channel absent from the roster's Helpers — is refused with FORMAT_ERROR, and one carrying a share that does not verify with VERIFICATION_FAILED, whatever auto_respond_on_failure says. Nothing is written; the receiver reports ReplicaSecretRefused and the publisher sees ReplicaSyncRejected.
Hydration adds proofs and never deletes one: a member keeps every proof it receives, including proofs the publisher later drops when a Helper refuses the round or drops the version under a later keepVersion. Freeing that storage is the application's concern. See Proof storage on replicas.
An empty share map is not a defect. A round whose paired Helpers' total weight is below the threshold runs no split, so the publisher distributed and tracked no share; that version stays unverifiable on every device, consistently.
The application learns about the copy through one of two events:
ReplicaSecretInstalled
The first copy for a secret_id this device held no snapshot of. The secret now exists here.
ReplicaSecretReceived
Every later version.
Both carry from_replica_id (the member the copy came from), author_replica_id (who published it), secret_id, version, the decoded secret, and the share map. Neither is a recovery: the copy arrived unsolicited from a member and was applied on receipt.
On the publisher, each member's answer arrives as ReplicaSecretAcked (accepted) or ReplicaSyncRejected (refused). A member the publisher could not send to at all is reported once, at dispatch, as ReplicaSyncFailed.
Catching up a quiet group
Convergence is automatic while the group is writing: every sync carries the whole Secret and the whole roster, so a stale member is brought fully current by any later publish. The gap is a quiet group, where nobody has written since a member came back online.
ReplicaDiscovery closes it:
The device asks every other member which version it holds (
GetSecretIdsVersionsRequeston the group channel). A member it cannot send to is not waited on.Once every asked member has answered, it compares the newest reported version with its own. If no member is strictly newer, it stops and fetches nothing — members reporting an older or equal version are ignored, and the check never turns into a publish.
Otherwise it asks the member holding the newest version for its state (
GetShareRequest). Ties go to the group'sSource, then to the lowestreplica_id.The answer is hydrated exactly as a pushed copy, and reported as
ReplicaSecretInstalledorReplicaSecretReceivedwithfrom_replica_idnaming the member that answered andauthor_replica_idthe original publisher.
The check reports ReplicaDiscoveryComplete { local_version, group_version, fetched_from }. group_version is the newest version any member reported, 0 when none answered. fetched_from names the member asked for its state, or is empty when this device was already current — in which case no hydration event follows. When a fetch happens, ReplicaDiscoveryComplete is reported when the request goes out, and the hydration event when the answer arrives.
A pulled copy reports the serving member's secret_id. Compare it with this device's own to tell an update to the vault you already hold from an offer to adopt a different vault.
Nothing triggers ReplicaDiscovery automatically; the application chooses when to run it — at app start, on a timer, after a member's verify_fingerprint succeeds (see Pairing replicas). It needs a configured replica_id and at least one other member; with none, it does nothing.
When a mixed round reports
A round that targets both Helpers and members reports only once both populations have settled: SharingComplete and ReplicaSyncComplete are emitted together, at that moment.
Members are best-effort: a member that refuses, times out, or could not be reached is reported in ReplicaSyncComplete.behind rather than failing the round, since a member holds a full copy and contributes nothing to the recovery quorum. behind is the application's retry list; the library keeps no durable per-member sync state. But best-effort governs the outcome, not the timing: one unreachable member delays both events by up to the sharing_round timeout, even though the Helpers may have confirmed in milliseconds. Watch the per-peer ShareConfirmed / ReplicaSecretAcked events where promptness matters. See SharingComplete and Concurrency and scheduling.
Before the Helper threshold is met
A replica relationship can exist before any Helper has been paired, or while the paired Helpers' total weight is still below the threshold. In that state the Helper-side fan-out sends nothing, but the replica-side fan-out still happens: every member receives every version, with an empty share map.
The practical effect: a user who pairs a second device as a replica before pairing any Helpers still has a synchronized backup of every secret on the second device. The threshold-recovery path becomes available once the Helpers' total weight reaches the threshold and the next publish carries both the full Secret to members and shares to Helpers.
Re-joining the group after a recovery
A device that lost its local state and recovered the Secret through the Helper quorum does not automatically resume replica synchronization — recovery reconstructs the Secret's data but not the live channels. restore closes that gap: it rebuilds the member rows from the recovered roster, on the group channel and with the group key, and retires the throwaway recovery channels.
Three things follow:
restoreadopts no replica identity. If the roster carries a group, the device can publish only once it is configured with areplica_idthe roster names; otherwise the next publish fails withReplicaIdNotConfigured. Claiming the lost device's identity is the application's decision.restorereturns events. A roster entry with no endpoint gets no channel and is reported asPeerNotRestored; retiring the recovery channels reportsUnpaired, plusUnpairFailedfor any teardown that could not complete.The restored snapshot has no author. An incoming copy of the same version is therefore compared by its user secrets: the same secrets are a re-send, different ones a conflict.
See Recovery transitivity for the paths a device can take to recover, and Protocol Lifecycle for where restore sits in the overall flow.
Last updated