Skip to main content

Module jcs

Module jcs 

Source
Expand description

RFC 8785 JSON Canonicalization Scheme — RFC-0031.

Thin wrapper around serde_jcs with aion-typed errors. Use this module when you need JSON bytes that are identical across Rust, Go, Python, JavaScript, and any other JCS-conformant implementation for the same logical document.

This module is additive. Existing canonical_bytes() methods on crate::slsa::InTotoStatement, crate::aibom::AiBom, and crate::oci::OciArtifactManifest keep their current (serde-declaration-order) semantics so historical DSSE-signed envelopes continue to verify. Reach for JCS at new call sites — content-addressed catalogs, transparency-log entries, multi- implementation reproducibility audits.

§Example

use aion_context::jcs;
use serde_json::json;

let v = json!({ "b": 1, "a": 2 });
let bytes = jcs::to_jcs_bytes(&v).unwrap();
// Keys emerge in lexicographic UTF-16 order.
assert_eq!(bytes, b"{\"a\":2,\"b\":1}");

Functions§

canonicalize_json_bytes
Canonicalize existing JSON bytes.
to_jcs_bytes
Serialize any serde::Serialize value to RFC 8785 canonical JSON bytes.