๐จ 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
npm install opentrustprotocol



> ๐จ 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
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.
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
- โ
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
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.
- ๐ 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
``typescript
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"
);
`
Transform any data type into neutrosophic judgments:
`typescript
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)});`
| 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 |
`bash`
npm install opentrustprotocol
`typescript
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)}...);๐ Fused Result: T=${fused.T.toFixed(3)}, I=${fused.I.toFixed(3)}, F=${fused.F.toFixed(3)}
console.log();
// 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!');
}
`
`typescript
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)});`
- ๐ 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
`typescript
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();
`
Run the comprehensive test suite:
`bash`
npm test
npm run test:coverage
Run examples:
`bash`
npm run example:mapper
`typescript
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;
}
}
`
`typescript
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});`
});
}
| Operation | Time | Memory |
|-----------|------|--------|
| Judgment Creation | < 5ฮผs | 48 bytes |
| Mapper Application | < 10ฮผs | 96 bytes |
| Fusion (10 judgments) | < 30ฮผs | 384 bytes |
We welcome contributions! Please see our Contributing Guide for details.
`bash`
git clone https://github.com/draxork/opentrustprotocol-js.git
cd opentrustprotocol-js
npm install
npm test
npm run example:mapper
- API Documentation - Complete API reference
- Examples - Real-world usage examples
- Specification - OTP v2.0 specification
OTP is available across multiple platforms with Conformance Seals:
| Platform | Package | Status | Conformance Seals |
|----------|---------|--------|-------------------|
| ๐จ JavaScript | opentrustprotocol | โ
v2.0.0 | โ
REVOLUTIONARY |opentrustprotocol
| ๐ Python | | โ
v2.0.0 | โ
REVOLUTIONARY |opentrustprotocol` | โ
v0.3.0 | โ
REVOLUTIONARY |
| ๐ฆ Rust |
This project is licensed under the MIT License - see the LICENSE file for details.
- 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