Skip to main content

Module record

Module record 

Source
Expand description

Record values larger than one page, and values sealed per record.

A LogEntry’s op is what every version of this crate reads. Since 0.4 an entry may also carry a Value: then op is only a fallback (empty, or a preview the application chose) and the full value is in the Value, either inline (body) or split into content-addressed chunks (Blob). Older peers ignore the field, keep the fallback and never see a chunk, so nothing they hold changes meaning.

Chunks are ordinary log entries of the companion type chunk_type(typ) (<typ>#chunks), keyed by the BLAKE3 hash of their bytes. They are pulled right after their type (Limits::eager_chunks) or on demand (crate::pull_chunks), and reassembled only when every chunk and the whole value match their hashes.

A type configured RecordOptions::sealed has every value sealed under a key derived for that record from the head epoch key (record_key). Only members of the head rotation hold that key, so a device revoked before the write cannot open it, even with the seed and every older key. Members keep older epoch keys and admitted devices receive them, so values sealed before a rotation stay readable; crate::SyncState::reseal_stale moves them to the head key. Sealing happens before chunking, so chunks of a sealed value are ciphertext.

Since 0.8.4 a value may instead be sealed under a key derived from the type’s SyncKey under the head rotation (scoped_record_key), which a service device granted the type holds (crate::EpochKeys::get_scoped) without any epoch key. The rule (crate::SyncState::seals_scoped): a service device always seals type-scoped; a full device seals type-scoped while an active service device is granted the type (crate::Roster::service_granted) and with the epoch key otherwise, so 0.7.1 to 0.8.3 devices keep reading what it writes when no service device shares the type. Readers try both keys, so no marker goes on the wire. A service device revoked before a rotation gets no scoped key for it and cannot open what is sealed under it.

Structs§

Blob
A chunked payload: its length, BLAKE3 hash, and the chunk hashes in order.
Limits
Per-type size limits for crate::SyncState::write.
RecordOptions
How a record type is written: sealed or not, and its limits.
RecordRef
Which record a sealed value belongs to: its type, record id and writer node.
SealInfo
Which key a sealed payload is under: the rotation key at epoch, and the nonce.
Value
The full value of an entry whose op is only a fallback.

Enums§

RecordValue
What crate::SyncState::read found.

Constants§

CHUNK_MAX
Largest chunk (and inline value) that still fits a page with room to spare.
CHUNK_SUFFIX
Suffix of the companion type that carries a type’s chunks.
VALUE_VERSION
Newest Value format this crate reads.

Functions§

assemble
Reassemble a blob from log’s chunks of typ, checking every chunk hash, the length and the whole hash.
base_type
The type a companion chunk type belongs to.
chunk_type
The companion type holding typ’s chunks.
is_chunk_type
open_record
Open a value sealed for record r.
open_record_scoped
Open a value sealed for record r under a type-scoped key (since 0.8.4).
record_aad
Associated data of a sealed record: type, epoch, rotation, writer node and record id, so a sealed value cannot be moved to another record, type, key or writer.
record_key
Per-record key: HKDF-SHA256(epoch key, salt = user id, info = weirdnet-sync/v1/record/<type>/e<n>/k<rotation id>/<record id>).
scoped_record_aad
Associated data of a record sealed under a type-scoped key (since 0.8.4): as record_aad, under its own label.
scoped_record_key
Per-record key under a type’s SyncKey (since 0.8.4): HKDF-SHA256(SyncKey(type) under rotation id, salt = user id, info = weirdnet-sync/v1/record-scoped/<type>/e<n>/k<rotation id>/<record id>). type_key is crate::rotated_sync_key of the rotation’s epoch key on a full device, or the scoped key a service device holds (crate::EpochKeys::sync_key gives either).
seal_record
Seal plain for record r under rotation id’s epoch key.
seal_record_scoped
Seal plain for record r under rotation id’s type-scoped key (since 0.8.4).
split
Split a payload into chunks of chunk_size; returns the blob and the chunks.

Type Aliases§

Chunk
One chunk of a payload: its BLAKE3 hash and bytes.