Expand description
macula 12’s DHT records, as macula_record and macula-go sign and verify
them. A record is the signed object {key, tbs, signature} under
MACULA-PQ-RECORD-V1; its tbs holds type, alg, version, created_at,
expires_at and payload, and subject only on a domain type (tags 0x20 to
0xFF). sign refuses a key whose purpose does not fit the type; verify
reads a record’s wire form in the design’s order and keeps its tbs bytes,
so encode sends them unchanged.
A record is named by the key id of its key: the node_id for node records, procedure advertisements, content announcements and station endpoints, and the key id for every other type. A tombstone is named as the type it withdraws.
Structs§
- Content
Announcement - A content announcement’s payload.
- Content
Announcement Options - Where the content is served, then its name, size and chunk count, each
left out when empty or
None;ttl_ms, 0 for the default, 48 hours. - Node
Record - A node record’s payload, as macula_record reads it. A field left out, or
of another kind, is zero, empty or
None. - Node
Record Options - A node record’s optional fields:
station_idisNonefor the node itself; empty text andNonecoordinates are left out;kindis “station” or “daemon”;peersare kept sorted and once each;ttl_msis 0 for the default, 48 hours. - OrgDirectory
- An org directory’s payload: a realm’s statement that the org
org_nameis held by the key with key idorg_key. - Procedure
Advertisement - A procedure advertisement’s payload.
kem_keyis the provider’s KEM key as carried and its id, when the advertisement names one: a verified record’s pair is well formed, the key’s id its own. - Procedure
Advertisement Options - A procedure advertisement’s optional fields: its authorization, the
provider’s KEM key as carried, which the advertisement names with its id
(macula 13, E2E design amendment A1), and
ttl_ms, 0 for the default and maximum, 5 minutes. - Procedure
Delegation - A procedure delegation’s payload: an org’s grant, signed by its org key,
that the node
advertisermay serve procedures under the org. - Record
- A record: unsigned as a builder returns it, or signed or verified, when
signedholds what signing or verifying gave. The payload is a map.subjectnames a domain record’s subject,Nonefor none and on every other type. - Record
Type - A record’s type tag.
- Signed
- What signing or verifying gave a record: the key as carried, its key id, the alg, the tbs bytes, and the signature.
- Station
Endpoint - A station endpoint’s payload: its QUIC port, 0 when it carries none from 1 to 65535, and the hosts it is dialled at.
- Station
Endpoint Options - A station endpoint’s optional fields: the hosts it is dialled at, left
out when none; its ALPN, left out when empty;
ttl_ms, 0 for the default and maximum, 5 minutes. - Tombstone
- A tombstone’s payload: what it withdraws, why, and the withdrawn record’s slot fields.
- Tombstone
Options - A tombstone’s optional fields:
detail, left out when empty, andttl_ms, 0 for the clock tolerance, 5 minutes. - Trust
- What a caller trusts for its realm: the verifier’s profile and the realm
key as carried,
Nonewhen none is pinned. - Verified
- A record
verifyreturned. Onlyverifymakes one.
Enums§
- Authorization
- A procedure advertisement’s provider authorization, as macula_record’s read_authorization/1 reads it.
- Reason
- Why a tombstone withdraws a record.
- Record
Error - The refusals of a record, named as macula_record names them.
Constants§
- CLOCK_
TOLERANCE_ MS - How far a verifier’s clock may be from a record’s created_at and expires_at, 5 minutes.
- MAX_
ENDORSEMENT_ WINDOW_ MS - The longest a realm member endorsement admits its member, 30 days.
- MAX_
RECORD_ BYTES - The longest wire form a record may have, 256 KiB.
- OWN_
NAMESPACE_ PREFIX - Starts the namespace of a node’s own procedures,
~<node_id>/<name>.
Functions§
- content_
key - The storage key every announcement of a content id shares.
- encode
- The wire form of a signed or verified record: its
{key, tbs, signature}map, tbs unchanged. - envelope
- An unsigned record of a domain type, 0x20 to 0xFF, with
subject, livingttl_ms, or 48 hours when 0. An empty subject would name a slot apart from no subject, so it is refused. - in_
own_ namespace - Whether
procedurenames a node’s own namespace,~before its first slash, spelled well or not. - namespace_
node - The node_id a
~namespace names: exactly 64 lowercase hex characters, the one spelling of a node_id in a namespace. - new_
content_ announcement - An unsigned announcement by
announcer_node, which signs it. A content id of another size or tag, or an empty procedure, is refused. - new_
node_ record - An unsigned node record about
node_id, which signs it. A coordinate out of its range, or NaN, is refused. - new_
procedure_ advertisement - An unsigned advertisement, by
advertiser_node, which signs it, ofprocedureinrealm_id, served throughserving_station. It builds no authorization but an org directory and a procedure delegation. - new_
station_ endpoint - An unsigned record of a station’s dialable endpoint. A QUIC port of 0 is refused.
- new_
tombstone - An unsigned tombstone that withdraws
withdrawn: it names the record’s type, version and slot fields, takes its slot, and lives until the record has expired plus the clock tolerance, orttl_mspast its own creation when later, so no replica serves the record again after it lapses. - org_
directory_ key - The storage key of an org directory record.
- own_
namespace - Whether a verified procedure advertisement is in its advertiser’s own
namespace and admissible there:
~<node_id>/<name>where node_id is the advertiser_node verifying bound to its signer, with no authorization. - own_
procedure namein the own namespace ofnode:~<node_id hex>/name.- payload_
bounded - Checks a payload before anything is signed: its encoding is at most 256 KiB, and it nests at most 63 levels, which a record’s tbs leaves it under the decoding rule’s 64.
- procedure_
delegation_ key - The storage key of a procedure delegation.
- procedure_
key - The storage key of a procedure’s advertisements.
- procedure_
org - A procedure’s org namespace: the text before the first
/of its name. A name without a slash, or with_before it, has none; a name starting with a slash is malformed. - read_
content_ announcement - Reads a content announcement’s payload.
- read_
node_ record - Reads a node record’s payload.
- read_
org_ directory - Reads an org directory’s payload.
- read_
procedure_ advertisement - Reads a procedure advertisement’s payload.
- read_
procedure_ delegation - Reads a procedure delegation’s payload.
- read_
station_ endpoint - Reads a station endpoint’s payload.
- read_
tombstone - Reads a tombstone’s payload.
- refresh
rwith a new version, created now, with the same lifetime, signed again withkey.- sign
- Signs
rwithkey, as macula_record’s sign/2 does. Refused, in macula’s order: a key whose purpose does not fit the type; a lifetime that runs backwards or past its type’s maximum; a payload that names a signer other than the key; a tbs or payload a verifier would refuse; and a record over 256 KiB. - station_
endpoint_ key - The storage key of a station’s endpoint record.
- storage_
key - The storage key of
r. A record stored under its signer must be signed or verified. - verify
- Reads a record’s wire form under the verifier’s
profileand clocknow_ms, as macula_record’s verify/3 does, in this order: a wire form over 256 KiB, before anything is decoded; a signed object that carries its key; its signature and alg; a tbs of exactly its fields; created_at no more than 5 minutes ahead and expires_at no more than 5 minutes behind; a lifetime within its type’s maximum; its type’s payload rules; and a payload that names its signer by the key’s id. - verify_
authorization - A caller’s check of a verified procedure advertisement’s provider
authorization against the realm it trusts, at
now_ms. An org procedure needs an org directory and a procedure delegation, and the realm key: the directory must verify, carry the realm key and name the advertisement’s realm and the procedure’s org; the delegation must verify, signed by the org key the directory names, for the advertiser; and the advertisement expires no later than either.