Function verify_composite
pub fn verify_composite(
cose_composite_bytes: &[u8],
expected_ed_vk: &VerifyingKey,
expected_pq_vk: Option<&VerifyingKey<MlDsa65>>,
payload: &[u8],
external_aad: &[u8],
require_pq: bool,
) -> Result<CompositeVerified, Error>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 overpayload ‖ inner_sig, AND the inner EdDSA layer MUST verify overpayload. Ifexpected_pq_vkisNone, 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.