Skip to content

Crypto & keys

Signing

approvo.crypto.signer.Signer

Bases: Protocol

Produces detached signatures. algorithm is a scheme id.

approvo.crypto.signer.Ed25519Signer

In-process Ed25519 signer backed by a raw 32-byte seed.

Keys and trust

approvo.crypto.keys.KeyRef dataclass

approvo.crypto.keys.KeyDirectory

keyid -> KeyRef. The verifier's trust root.

approvo.crypto.keys.keyid_for

keyid_for(public_raw: bytes) -> str

Key id = SHA-256 of the scheme's canonical public bytes.

DSSE envelopes

approvo.crypto.envelope.wrap

wrap(payload: Any, payload_type: str, signers: list) -> dict

Canonicalize payload and sign it with every (synchronous) signer.

approvo.crypto.envelope.unwrap_payload

unwrap_payload(envelope: dict) -> Any

Decode the payload without verifying. Callers must verify separately.

approvo.crypto.envelope.pae

pae(payload_type: str, payload: bytes) -> bytes

DSSE v1 Pre-Authentication Encoding.

approvo.crypto.envelope.signable_bytes

signable_bytes(envelope: dict) -> bytes

Verification

approvo.crypto.verifier.verify_envelope

verify_envelope(envelope: dict, key_dir: KeyDirectory, at_time: str) -> list[str]

Owner ids with a valid signature on envelope as of at_time.

Kept for the common case and for existing callers/tests. For the decision-authorisation rule (per-person key or an authorised decision-issuer key) use :func:decision_authorized.

Canonical serialization

approvo.canonical.canonical_bytes

canonical_bytes(obj: Any) -> bytes

Serialize obj to its unique canonical byte form.

approvo.canonical.canonical_hash

canonical_hash(obj: Any) -> str

Return sha256:<hex> of the canonical bytes of obj.

approvo.canonical.NotCanonicalizable

Bases: TypeError

Raised when a value cannot be canonically serialized.

Time

approvo.clock.Clock

Bases: Protocol

now

now() -> str

Current time as an RFC 3339 UTC string.

approvo.clock.SystemClock

approvo.clock.FixedClock

Deterministic clock for tests.

approvo.clock.to_rfc3339

to_rfc3339(dt: datetime) -> str

approvo.clock.parse_rfc3339

parse_rfc3339(value: str) -> datetime