| Crates.io | opentrustprotocol |
| lib.rs | opentrustprotocol |
| version | 3.0.0 |
| created_at | 2025-09-21 21:52:48.630516+00 |
| updated_at | 2025-09-23 05:18:20.898844+00 |
| description | ๐ฆ Official Rust SDK for OpenTrust Protocol - The mathematical embodiment of trust itself. Features neutrosophic judgments, fusion operators, OTP mappers, REVOLUTIONARY Conformance Seals, and Performance Oracle with Circle of Trust for real-world outcome tracking. |
| homepage | https://opentrustprotocol.com |
| repository | https://github.com/draxork/opentrustprotocol-rs |
| max_upload_size | |
| id | 1849236 |
| size | 254,624 |
๐ฆ The official Rust implementation of the OpenTrust Protocol - The MATHEMATICAL EMBODIMENT OF TRUST ITSELF
OTP v3.0.0 introduces:
Every fusion operation now generates a cryptographic fingerprint (SHA-256 hash) that proves the operation was performed according to the exact OTP specification. Additionally, the Performance Oracle system enables tracking real-world outcomes to measure the effectiveness of OTP-based decisions.
This transforms OTP from a trust protocol into the mathematical embodiment of trust itself.
This solves the fundamental paradox: "Who audits the auditor?"
With Conformance Seals, OTP audits itself through mathematics. No more blind trust in implementations - every operation is mathematically provable.
The Performance Oracle is the First Pillar of OTP, enabling the Circle of Trust:
The OpenTrust Protocol (OTP) is a revolutionary framework for representing and managing uncertainty, trust, and auditability in AI systems, blockchain applications, and distributed networks. Built on neutrosophic logic, OTP provides a mathematical foundation for handling incomplete, inconsistent, and uncertain information.
use opentrustprotocol::{NeutrosophicJudgment, conflict_aware_weighted_average, verify_conformance_seal_with_inputs};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create judgments
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())]
)?;
// Fuse judgments (now with automatic Conformance Seal generation)
let fused = conflict_aware_weighted_average(
&[&judgment1, &judgment2],
&[0.6, 0.4]
)?;
// Verify mathematical proof of conformance
let is_mathematically_proven = verify_conformance_seal_with_inputs(
&fused,
&[&judgment1, &judgment2],
&[0.6, 0.4]
)?;
if is_mathematically_proven {
println!("โ
MATHEMATICAL PROOF: This judgment is 100% conformant!");
} else {
println!("โ WARNING: Conformance verification failed!");
}
// Extract the Conformance Seal
let seal = fused.provenance_chain.last().unwrap().conformance_seal.as_ref().unwrap();
println!("๐ Conformance Seal: {}", seal);
Ok(())
}
Transform any data type into neutrosophic judgments:
use opentrustprotocol::*;
// DeFi Health Factor Mapping
let health_mapper = NumericalMapper::new(NumericalParams {
base: BaseMapperParams {
id: "defi-health-factor".to_string(),
version: "1.0.0".to_string(),
mapper_type: MapperType::Numerical,
description: Some("DeFi health factor mapper".to_string()),
metadata: None,
},
falsity_point: 1.0, // Liquidation threshold
indeterminacy_point: 1.5, // Warning zone
truth_point: 2.0, // Safe zone
clamp_to_range: Some(true),
})?;
// Transform health factor to neutrosophic judgment
let judgment = health_mapper.apply(1.8)?;
println!("Health Factor 1.8: T={:.3}, I={:.3}, F={:.3}",
judgment.t, judgment.i, judgment.f);
| Mapper Type | Use Case | Example |
|---|---|---|
| NumericalMapper | Continuous data interpolation | DeFi health factors, IoT sensors |
| CategoricalMapper | Discrete category mapping | KYC status, product categories |
| BooleanMapper | Boolean value transformation | SSL certificates, feature flags |
Add to your Cargo.toml:
[dependencies]
opentrustprotocol = "0.2.0"
use opentrustprotocol::*;
// Create judgments with provenance
let judgment1 = NeutrosophicJudgment::new(
0.8, 0.2, 0.0, // T=0.8, I=0.2, F=0.0
vec![("sensor1".to_string(), "2023-01-01T00:00:00Z".to_string())]
)?;
let judgment2 = NeutrosophicJudgment::new(
0.6, 0.3, 0.1, // T=0.6, I=0.3, F=0.1
vec![("sensor2".to_string(), "2023-01-01T00:00:00Z".to_string())]
)?;
// Fuse judgments with conflict-aware weighted average
let fused = conflict_aware_weighted_average(
&[&judgment1, &judgment2],
&[0.6, 0.4] // weights
)?;
println!("Fused: {}", fused);
use opentrustprotocol::*;
use std::collections::HashMap;
// 1. Health Factor Mapper
let health_mapper = NumericalMapper::new(NumericalParams {
base: BaseMapperParams {
id: "health-factor".to_string(),
version: "1.0.0".to_string(),
mapper_type: MapperType::Numerical,
description: None,
metadata: None,
},
falsity_point: 1.0,
indeterminacy_point: 1.5,
truth_point: 2.0,
clamp_to_range: Some(true),
})?;
// 2. KYC Status Mapper
let mut kyc_mappings = HashMap::new();
kyc_mappings.insert("VERIFIED".to_string(), JudgmentData {
T: 0.9, I: 0.1, F: 0.0,
});
let kyc_mapper = CategoricalMapper::new(CategoricalParams {
base: BaseMapperParams {
id: "kyc-status".to_string(),
version: "1.0.0".to_string(),
mapper_type: MapperType::Categorical,
description: None,
metadata: None,
},
mappings: kyc_mappings,
default_judgment: None,
})?;
// 3. SSL Certificate Mapper
let ssl_mapper = BooleanMapper::new(BooleanParams {
base: BaseMapperParams {
id: "ssl-cert".to_string(),
version: "1.0.0".to_string(),
mapper_type: MapperType::Boolean,
description: None,
metadata: None,
},
true_map: JudgmentData { T: 0.9, I: 0.1, F: 0.0 },
false_map: JudgmentData { T: 0.0, I: 0.0, F: 1.0 },
})?;
// 4. Transform data to judgments
let health_judgment = health_mapper.apply(1.8)?;
let kyc_judgment = kyc_mapper.apply("VERIFIED")?;
let ssl_judgment = ssl_mapper.apply(true)?;
// 5. Fuse for final risk assessment
let risk_assessment = conflict_aware_weighted_average(
&[&health_judgment, &kyc_judgment, &ssl_judgment],
&[0.5, 0.3, 0.2] // Health factor most important
)?;
println!("DeFi Risk Assessment: T={:.3}, I={:.3}, F={:.3}",
risk_assessment.t, risk_assessment.i, risk_assessment.f);
Arc<RwLock<>> for concurrent accessserde, serde_json, and thiserroruse opentrustprotocol::*;
let registry = get_global_registry();
// Register mappers
registry.register(Box::new(health_mapper))?;
registry.register(Box::new(kyc_mapper))?;
// Retrieve and use
let mapper = registry.get("health-factor")?;
let judgment = mapper.apply(1.5)?;
// Export configurations
let configs = registry.export();
Run the comprehensive test suite:
cargo test
Run examples:
cargo run --example mapper_examples
// Create your own mapper by implementing the Mapper trait
struct CustomMapper {
// Your implementation
}
impl Mapper for CustomMapper {
fn apply(&self, input: &dyn std::any::Any) -> Result<NeutrosophicJudgment> {
// Your transformation logic
}
fn get_params(&self) -> &dyn std::any::Any {
// Return your parameters
}
fn get_type(&self) -> MapperType {
// Return your mapper type
}
fn validate(&self) -> Result<()> {
// Validate your parameters
}
}
let validator = MapperValidator::new();
let result = validator.validate(&mapper_params);
if result.valid {
println!("โ
Valid mapper configuration");
} else {
for error in result.errors {
println!("โ Validation error: {}", error);
}
}
| Operation | Time | Memory |
|---|---|---|
| Judgment Creation | < 1ฮผs | 48 bytes |
| Mapper Application | < 2ฮผs | 64 bytes |
| Fusion (10 judgments) | < 5ฮผs | 256 bytes |
We welcome contributions! Please see our Contributing Guide for details.
git clone https://github.com/draxork/opentrustprotocol-rs.git
cd opentrustprotocol-rs
cargo test
cargo run --example mapper_examples
OTP is available across multiple platforms:
| Platform | Package | Status |
|---|---|---|
| Rust | opentrustprotocol |
โ v0.2.0 |
| Python | opentrustprotocol |
โ v1.0.6 |
| JavaScript | opentrustprotocol |
โ v1.0.3 |
This project is licensed under the MIT License - see the LICENSE file for details.