Skip to main content

verify_composite

Function verify_composite 

Source
pub fn verify_composite(
    cose_composite_bytes: &[u8],
    expected_ed_vk: &VerifyingKey,
    expected_pq_vk: Option<&MlDsaVerifyingKey>,
    payload: &[u8],
    external_aad: &[u8],
    require_pq: bool,
) -> Result<CompositeVerified>
Expand description

Verify a CBOR-encoded nested COSE composite against a detached payload.

§kid-anchoring

expected_ed_vk is the EdDSA verifying key resolved by the caller. When expected_pq_vk is Some, it is the trust-anchored ML-DSA-65 key — the outer COSE entry’s kid AND signature must verify against it, closing the self-certification gap.

§Policy

  • require_pq = true (Hybrid verifier): the OUTER ML-DSA-65 layer MUST be present and verify against the anchored key over payload ‖ inner_sig, AND the inner EdDSA layer MUST verify over payload. If expected_pq_vk is None, verification fails (no anchor — fail-closed). Stripping the outer layer (outer = null) is rejected.
  • require_pq = false (Classical verifier): only the inner EdDSA layer is required and verified; any outer ML-DSA layer is IGNORED (skip-unknown interop — a Hybrid-signed envelope still verifies via its inner EdDSA).

§Hybrid-alg-id binding (#278)

The inner/outer layers in a Hybrid composite bind the hybrid-composite alg-id into their external_aad (see build_hybrid_external_aad). The verifier reconstructs the inner AAD from the composite’s self-describing shape: if an outer ML-DSA layer is present, the inner was Hybrid-signed → reconstruct the hybrid inner AAD; if the outer is absent (Classical or stripped), reconstruct the bare base AAD. Consequently a Hybrid-signed inner whose outer layer has been STRIPPED (outer = null) fails the inner EdDSA signature check (AAD mismatch) — signature-level non-separability — independent of require_pq.