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. - Record
Options - How a record type is written: sealed or not, and its limits.
- Record
Ref - Which record a sealed value belongs to: its type, record id and writer node.
- Seal
Info - Which key a sealed payload is under: the rotation
keyatepoch, and the nonce. - Value
- The full value of an entry whose
opis only a fallback.
Enums§
- Record
Value - What
crate::SyncState::readfound.
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
Valueformat this crate reads.
Functions§
- assemble
- Reassemble a blob from
log’s chunks oftyp, 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
runder 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_keyiscrate::rotated_sync_keyof the rotation’s epoch key on a full device, or the scoped key a service device holds (crate::EpochKeys::sync_keygives either). - seal_
record - Seal
plainfor recordrunder rotationid’s epoch key. - seal_
record_ scoped - Seal
plainfor recordrunder rotationid’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.