opentrustprotocol

Crates.ioopentrustprotocol
lib.rsopentrustprotocol
version3.0.0
created_at2025-09-21 21:52:48.630516+00
updated_at2025-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.
homepagehttps://opentrustprotocol.com
repositoryhttps://github.com/draxork/opentrustprotocol-rs
max_upload_size
id1849236
size254,624
Robert Glez (@draxork) (draxork)

documentation

https://docs.rs/opentrustprotocol

README

๐Ÿฆ€ OpenTrust Protocol (OTP) - Rust SDK

Crates.io Documentation License: MIT Rust

๐Ÿฆ€ The official Rust implementation of the OpenTrust Protocol - The MATHEMATICAL EMBODIMENT OF TRUST ITSELF

๐Ÿ”ฅ REVOLUTIONARY UPDATE: v3.0.0 - Performance Oracle & Circle of Trust

OTP v3.0.0 introduces:

  • Zero Pillar: Proof-of-Conformance Seals (cryptographic proof of specification compliance)
  • First Pillar: Performance Oracle (Circle of Trust for real-world outcome tracking)

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.

๐Ÿ›ก๏ธ What are Conformance Seals?

  • ๐Ÿ” Cryptographic Proof: SHA-256 hash of the fusion operation
  • โœ… Mathematical Verification: Anyone can verify conformance independently
  • ๐Ÿšจ Tamper Detection: Any modification breaks the seal instantly
  • โšก Self-Auditing: OTP audits itself through mathematics

๐ŸŽฏ The Revolution

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.

๐Ÿ”ฎ What is the Performance Oracle?

The Performance Oracle is the First Pillar of OTP, enabling the Circle of Trust:

  • ๐Ÿ†” Judgment IDs: Unique SHA-256 identifiers for every decision
  • ๐ŸŒ Outcome Tracking: Link decisions with real-world results
  • ๐Ÿ“Š Performance Measurement: Measure calibration and effectiveness
  • ๐Ÿ”„ Learning Loop: Continuous improvement through feedback
  • ๐ŸŽฏ Trust Validation: Prove that OTP decisions lead to better outcomes

๐Ÿ”„ The Circle of Trust

  1. Decision: OTP makes a decision with a unique Judgment ID
  2. Action: The decision is acted upon in the real world
  3. Outcome: The Performance Oracle records the actual result
  4. Learning: The system learns from the decision-outcome pair
  5. Improvement: Future decisions become more accurate and trustworthy

๐Ÿš€ What is OpenTrust Protocol?

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.

๐ŸŽฏ Why OTP Matters

  • ๐Ÿ”’ Trust & Security: Quantify trust levels in AI decisions and blockchain transactions
  • ๐Ÿ“Š Uncertainty Management: Handle incomplete and contradictory information gracefully
  • ๐Ÿ” Full Auditability: Complete provenance chain for every decision
  • ๐ŸŒ Cross-Platform: Interoperable across Python, JavaScript, Rust, and more
  • โšก Performance: Zero-cost abstractions with memory safety guarantees

๐Ÿฆ€ Rust SDK Features

Core Components

  • Neutrosophic Judgments: Represent evidence as (T, I, F) values where T + I + F โ‰ค 1.0
  • Fusion Operators: Combine multiple judgments with conflict-aware algorithms
  • OTP Mappers: Transform raw data into neutrosophic judgments
  • Provenance Chain: Complete audit trail for every transformation

๐Ÿš€ Quick Start with Conformance Seals

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(())
}

๐Ÿ†• OTP Mapper System (v0.2.0)

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

Available Mappers

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

๐Ÿ“ฆ Installation

Add to your Cargo.toml:

[dependencies]
opentrustprotocol = "0.2.0"

๐Ÿš€ Quick Start

Basic Neutrosophic Judgment

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

Real-World Example: DeFi Risk Assessment

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

๐Ÿ—๏ธ Architecture

Memory Safety & Performance

  • ๐Ÿ”’ Memory Safe: No null pointers, no data races
  • โšก Zero-Cost Abstractions: Zero runtime overhead
  • ๐Ÿ”„ Thread Safe: Arc<RwLock<>> for concurrent access
  • ๐Ÿ“ฆ Minimal Dependencies: Only serde, serde_json, and thiserror

Mapper Registry System

use 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();

๐Ÿงช Testing

Run the comprehensive test suite:

cargo test

Run examples:

cargo run --example mapper_examples

๐Ÿ“Š Use Cases

๐Ÿ”— Blockchain & DeFi

  • Risk Assessment: Health factors, liquidation risks
  • KYC/AML: Identity verification, compliance scoring
  • Oracle Reliability: Data source trust evaluation

๐Ÿค– AI & Machine Learning

  • Uncertainty Quantification: Model confidence scoring
  • Data Quality: Input validation and reliability
  • Decision Fusion: Multi-model ensemble decisions

๐ŸŒ IoT & Sensors

  • Sensor Reliability: Temperature, pressure, motion sensors
  • Data Fusion: Multi-sensor decision making
  • Anomaly Detection: Trust-based outlier identification

๐Ÿญ Supply Chain

  • Product Tracking: Status monitoring and verification
  • Quality Control: Defect detection and classification
  • Compliance: Regulatory requirement tracking

๐Ÿ”ง Advanced Features

Custom Mapper Creation

// 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
    }
}

JSON Schema Validation

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);
    }
}

๐ŸŒŸ Why Choose OTP Rust SDK?

๐Ÿš€ Performance

  • Zero-cost abstractions - No runtime overhead
  • Memory safe - No garbage collector, no memory leaks
  • Fast compilation - Optimized for development speed

๐Ÿ”’ Safety

  • Memory safety - Compile-time guarantees
  • Thread safety - Safe concurrent access
  • Type safety - Strong typing prevents errors

๐Ÿ”ง Developer Experience

  • Rich error messages - Clear, actionable feedback
  • Comprehensive docs - Extensive documentation and examples
  • Active community - Growing ecosystem and support

๐Ÿ“ˆ Performance Benchmarks

Operation Time Memory
Judgment Creation < 1ฮผs 48 bytes
Mapper Application < 2ฮผs 64 bytes
Fusion (10 judgments) < 5ฮผs 256 bytes

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

git clone https://github.com/draxork/opentrustprotocol-rs.git
cd opentrustprotocol-rs
cargo test
cargo run --example mapper_examples

๐Ÿ“š Documentation

๐ŸŒ Ecosystem

OTP is available across multiple platforms:

Platform Package Status
Rust opentrustprotocol โœ… v0.2.0
Python opentrustprotocol โœ… v1.0.6
JavaScript opentrustprotocol โœ… v1.0.3

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Neutrosophic Logic: Founded by Florentin Smarandache
  • Rust Community: For the amazing language and ecosystem
  • Open Source Contributors: Making trust auditable for everyone

๐ŸŒŸ Star this repository if you find it useful!

GitHub stars

Made with โค๏ธ by the OpenTrust Protocol Team

Commit count: 27

cargo fmt