Verify transport and profile using an independently selected exporter key. The envelope's `keyid` never selects a trusted key. The returned bytes come directly from DSSE's `VerifiedPayload`; consume those bytes, never decode the original envelope again. This checks neither native proofs nor claims.
(
envelope_json: &[u8],
trusted_key: &PublicKey,
)
| 110 | /// directly from DSSE's `VerifiedPayload`; consume those bytes, never decode |
| 111 | /// the original envelope again. This checks neither native proofs nor claims. |
| 112 | pub fn verify_provenance_export( |
| 113 | envelope_json: &[u8], |
| 114 | trusted_key: &PublicKey, |
| 115 | ) -> Result<VerifiedPayload, ExportError> { |
| 116 | bounded(envelope_json)?; |
| 117 | // Admit raw bytes before parsing so duplicate members cannot be collapsed. |
| 118 | let envelope: Envelope = serde_json::from_value(crate::jcs::admit_document(envelope_json)?)?; |
| 119 | if envelope.payload_type != PAYLOAD_TYPE { |
| 120 | return Err(ExportError::Profile("wrong payload type")); |
| 121 | } |
| 122 | let verified = dsse::verify(&envelope, &[&AtomicVerifier(trusted_key)], 1)?; |
| 123 | bounded(&verified.payload)?; |
| 124 | let payload: ExportPayload = |
| 125 | serde_json::from_value(crate::jcs::admit_document(&verified.payload)?)?; |
| 126 | validate_profile(&payload)?; |
| 127 | Ok(verified) |
| 128 | } |
| 129 | |
| 130 | fn bounded(bytes: &[u8]) -> Result<(), ExportError> { |
| 131 | if bytes.len() > MAX_EXPORT_BYTES { |