Expand description
Ed25519 signing and verification for AgentStateGraph policies.
This crate is an opt-in sibling of agentstategraph-policy.
Consumers that never sign policies (the common case in 0.7.x)
don’t pay the ed25519-dalek / sha2 compile-time cost. §2c of
the 0.7.5 plan wires the types exposed here into the MCP server.
§Layering
canonicalizeproduces the deterministic UTF-8 byte representation of aPolicythat is fed to the signer and verifier. Thesignaturefield is stripped before serialization so sign/verify round-trip cleanly once §2b adds the field.PolicySigner/Ed25519Signerproduces(signer_key_id, 64-byte signature)over those bytes.PolicyVerifier/Ed25519Verifierchecks such a pair against aKeyRegistrylookup.
§Canonical-JSON spec choice
This crate uses “sorted keys + no whitespace + UTF-8” rather than
full RFC 8785 JCS. Policy values never contain f64 fields today,
so the extra IEEE-754 canonicalization JCS requires is pure
overhead. See [canonical] for the full contract.
Structs§
- Ed25519
Signer - Default Ed25519 signer. Holds a key id (opaque string the verifier
uses to look up the corresponding
VerifyingKeyin acrate::keys::KeyRegistry) and aSigningKey. - Ed25519
Verifier - Default verifier — looks up a [
VerifyingKey] in the registry and runsed25519_dalek::VerifyingKey::verify_strict. - InMemory
KeyRegistry - Simple in-memory
KeyRegistry. Suitable for tests and for servers that load keys from disk at startup (D4 / pre-GA key rotation is out of scope per the 0.7.5 plan).
Enums§
- Sign
Error - Errors produced by the signing pipeline.
- Verify
Error - Errors produced by the verification pipeline.
Traits§
- KeyRegistry
- Lookup of verifying keys by opaque
signer_key_id. - Policy
Signer - Produces an Ed25519 signature over canonical policy bytes.
- Policy
Verifier - Checks an Ed25519 signature against canonical policy bytes.
Functions§
- canonicalize
- Serialize
policyinto the canonical bytes used as the signing input. Thesignaturekey is removed from the top-level object before serialization; see module docs for the full spec. - canonicalize_
value - Same as
canonicalizebut operates on an arbitraryserde_json::Value. Exposed for tests that want to prove the sort-and-strip behavior without building a fullPolicy.