oas-crypto · jcs
Declared module signatures, types, configuration, and source documentation.
Source: oas/oas/oas-crypto/src/jcs.rs. SHA-256: 986712ea5cf59171c3bbecd9190179fa28b95600fc589bbb9c5368fd06f00e35.
This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.
jcs::canonicalize
Canonicalizes a JSON value using JCS (RFC 8785).
Produces a deterministic byte representation where object keys are sorted lexicographically and no insignificant whitespace is present.
Arguments
value- A [serde_json::Value] to canonicalize.
Returns
The canonical JSON bytes.
Errors
Returns [CryptoError::CanonicalizationFailed] if serialization fails.
Examples
use oas_crypto::jcs::canonicalize;
use serde_json::json;
let value = json!({"b": 1, "a": 2});
let canonical = canonicalize(&value).unwrap();
let s = String::from_utf8(canonical).unwrap();
assert_eq!(s, r#"{"a":2,"b":1}"#);pub fn canonicalize(value: &serde_json::Value) -> Result<Vec<u8>, CryptoError>;Source line: 38.
jcs::canonicalize_to_string
Canonicalizes a JSON value and returns it as a UTF-8 string.
Arguments
value- A [serde_json::Value] to canonicalize.
Returns
The canonical JSON as a string.
Errors
Returns [CryptoError::CanonicalizationFailed] if serialization fails.
Examples
use oas_crypto::jcs::canonicalize_to_string;
use serde_json::json;
let value = json!({"z": "last", "a": "first"});
let s = canonicalize_to_string(&value).unwrap();
assert_eq!(s, r#"{"a":"first","z":"last"}"#);pub fn canonicalize_to_string(value: &serde_json::Value) -> Result<String, CryptoError>;Source line: 68.