Skip to main content

Module signed

Module signed 

Source
Expand description

Signed objects (specification §4.1–4.6).

Each object has a canonical encoding (§3.1) starting with its format byte (0x01), a fixed signature context (§3.5) and per-field rules checked on both encode and decode, so an object that encodes also decodes. A Signed<T> only exists after signing or after verifying the signature before decoding (§3.6).

The pure validity rules take the verifier’s state and now_ms as parameters: validate_descriptor / validate_pair (§4.3), verify_chain (§4.6), MemberKeyRegistration::verify_for_host (§4.4) and HostSessionProof::verify_for_client (§4.5).

Structs§

AcceptedState
What a verifier stores per community for anti-rollback (rule 5).
AdmissionSummary
AdmissionSummary = mode u8 ‖ level u8: the owner’s public claim; the host’s policy is authoritative for enforcement.
BotPackage
The signed header of a bot package (§4.9), signed by the publisher key inside it.
ChainHead
Every root key of a verified chain, K₀ (genesis) to Kₙ (current). Only super::verify_chain creates one.
CommunityDescriptor
The community’s public, owner-signed statement. Signed by the current root key.
DelegationRef
DelegationRef = epoch u64 ‖ delegation_hash bytes[32], where delegation_hash is SHA3-256 of the delegation’s canonical bytes (not its signature).
ExportManifest
Signed by the exporting host’s key (and, in a later version, the root key when the owner exports). The key is inside the bytes: an importer trusts it only once it matches a host delegation signed by the community’s root (ADR-0013).
HostDelegation
The root key’s authorisation of one host to operate the community.
HostSessionProof
The host’s proof of key possession in session.welcome. Signed by the host key.
ManifestEntry
One chunk: what it is, its length and its SHA3-256.
MemberKeyRegistration
Proves that the client holds the private key of the member key it registers. Signed by that key.
MemberReauth
Signed by the member key. Binds the challenge to the community, the new host and the delegation epoch it operates under, so a proof made for one host or epoch is useless at another.
ParsedPackage
The parts of a .zbot file, not yet verified.
ReauthExpectation
What the host expects of a reauthentication: the envelope’s community, this host, the epoch it operates under and the connection’s current challenge.
RegistrationExpectation
What the host expects of a registration: the command’s fields and the connection’s current challenge (§4.4).
RootRotation
The replacement of the community’s root key, signed by the old and the new key.
Scopes
Delegation scopes (field 6). Unknown bits are kept for re-encoding, are ignored and grant nothing.
Signed
A signed object whose signature has been made or verified, with its exact bytes.
SignedRootRotation
A rotation with both signatures, unverified (verify with super::verify_chain).
ValidDescriptor
A descriptor that passed rule 1 and the descriptor parts of rule 5.
ValidPair
A (descriptor, delegation) pair valid at the time it was checked, with the state to store. Only validate_pair creates one.
VerifiedPackage
A package whose signature (unless unsigned was allowed), hashes and manifest ids were checked.

Enums§

AdmissionMode
AdmissionSummary.mode.
Discovery
discovery (field 17).
PackageError
A .zbot file that does not verify.
Purpose
Why a member key is registered (field 2). Other values are reserved and rejected.
RegistrationError
A MemberKeyRegistration is not acceptable to the host (specification §4.4).
RotationError
The rotation chain does not verify (specification §4.6). index is 1-based.
SessionProofError
A HostSessionProof is not acceptable to the client (specification §4.5).
SignedError
Signing, verifying, encoding or decoding one signed object failed.
ValidityError
A (descriptor, delegation) pair is not valid (specification §4.3).
VerificationLevel
AdmissionSummary.level: verification level None … Highest (governance.md).

Constants§

APP_ID_MAX
Bytes of app_id (3–64).
CLOCK_SKEW_MS
Clock-skew allowance on delegation validity windows (rule 4), in milliseconds.
ENTRY_NAME_MAX
Bytes per chunk name.
EXPORT_FORMAT
The bundle format this manifest describes.
FORMAT_V1
The format byte of every v1 signed object.
MANIFEST_ENTRIES_MAX
At most this many chunks.
PACKAGE_FORMAT
The package format this header describes.
PACKAGE_MAGIC
The file’s first four bytes.
PACKAGE_VERSION
The container version byte after the magic.
SUPPORTED_WORLDS
The zaun:bot worlds a host built from this crate runs; a package for any other is refused at install and update (it could never load). Kept equal to the bot runtime’s list.
VERSION_MAX
Bytes of version.
WORLD_MAX
Bytes of world.

Traits§

SignedObject
A signed object type: its canonical encoding (format byte first) and its context.

Functions§

claimed_genesis
The claimed genesis key: the first rotation’s old_root, or the descriptor’s root_public_key when the chain is empty (§4.6).
compare_versions
Semantic Versioning precedence of two versions; None when either is invalid. An update must be Ordering::Greater than the installed version (§8.13).
parse_package
Splits a .zbot file into its parts, checking every limit and that nothing trails.
valid_app_id
Lowercase reverse-DNS: [a-z0-9-]+(\.[a-z0-9-]+)+, 3–64 bytes.
valid_version
Semantic Versioning 2.0.0 without build metadata, ≤ 64 bytes.
valid_world
zaun:bot/bot@<semver>, ≤ 64 bytes.
validate_descriptor
Rule 1 and the descriptor parts of rule 5: chain is the full rotation chain from the genesis key (community.rotations), accepted the verifier’s stored state, if any.
validate_pair
Whether a (descriptor, delegation) pair is valid at now_ms (§4.3 rules 1–5). chain is the full rotation chain from the genesis key; accepted is the verifier’s stored state for the community, if any. On success the returned pair carries the state to store.
verify_chain
Verifies a rotation chain from the genesis key (§4.6): genesis must derive community_id; for rotation i (1-based, list order) sig_old verifies under Kᵢ₋₁ before decoding, then community_id, rotation_seq = i, old_root = Kᵢ₋₁, new_suite ≥ the previous suite and sig_new under new_root are checked.
verify_package
Verifies the signature under the header’s publisher key (min_suite 1) before anything else, then both hashes and the manifest’s app_id and version. An all-zero signature is accepted only with allow_unsigned.
write_package
Writes a .zbot file from a signed header and its parts. The caller computed the header’s hashes from these exact manifest and component bytes.
write_unsigned_package
Writes an unsigned development .zbot file (all-zero signature, §4.9).