SaltDns. Shaker. Envelope
(Salt v1.0.0)
The envelope Salt sends a Shaker (contract 3.4): an age-encrypted payload, numbered per node and kind, and signed by Salt.
{"type":"envelope","kind":"state"|"certificate","node_id":"<uuid>",
"seq":<integer>,"ciphertext":"<base64url age file>",
"signature":"<base64url Ed25519>"}The signature is over the exact bytes
"shaker-envelope-v1\n" + kind + "\n" + node_id + "\n" +
seq(decimal) + "\n" + SHA-256(ciphertext raw bytes)with the digest appended as 32 raw bytes (the contract writes
SHA-256(ciphertext raw bytes); it is not hex-encoded — see
docs/shaker.md). seq is allocated by an atomic
UPDATE ... RETURNING on the node's per-kind counter, so the number is
persisted as it is taken and two replicas cannot issue the same one. Gaps
are possible (a failed encryption still consumed a number); the contract
only requires that the number increases. A Shaker refuses a number not
higher than the last it accepted for that kind.
Summary
Functions
Takes the next sequence number for a node and kind, in the database.
Allocates the next sequence number for kind, encrypts plaintext (a map,
encoded as JSON) to the node's recipient and signs the result.
The exact bytes Salt signs for an envelope: the fixed line
shaker-envelope-v1, the kind, the node id, the decimal sequence number,
and the raw SHA-256 of the ciphertext.
Types
@type envelope() :: %{required(String.t()) => String.t() | non_neg_integer()}
@type kind() :: :state | :certificate
Functions
Takes the next sequence number for a node and kind, in the database.
The column is a fixed mapping, never caller input.
@spec build(SaltDns.Shaker.Node.t(), kind(), map()) :: {:ok, envelope()} | {:error, term()}
Allocates the next sequence number for kind, encrypts plaintext (a map,
encoded as JSON) to the node's recipient and signs the result.
Returns the wire map, with base64url fields, ready for Jason.encode!/1.
The exact bytes Salt signs for an envelope: the fixed line
shaker-envelope-v1, the kind, the node id, the decimal sequence number,
and the raw SHA-256 of the ciphertext.