Versioning
The DeRec protocol carries three distinct version concepts that should not be confused:
Protocol version — identifies the schema and flow semantics implemented by the sender. Carried on every
DeRecMessageenvelope.Secret version — a monotonic counter on the protected Secret. Increments by one on every publish round.
Secret-encoding version — a 1-byte prefix on the recoverable Secret bytes identifying how they are serialized. Distinct from both of the above; described under Secret Version below.
This section describes all three, and how they relate to the version of the library that implements them.
Library version and protocol version
The library version identifies a release of the reference implementation. It is currently 0.0.10. Every package — the Rust crates (derec-library, derec-proto, derec-cryptography), @derec-alliance/nodejs, @derec-alliance/web, @derec-alliance/react-native, the .NET package DeRec.Library, and the Go module (tag packages/go/v0.0.10) — is stamped from library/Cargo.toml and always shares that one version.
The protocol version identifies the wire protocol: the protocolVersionMajor / protocolVersionMinor pair written into every DeRecMessage envelope. The current protocol version is 0.0. It is independent of the library version; a library release does not imply a protocol version change.
Every SDK exposes the protocol version it writes:
Rust
derec_library::protocol_version::ProtocolVersion::current() (also the constant protocol_version::CURRENT)
ProtocolVersion { major: u32, minor: u32 }
TypeScript (nodejs / web)
protocol_version()
{ major: number; minor: number }
React Native
protocol_version()
{ major: number; minor: number }
.NET
DeRec.Library.ProtocolVersion.Current()
ProtocolVersion with Major / Minor (uint)
Go
derec.CurrentProtocolVersion()
derec.ProtocolVersion{Major, Minor uint32}
Protocol Version
Each DeRecMessage carries two fields that identify the protocol version used to construct the message:
protocolVersionMajorprotocolVersionMinor
These fields indicate the protocol version implemented by the sender. The protocol version describes the message schemas, protocol flows, and validation rules supported by the implementation.
Purpose
Protocol versioning allows implementations to detect compatibility differences between participants. When an Owner and Helper communicate, both sides may use these fields to determine whether they support the same protocol semantics.
Major and Minor Versions
The protocol separates version numbers into two components:
Major version — used when protocol changes are not backward compatible.
Minor version — used when changes extend the protocol while preserving compatibility with earlier versions.
The protocol specification does not mandate specific compatibility rules. Implementations may choose how strictly they enforce version matching when processing messages. The reference library enforces none — see Library version and protocol version.
Secret Version
The protocol defines a version field associated with the protected Secret. It is not a field of the Secret data model; it travels on every share and Secret-sync message that carries a snapshot (StoreShareRequestMessage.version, DeRecShare.version, ReplicaSecretPayload.version), and the Owner records it with each committed user-secret snapshot.
The version value identifies a specific snapshot of the Secret. The combination of (secret_id, version) identifies a logical state of the Owner identity, and Helpers index their stored shares by (secret_id, channel_id, version). Exactly one share exists per key.
version is a monotonic counter on the Secret. It increments by one on every publish round: the writer derives it as latest_version + 1 from its committed snapshot, and version 1 is the first.
A version has exactly one writer. A recipient stores the first write it sees at a version; a later write carrying different bytes is refused with VERSION_CONFLICT rather than overwriting or coexisting, while a byte-identical re-send is an idempotent retry. Because a single writer always derives version as latest_version + 1, it can never rewrite one of its own versions — receiving that status always means a second writer published concurrently. See Conflict resolution.
Writer attribution is stored with each version on the replica path. The member that published a version is recorded as author_replica_id in its user-secret snapshot and carried to every other member in ReplicaSecretPayload.author_replica_id. A member receiving a pushed copy at a version it already holds compares authors: the same author is a re-send, a different one is a conflict (ReplicaVersionConflict, carrying the incoming copy; nothing is written). The envelope's replicaId names the member that sent the message, which on a catch-up answer need not be the author. Helper-bound messages carry no writer identity at all.
Secret-encoding version (a third, separate concept)
The version counter above is not the same as the encoding version of the recoverable Secret bytes. When a Secret is protected, it is serialized to [ 1-byte version ] · payload, where the leading byte identifies the serialization format. That byte is read before decompression, so a future value can change the compression as well as the schema.
3
Written by every new encode; accepted
gzip-compressed JSON. Each roster entry carries transports: [{ uri, protocol }], every endpoint the peer advertised with its protocol discriminant. role is the string "Source" or "Destination". Since 0.0.9 a Helper entry may carry weight (omitted when 1) and the Secret a threshold (omitted when absent); both are additive, so v3 payloads written earlier decode unchanged.
2
Accepted on decode
gzip-compressed JSON with a single transport_uri per roster entry. Lifted into the v3 shape on decode; an entry whose URI scheme is not recognised decodes with no endpoints, and restore reports it as PeerNotRestored.
1
Rejected
A v1 roster listed only the destination peers, naming the source by a bare id with no endpoint of its own, so a conversion would have to invent one. Payloads written by 0.0.1-alpha.9 or earlier stamp 1; the decoder returns an unsupported-version error.
The encoding version is a property of the format, not of the Secret's content: two different (secret_id, version) snapshots share the same encoding version, and the encoding version only bumps on a breaking change to the recoverable format (in lockstep with the protocol majors that touch the Secret — but it is not the protocol version itself). It also does not appear at all in the protobuf replica-sync message. See Secret → Recoverable encoding for the format and the protocol::types::secret module docs for the normative schema.
Share version retention
A Helper holds at most two versions of a Secret. Each StoreShareRequestMessage carries a keepVersion: the one version, other than the one being shared, the Helper keeps on that channel.
The Owner asks its share store once per round, before sending —
keep_version(secret_id, version)onDeRecShareStore— including the rounds the library starts itself, and sends every Helper the same answer.0keeps no other version. There is no keep-everything value.A
keepVersionequal to or greater thanversionis invalid: the Owner fails the round withSharingError::InvalidKeepVersion(code67) before sending, and a Helper refuses such a request withFORMAT_ERROR.The Helper deletes every other version only after storing the incoming share, and only when the request is at least as new as every version it holds on that channel. A replayed older request's
keepVersionis ignored, and the incoming share is never deleted.Discovery then reports only the versions a Helper retained.
When a Helper confirms a version, the Owner deletes its own proofs for that channel other than the confirmed version and
keepVersion, so it never challenges a Helper for a version the Helper dropped.
Replica pushes never consult keep_version and always send 0. See Version retention for the flow and a worked example, and Owner keep version for the store contract.
Protocol Evolution
Independent implementations of the DeRec protocol may evolve over time. Implementations may add new message fields, introduce additional validation rules, or support new capabilities.
When interacting with other implementations, systems should ensure that both parties support compatible protocol behavior before executing protocol flows.
The protocol does not currently define a formal protocol version negotiation mechanism. Implementations may perform compatibility checks during pairing or session establishment; the reference library performs none.
Backward Compatibility
Protocol evolution should preserve interoperability with existing implementations whenever possible.
Backward compatibility may be maintained through practices such as:
Maintaining existing message fields and semantics
Adding new fields as optional rather than mandatory
Ensuring that older implementations can safely ignore fields they do not recognize
Preserving field numbers in serialized message schemas
These practices allow newer implementations to interact with older ones when the protocol behavior remains compatible.
Forward Compatibility
Forward compatibility allows older implementations to process messages generated by newer implementations without failing unexpectedly.
Structured message formats such as protobuf support forward compatibility by allowing unknown fields to be ignored during decoding.
However, if a protocol flow depends on behavior that an older implementation does not support, the interaction may fail due to validation errors or unsupported functionality.
Schema Evolution
Protocol message schemas may change over time as the protocol evolves. Safe schema evolution requires careful management of serialized message formats.
Recommended practices include:
Adding new fields as optional
Avoiding changes to the meaning of existing fields
Reserving field numbers when removing fields
Preserving field numbering to maintain serialization compatibility
These practices ensure that message serialization remains stable across protocol updates.
Compatibility Considerations
Implementations should assume that different versions of DeRec software may coexist within the ecosystem.
Systems should therefore detect incompatible behavior early and fail gracefully when interoperability cannot be guaranteed.
Compatibility checks should occur before executing protocol flows that depend on specific message structures or capabilities.
Design Implications
Versioning allows the DeRec protocol and its implementations to evolve without disrupting existing deployments.
The version field identifies the share referenced in protocol interactions, while protocol evolution governs how implementations extend or modify behavior over time.
Careful version management enables independent implementations to upgrade safely while preserving interoperability across the ecosystem.
Deprecations
ML-KEM decapsulation keys stored in the 3168-byte expanded form
0.0.8
0.0.13
Nothing now. New pairing secrets store the 64-byte seed form; secrets stored before 0.0.8 hold the expanded form and are still accepted, with a warning under the logging feature. A pairing started before 0.0.8 that is still pending at 0.0.13 can no longer complete: re-create its contact.
Security advisories
Some releases fix defects that affect data exchanged before the upgrade. The list, with what an application must do about each, is kept under Security advisories in the trust model. Currently:
0.0.6 — every message on a channel was encrypted under the same AES-GCM nonce. Fixed; old and new peers interoperate, but traffic already exchanged stays exposed. Re-pair any channel whose earlier traffic must be treated as compromised.
0.0.6 — a replica destination acted on its source's roster before confirming the fingerprint.
0.0.8 — a forked process could repeat its parent's random values, including channel message nonces. Every nonce, seed, and random id is now drawn from the operating system generator.
0.0.9 — a forged share could pass verification. The Merkle commitment is now domain-separated; shares made before 0.0.9 no longer decode, so publish a new version after upgrading.
0.0.9 — a response could go to a
reply_toendpoint the transport policy refused. Responses now use only the allowed entries and fall back to the channel's recorded endpoints.0.0.10 — a paired Helper could act as a replica-group member by naming one in a message body on its own channel. A body naming a member is now accepted only on that member's channel.
0.0.10 — a failed fingerprint comparison left a usable channel, and the expired-channel sweep left the channel key behind. A mismatch now revokes the
Pendingpairing, and the sweep removes the key.0.0.10 — a man-in-the-middle could search offline for a key contribution whose fingerprint matched. The contact creator now commits to a random nonce before the responder contributes; 0.0.9 and 0.0.10 peers cannot pair.
Last updated