Expand description
Compiled-policy distribution + signing (S4 / #570).
The PolicyService (PDP authority) compiles policy into a CompiledPolicy (the TE
matrix plus the lattice generation it is valid for), serializes it canonically, hashes
it, and signs (generation, policy_hash) with the hybrid COSE composite (EdDSA +
ML-DSA-65; design §13a, §14). Nodes (PEPs) load the signed artifact and the
PolicyLoader rejects any policy whose signature does not verify and (per design
§14 / S5 containment backstop) whose hash does not match an approval.
This module is the transport/verification boundary; the per-op hot path (te + avc)
never touches it. Signature verification happens once at load, never per op (design §7,
§13a “never verify-per-op”).
§What S5 owns vs what this owns
- S5: the UCAN→TE compiler that produces the
TeMatrixand the approval signature over(canonical_UCAN_CID, bundle_hash). - S4 (here): wrapping the matrix as a versioned, hashed, signed distributable; and the loader that rejects anything unsigned/mismatched before it can feed an evaluator.
The actual COSE composite sign/verify lives in hyprstream_rpc::crypto::cose_sign; this
module abstracts it behind PolicySigner / PolicyVerifier so the hot-path crate has
no crypto dependency and so tests can use a trivial signer. The production wiring (using
MlDsaSigningKeyStore + Ed25519) is in cose.
Modules§
- cose
- Production signer/verifier adapters over
hyprstream_rpc::crypto::cose_sign.
Structs§
- Compiled
Policy - A compiled, distributable policy artifact: the TE matrix, the S1 lattice it was
compiled against (embedded verbatim), and the generation that binds them.
generationties the matrix to a specific lattice generation (S1) AND is the AVC’s cache-invalidation key — bumping it invalidates every cached decision. - Policy
Approval - An approval record (design §14 containment backstop): the human-approved binding of a
policy generation to its expected hash. The loader accepts ONLY a policy whose recomputed
hash matches an approval for its generation. Even an undetected compiler bug then can’t
smuggle authority past review. S5 produces these (signed
(UCAN_CID, bundle_hash)); here we model the hash-match the loader enforces. - Policy
Loader - PEP side: verify signature + match against an approval, then yield the
CompiledPolicyready to feed acrate::mac::te::LatticeTeEvaluator. Fail-closed: any failure returns an error and NO policy is loaded (the PEP keeps denying). - Signed
Policy - A signed, distributable policy: the canonical policy bytes + a detached composite
signature over
(generation || policy_hash). This is the wire artifact PolicyService publishes and PEPs fetch.
Enums§
- Policy
Dist Error - Errors in compiled-policy distribution. All are load-time; the hot path never sees them.
Traits§
- Policy
Signer - Abstraction over the authority’s signing key (production = hybrid EdDSA+ML-DSA-65 COSE
composite). Implemented in
coseover the existing crypto stack. - Policy
Verifier - Abstraction over signature verification at the loader (production = composite verify with
require_pq = true, fail-closed).
Functions§
- sign_
policy - PolicyService side: compile → hash → sign → distributable artifact.
- signing_
input - The exact bytes that get signed: domain-separated
(generation, policy_hash). Binding the generation prevents a rollback/replay of an older signed matrix under a new generation.