Skip to main content

Module signed

Module signed 

Source
Expand description

Length-prefixed signed-payload encoding.

Every signed message in freenet-git is constructed by concatenating length-prefixed fields, with the domain prefix as the first field. This makes the encoding self-describing in the trivial sense that no field can be confused with any other field, and makes a domain-version bump syntactically distinguishable from a same-domain message that happened to start with the same bytes.

payload = field(domain)
        || field(repo_key)
        || field(...)
        || ...

field(x) = u32_le(len(x)) || raw(x)

Primitive encodings:

TypeBytes (inside the length prefix)
bool0x00 (false) or 0x01 (true)
u324 bytes, little-endian
u648 bytes, little-endian
[u8; N]the N raw bytes
&[u8] /String/&strthe raw bytes
Option<T>0x00 for None; 0x01 followed by the encoded payload of T

Each one of these primitives is then wrapped in the standard length-prefix envelope when it appears as a field of a payload.

There are no nested structures in any v1 signed payload. If a future version adds nesting, it recursively follows the same length-prefix- everything rule.

Structs§

Builder
A buffer for accumulating a signed payload.

Functions§

build
Convenience: build a payload by chaining mutations on a Builder.