pub fn generate_conformance_seal(
judgments: &[&NeutrosophicJudgment],
weights: &[f64],
operator_id: &str,
) -> Result<String>Expand description
Generates a Conformance Seal for a fusion operation
This function implements the deterministic algorithm that creates a cryptographic fingerprint proving the fusion operation was performed according to OTP specification.
§Arguments
judgments- Slice of input Neutrosophic Judgmentsweights- Corresponding weights for each judgmentoperator_id- The fusion operator identifier (e.g., “otp-cawa-v1.1”)
§Returns
A SHA-256 hash as a hexadecimal string representing the Conformance Seal
§Errors
Returns ConformanceError if inputs are invalid or serialization fails
§Algorithm
- Validate input lengths match
- Create judgment-weight pairs
- Sort canonically by source_id from last provenance entry
- Serialize to canonical JSON (no spaces, sorted keys)
- Concatenate with operator ID using separator
- Calculate SHA-256 hash
§Example
use opentrustprotocol::{NeutrosophicJudgment, generate_conformance_seal};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let judgment1 = NeutrosophicJudgment::new(0.8, 0.2, 0.0, vec![
("sensor1".to_string(), "2023-01-01T00:00:00Z".to_string())
])?;
let judgment2 = NeutrosophicJudgment::new(0.6, 0.3, 0.1, vec![
("sensor2".to_string(), "2023-01-01T00:00:00Z".to_string())
])?;
let seal = generate_conformance_seal(
&[&judgment1, &judgment2],
&[0.6, 0.4],
"otp-cawa-v1.1"
)?;
println!("Conformance Seal: {}", seal);
Ok(())
}