๐ Official Python 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.
Project description
๐ OpenTrust Protocol (OTP) - Python SDK
๐ REVOLUTIONARY UPDATE: v3.0.0 - Performance Oracle & Circle of Trust
OTP v3.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.
The official Python implementation of the OpenTrust Protocol - The mathematical embodiment of trust itself
๐ 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: Optimized for production environments with minimal overhead
๐ Python 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
๐ Conformance Seals (v2.0.0) - THE REVOLUTION
Mathematical Proof of Conformance
Every fusion operation automatically generates a Conformance Seal - a cryptographic SHA-256 hash that proves the operation was performed according to the exact OTP specification:
from otp import conflict_aware_weighted_average, verify_conformance_seal_with_inputs
# Create judgments
judgment1 = NeutrosophicJudgment(0.8, 0.2, 0.0, [{"source_id": "sensor1"}])
judgment2 = NeutrosophicJudgment(0.6, 0.3, 0.1, [{"source_id": "sensor2"}])
# Fusion automatically generates Conformance Seal
fused = conflict_aware_weighted_average([judgment1, judgment2], [0.6, 0.4])
# Extract the Conformance Seal
seal = fused.provenance_chain[-1]["conformance_seal"]
print(f"๐ Conformance Seal: {seal}")
# Verify mathematical proof of conformance
is_valid = verify_conformance_seal_with_inputs(fused, [judgment1, judgment2], [0.6, 0.4])
print(f"โ
Mathematical proof verified: {is_valid}")
The Revolution:
- Self-Auditing: OTP audits itself through mathematics
- Tamper Detection: Any modification breaks the seal instantly
- Independent Verification: Anyone can verify conformance without trust
- Solves the Paradox: "Who audits the auditor?" - OTP does!
๐ OTP Mapper System (v1.0.6)
Transform any data type into neutrosophic judgments:
from otp import NumericalMapper, CategoricalMapper, BooleanMapper
from otp.types import NumericalParams, CategoricalParams, BooleanParams
# DeFi Health Factor Mapping
health_mapper = NumericalMapper(NumericalParams(
id="defi-health-factor",
version="1.0.0",
falsity_point=1.0, # Liquidation threshold
indeterminacy_point=1.5, # Warning zone
truth_point=2.0, # Safe zone
clamp_to_range=True
))
# Transform health factor to neutrosophic judgment
judgment = health_mapper.apply(1.8)
print(f"Health Factor 1.8: T={judgment.T:.3f}, I={judgment.I:.3f}, F={judgment.F:.3f}")
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
pip install opentrustprotocol
๐ Quick Start
Basic Neutrosophic Judgment
from otp import NeutrosophicJudgment, fuse
# Create judgments with provenance
judgment1 = NeutrosophicJudgment(
T=0.8, I=0.2, F=0.0,
provenance_chain=[{
"source_id": "sensor1",
"timestamp": "2023-01-01T00:00:00Z"
}]
)
judgment2 = NeutrosophicJudgment(
T=0.6, I=0.3, F=0.1,
provenance_chain=[{
"source_id": "sensor2",
"timestamp": "2023-01-01T00:00:00Z"
}]
)
# Fuse judgments with conflict-aware weighted average
fused = fuse.conflict_aware_weighted_average(
judgments=[judgment1, judgment2],
weights=[0.6, 0.4]
)
print(f"Fused: {fused}")
Real-World Example: DeFi Risk Assessment
from otp import *
from otp.types import *
from typing import Dict
# 1. Health Factor Mapper
health_mapper = NumericalMapper(NumericalParams(
id="health-factor",
version="1.0.0",
falsity_point=1.0,
indeterminacy_point=1.5,
truth_point=2.0,
clamp_to_range=True
))
# 2. KYC Status Mapper
kyc_mappings = {
"VERIFIED": JudgmentData(T=0.9, I=0.1, F=0.0),
"PENDING": JudgmentData(T=0.3, I=0.7, F=0.0),
"REJECTED": JudgmentData(T=0.0, I=0.0, F=1.0)
}
kyc_mapper = CategoricalMapper(CategoricalParams(
id="kyc-status",
version="1.0.0",
mappings=kyc_mappings,
default_judgment=None
))
# 3. SSL Certificate Mapper
ssl_mapper = BooleanMapper(BooleanParams(
id="ssl-cert",
version="1.0.0",
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
health_judgment = health_mapper.apply(1.8)
kyc_judgment = kyc_mapper.apply("VERIFIED")
ssl_judgment = ssl_mapper.apply(True)
# 5. Fuse for final risk assessment
risk_assessment = fuse.conflict_aware_weighted_average(
judgments=[health_judgment, kyc_judgment, ssl_judgment],
weights=[0.5, 0.3, 0.2] # Health factor most important
)
print(f"DeFi Risk Assessment: T={risk_assessment.T:.3f}, I={risk_assessment.I:.3f}, F={risk_assessment.F:.3f}")
๐๏ธ Architecture
Performance & Reliability
- ๐ Memory Efficient: Optimized data structures with minimal overhead
- โก Fast Execution: C-optimized operations where possible
- ๐ Thread Safe: Safe concurrent access with proper locking
- ๐ฆ Minimal Dependencies: Only essential packages for reliability
Mapper Registry System
from otp import get_global_registry
registry = get_global_registry()
# Register mappers
registry.register(health_mapper)
registry.register(kyc_mapper)
# Retrieve and use
mapper = registry.get("health-factor")
judgment = mapper.apply(1.5)
# Export configurations
configs = registry.export()
๐งช Testing
Run the comprehensive test suite:
python -m pytest tests/
Run examples:
python examples/mapper_examples.py
๐ 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
from otp.types import Mapper, MapperType, MapperParams
from otp import NeutrosophicJudgment
class CustomMapper(Mapper):
def __init__(self, params: MapperParams):
self.params = params
def apply(self, input_value: any) -> NeutrosophicJudgment:
# Your transformation logic
return NeutrosophicJudgment(T=0.8, I=0.2, F=0.0, provenance_chain=[])
def get_params(self) -> MapperParams:
return self.params
def get_type(self) -> MapperType:
return MapperType.Custom
def validate(self) -> bool:
# Validate your parameters
return True
JSON Schema Validation
from otp import MapperValidator
validator = MapperValidator()
result = validator.validate(mapper_params)
if result.valid:
print("โ
Valid mapper configuration")
else:
for error in result.errors:
print(f"โ Validation error: {error}")
๐ Why Choose OTP Python SDK?
๐ Performance
- Optimized operations - Minimal runtime overhead
- Memory efficient - Smart garbage collection
- Fast development - Rich ecosystem integration
๐ Safety
- Type safety - Full type hints and validation
- Error handling - Comprehensive exception handling
- Data integrity - Immutable provenance chains
๐ง Developer Experience
- Rich ecosystem - Seamless integration with Python tools
- Comprehensive docs - Extensive documentation and examples
- Active community - Growing ecosystem and support
๐ Performance Benchmarks
| Operation | Time | Memory |
|---|---|---|
| Judgment Creation | < 10ฮผs | 64 bytes |
| Mapper Application | < 15ฮผs | 128 bytes |
| Fusion (10 judgments) | < 50ฮผs | 512 bytes |
๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Setup
git clone https://github.com/draxork/opentrustprotocol-py.git
cd opentrustprotocol-py
pip install -e .
pytest
python examples/mapper_examples.py
๐ Documentation
- API Documentation - Complete API reference
- Examples - Real-world usage examples
- Specification - OTP v2.0 specification
๐ Ecosystem
OTP is available across multiple platforms:
| Platform | Package | Status |
|---|---|---|
| Python | opentrustprotocol |
โ v1.0.6 |
| JavaScript | opentrustprotocol |
โ v1.0.3 |
| Rust | opentrustprotocol |
โ v0.2.0 |
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Neutrosophic Logic: Founded by Florentin Smarandache
- Python Community: For the amazing language and ecosystem
- Open Source Contributors: Making trust auditable for everyone
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opentrustprotocol-3.0.0.tar.gz.
File metadata
- Download URL: opentrustprotocol-3.0.0.tar.gz
- Upload date:
- Size: 31.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28c6733b023f8f8600810fd6516b24d627c302f2d44f823923bfdc97cd604930
|
|
| MD5 |
114be4e48999c0a652e63de99ca55a7e
|
|
| BLAKE2b-256 |
366c3f9e70869d282b0e7a92ca63fabbc5cdb913419875f5b1f01ed7ff4cfb59
|
File details
Details for the file opentrustprotocol-3.0.0-py3-none-any.whl.
File metadata
- Download URL: opentrustprotocol-3.0.0-py3-none-any.whl
- Upload date:
- Size: 36.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb876e0a7526c48b89796bc4311c09a779b9bcff9ebeca55153371837d280acd
|
|
| MD5 |
ee736f7630a3c730716a822946070a48
|
|
| BLAKE2b-256 |
a319a1ce30fb43c7a7d3942630c6c4d99372c3c00fa868bcb9a4c88fe2a781d8
|