opentrustprotocol
v3.0.0
Published
๐จ Official JavaScript 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 ou
Maintainers
Readme
๐จ OpenTrust Protocol (OTP) - JavaScript SDK
๐จ REVOLUTIONARY UPDATE: OTP v3.0 introduces Performance Oracle & Circle of Trust
The official JavaScript/TypeScript implementation of the OpenTrust Protocol - The mathematical embodiment of trust itself
๐ REVOLUTIONARY UPDATE: v3.0.0 - Performance Oracle & Circle of Trust
๐ The Zero Pillar: Mathematical Proof of Conformance
OTP v3.0 introduces Conformance Seals - cryptographic SHA-256 hashes that provide mathematical, irrefutable proof that every fusion operation was performed according to the exact OTP specification.
This solves the fundamental paradox: "Who audits the auditor?"
With Conformance Seals, OTP audits itself through mathematics.
๐ฎ The First Pillar: Performance Oracle & Circle of Trust
OTP v3.0 introduces the Performance Oracle - a revolutionary system that enables tracking real-world outcomes and measuring the effectiveness of OTP-based decisions.
The Circle of Trust creates a feedback loop between decisions and outcomes:
- ๐ 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 Revolution
- โ Mathematical Proof: SHA-256 hashes prove 100% conformance to OTP specification
- โ Self-Auditing: OTP verifies its own operations through cryptography
- โ Tamper Detection: Any modification breaks the mathematical proof
- โ Independent Verification: Anyone can verify conformant operations
- โ Decentralized Trust: No central authority needed for verification
๐ 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.
With Conformance Seals, OTP transforms from a trust protocol into the mathematical embodiment of trust itself.
๐ฏ 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 both browser and Node.js environments
๐จ JavaScript SDK Features
๐ Revolutionary Core Components
- Neutrosophic Judgments: Represent evidence as (T, I, F) values where T + I + F โค 1.0
- Conformance Seals: Cryptographic SHA-256 proof of OTP specification compliance
- Fusion Operators: Combine multiple judgments with automatic Conformance Seal generation
- OTP Mappers: Transform raw data into neutrosophic judgments
- Provenance Chain: Complete audit trail with cryptographic verification
๐ Conformance Seals API
import {
generateConformanceSeal,
verifyConformanceSealWithInputs,
createFusionProvenanceEntry,
ConformanceError
} from 'opentrustprotocol';
// Generate a Conformance Seal
const seal = generateConformanceSeal(judgments, weights, "otp-cawa-v1.1");
console.log(`๐ Conformance Seal: ${seal}`);
// Verify mathematical proof
const isValid = verifyConformanceSealWithInputs(fusedJudgment, inputJudgments, weights);
if (isValid) {
console.log('โ
Mathematical proof of conformance verified!');
}
// Create provenance entry with seal
const provenanceEntry = createFusionProvenanceEntry(
"otp-cawa-v1.1",
new Date().toISOString(),
seal,
"Conflict-aware weighted average fusion operation"
);๐ OTP Mapper System (v2.0.0)
Transform any data type into neutrosophic judgments:
import { NumericalMapper, CategoricalMapper, BooleanMapper } from 'opentrustprotocol';
import { NumericalParams, CategoricalParams, BooleanParams } from 'opentrustprotocol';
// DeFi Health Factor Mapping
const healthMapper = new NumericalMapper(new NumericalParams({
id: "defi-health-factor",
version: "1.0.0",
falsityPoint: 1.0, // Liquidation threshold
indeterminacyPoint: 1.5, // Warning zone
truthPoint: 2.0, // Safe zone
clampToRange: true
}));
// Transform health factor to neutrosophic judgment
const judgment = healthMapper.apply(1.8);
console.log(`Health Factor 1.8: T=${judgment.T.toFixed(3)}, I=${judgment.I.toFixed(3)}, F=${judgment.F.toFixed(3)}`);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
npm install opentrustprotocol๐ Quick Start
๐ Revolutionary: Conformance Seals in Action
import {
NeutrosophicJudgment,
conflict_aware_weighted_average,
generateConformanceSeal,
verifyConformanceSealWithInputs
} from 'opentrustprotocol';
// Create judgments with provenance
const judgment1 = new NeutrosophicJudgment(
0.8, 0.2, 0.0,
[{
source_id: 'sensor1',
timestamp: '2023-01-01T00:00:00Z'
}]
);
const judgment2 = new NeutrosophicJudgment(
0.6, 0.3, 0.1,
[{
source_id: 'sensor2',
timestamp: '2023-01-01T00:00:00Z'
}]
);
// **REVOLUTIONARY**: Fuse with automatic Conformance Seal generation
const fused = conflict_aware_weighted_average(
[judgment1, judgment2],
[0.6, 0.4]
);
// Extract the Conformance Seal
const lastEntry = fused.provenance_chain[fused.provenance_chain.length - 1];
const conformanceSeal = (lastEntry as any).conformance_seal;
console.log(`๐ Conformance Seal: ${conformanceSeal.substring(0, 16)}...`);
console.log(`๐ Fused Result: T=${fused.T.toFixed(3)}, I=${fused.I.toFixed(3)}, F=${fused.F.toFixed(3)}`);
// **MATHEMATICAL PROOF**: Verify the seal
const isValid = verifyConformanceSealWithInputs(
fused,
[judgment1, judgment2],
[0.6, 0.4]
);
if (isValid) {
console.log('โ
MATHEMATICAL PROOF OF CONFORMANCE VERIFIED!');
console.log(' The judgment is mathematically proven to be conformant.');
} else {
console.log('โ Conformance verification failed!');
}Real-World Example: DeFi Risk Assessment
import {
NumericalMapper, CategoricalMapper, BooleanMapper,
NumericalParams, CategoricalParams, BooleanParams,
JudgmentData, conflict_aware_weighted_average
} from 'opentrustprotocol';
// 1. Health Factor Mapper
const healthMapper = new NumericalMapper(new NumericalParams({
id: "health-factor",
version: "1.0.0",
falsityPoint: 1.0,
indeterminacyPoint: 1.5,
truthPoint: 2.0,
clampToRange: true
}));
// 2. KYC Status Mapper
const kycMappings = new Map([
["VERIFIED", new JudgmentData(0.9, 0.1, 0.0)],
["PENDING", new JudgmentData(0.3, 0.7, 0.0)],
["REJECTED", new JudgmentData(0.0, 0.0, 1.0)]
]);
const kycMapper = new CategoricalMapper(new CategoricalParams({
id: "kyc-status",
version: "1.0.0",
mappings: kycMappings,
defaultJudgment: null
}));
// 3. SSL Certificate Mapper
const sslMapper = new BooleanMapper(new BooleanParams({
id: "ssl-cert",
version: "1.0.0",
trueMap: new JudgmentData(0.9, 0.1, 0.0),
falseMap: new JudgmentData(0.0, 0.0, 1.0)
}));
// 4. Transform data to judgments
const healthJudgment = healthMapper.apply(1.8);
const kycJudgment = kycMapper.apply("VERIFIED");
const sslJudgment = sslMapper.apply(true);
// 5. Fuse for final risk assessment
const riskAssessment = conflict_aware_weighted_average(
[healthJudgment, kycJudgment, sslJudgment],
[0.5, 0.3, 0.2] // Health factor most important
);
console.log(`DeFi Risk Assessment: T=${riskAssessment.T.toFixed(3)}, I=${riskAssessment.I.toFixed(3)}, F=${riskAssessment.F.toFixed(3)}`);๐๏ธ Architecture
Performance & Reliability
- ๐ Memory Efficient: Optimized for both browser and Node.js
- โก Fast Execution: V8-optimized operations with minimal overhead
- ๐ Thread Safe: Safe concurrent access with proper async handling
- ๐ฆ Minimal Dependencies: Only essential packages for reliability
Mapper Registry System
import { getGlobalRegistry } from 'opentrustprotocol';
const registry = getGlobalRegistry();
// Register mappers
registry.register(healthMapper);
registry.register(kycMapper);
// Retrieve and use
const mapper = registry.get("health-factor");
const judgment = mapper.apply(1.5);
// Export configurations
const configs = registry.export();๐งช Testing
Run the comprehensive test suite:
npm test
npm run test:coverageRun examples:
npm run example:mapper๐ 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
import { Mapper, MapperType, MapperParams, NeutrosophicJudgment } from 'opentrustprotocol';
class CustomMapper implements Mapper {
constructor(private params: MapperParams) {}
apply(inputValue: any): NeutrosophicJudgment {
// Your transformation logic
return new NeutrosophicJudgment(0.8, 0.2, 0.0, []);
}
getParams(): MapperParams {
return this.params;
}
getType(): MapperType {
return MapperType.Custom;
}
validate(): boolean {
// Validate your parameters
return true;
}
}JSON Schema Validation
import { MapperValidator } from 'opentrustprotocol';
const validator = new MapperValidator();
const result = validator.validate(mapperParams);
if (result.valid) {
console.log("โ
Valid mapper configuration");
} else {
result.errors.forEach(error => {
console.log(`โ Validation error: ${error}`);
});
}๐ Why Choose OTP JavaScript SDK?
๐ Performance
- Optimized operations - Minimal runtime overhead
- Memory efficient - Smart garbage collection
- Fast development - Rich TypeScript integration
๐ Safety
- Type safety - Full TypeScript support with strict typing
- Error handling - Comprehensive exception handling
- Data integrity - Immutable provenance chains
๐ง Developer Experience
- Rich ecosystem - Seamless integration with Node.js and browser tools
- Comprehensive docs - Extensive documentation and examples
- Active community - Growing ecosystem and support
๐ Performance Benchmarks
| Operation | Time | Memory | |-----------|------|--------| | Judgment Creation | < 5ฮผs | 48 bytes | | Mapper Application | < 10ฮผs | 96 bytes | | Fusion (10 judgments) | < 30ฮผs | 384 bytes |
๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Setup
git clone https://github.com/draxork/opentrustprotocol-js.git
cd opentrustprotocol-js
npm install
npm test
npm run example:mapper๐ Documentation
- API Documentation - Complete API reference
- Examples - Real-world usage examples
- Specification - OTP v2.0 specification
๐ Ecosystem
OTP is available across multiple platforms with Conformance Seals:
| Platform | Package | Status | Conformance Seals |
|----------|---------|--------|-------------------|
| ๐จ JavaScript | opentrustprotocol | โ
v2.0.0 | โ
REVOLUTIONARY |
| ๐ Python | opentrustprotocol | โ
v2.0.0 | โ
REVOLUTIONARY |
| ๐ฆ Rust | opentrustprotocol | โ
v0.3.0 | โ
REVOLUTIONARY |
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Neutrosophic Logic: Founded by Florentin Smarandache
- JavaScript/TypeScript Community: For the amazing language and ecosystem
- Open Source Contributors: Making trust auditable for everyone
๐ Star this repository if you find it useful!
Made with โค๏ธ by the OpenTrust Protocol Team
