MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / verify_provenance_export

Function verify_provenance_export

atomic-canonical/src/provenance_export.rs:112–128  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

110/// directly from DSSE's `VerifiedPayload`; consume those bytes, never decode
111/// the original envelope again. This checks neither native proofs nor claims.
112pub 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
130fn bounded(bytes: &[u8]) -> Result<(), ExportError> {
131 if bytes.len() > MAX_EXPORT_BYTES {

Calls 6

boundedFunction · 0.85
admit_documentFunction · 0.85
AtomicVerifierClass · 0.85
validate_profileFunction · 0.85
verifyFunction · 0.70
ProfileEnum · 0.50