Skip to main content

Module cose_sign1

Module cose_sign1 

Source
Expand description

COSE_Sign1 (RFC 9052) detached-payload signing for the hyprstream SignedEnvelope.

Stage C of Phase 0.5 migrates envelope authentication from a bespoke Ed25519.sign(serialize(envelope)) scheme to standards-based COSE_Sign1 with a detached payload and a domain-separating external_aad.

§Wire shape

Each SignedEnvelope.signatures entry is the CBOR encoding of a COSE_Sign1 structure (see RFC 9052 §4.2). The signed payload is the Cap’n Proto-canonical bytes of the RequestEnvelope, detached — it is not embedded in the COSE structure itself. The signer’s identity and algorithm are conveyed via the protected header (kid, alg).

§external_aad

To prevent schema-confusion (signing one schema’s bytes and replaying them as another schema), external_aad is computed as the CBOR encoding of [envelope_schema_id, inner_type_id] — two Cap’n Proto file/type IDs as u64s. Sender and receiver must agree on these IDs; the verifier passes them in, and a mismatch causes verification to fail with InvalidSignature.

Structs§

ParsedCoseSign1
Parsed COSE_Sign1 with kid + alg extracted from the protected header.

Traits§

CoseSigner
Trait abstracting over a signing key.
CoseVerifier
Trait abstracting over a verifying key.

Functions§

build_external_aad
Build the COSE external_aad for envelope signing.
parse
Parse a CBOR-encoded COSE_Sign1 blob. Does not verify the signature.
peek_kid_alg
Inspect a COSE_Sign1 without verifying it, returning (kid_bytes, alg_int).
sign_detached
Sign payload (detached) with signing_key, producing CBOR-encoded COSE_Sign1 bytes.
sign_ed25519_detached
Concrete Ed25519 detached-signature wrapper for envelope.rs.
verify_detached
Verify a CBOR-encoded COSE_Sign1 against the detached payload and external_aad.
verify_ed25519_detached
Concrete Ed25519 verification wrapper. Reconstructs external_aad from the given schema/inner IDs and verifies the parsed COSE_Sign1’s detached signature against pubkey + payload.