smartledger-bsv 3.3.1 → 3.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +211 -83
- package/README.md +266 -71
- package/bsv-covenant.min.js +26 -3
- package/bsv-gdaf.min.js +11 -9
- package/bsv-ltp.min.js +10 -8
- package/bsv-script-helper.min.js +2 -2
- package/bsv-security.min.js +3 -24
- package/bsv-shamir.min.js +2 -2
- package/bsv-smartcontract.min.js +10 -8
- package/bsv.bundle.js +9 -9
- package/bsv.min.js +10 -8
- package/build/webpack.bundle.config.js +2 -2
- package/build/webpack.config.js +2 -2
- package/build/webpack.covenant.config.js +2 -2
- package/build/webpack.gdaf.config.js +6 -43
- package/build/webpack.script-helper.config.js +2 -2
- package/build/webpack.security.config.js +2 -2
- package/build/webpack.smartcontract.config.js +2 -2
- package/bundle-entry.js +1 -341
- package/covenant-entry.js +1 -44
- package/docs/DOCUMENTATION_REVIEW_REPORT.md +295 -0
- package/docs/MODULE_REFERENCE_COMPLETE.md +330 -0
- package/docs/README.md +107 -79
- package/docs/advanced/LEGAL_TOKEN_PROTOCOL.md +411 -0
- package/docs/advanced/SMART_CONTRACT_GUIDE.md +1255 -0
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +851 -0
- package/docs/api/LTP.md +334 -0
- package/docs/getting-started/INSTALLATION.md +410 -0
- package/docs/getting-started/QUICK_START.md +180 -0
- package/docs/migration/FROM_BSV_1_5_6.md +260 -0
- package/docs/technical/GDAF_DEVELOPER_INTERFACE.md +187 -0
- package/docs/technical/GDAF_IMPLEMENTATION_COMPLETE.md +190 -0
- package/docs/technical/SHAMIR_INTEGRATION_SUMMARY.md +165 -0
- package/docs/technical/roadmap.md +1250 -0
- package/docs/technical/trust_law.md +142 -0
- package/gdaf-entry.js +2 -54
- package/index.js +32 -0
- package/ltp-entry.js +2 -92
- package/package.json +5 -3
- package/script-helper-entry.js +1 -49
- package/security-entry.js +1 -70
- package/shamir-entry.js +1 -173
- package/smartcontract-entry.js +1 -133
- package/tests/test_builtin_verify.js +117 -0
- package/tests/test_debug_integration.js +71 -0
- package/tests/test_ecdsa_little.js +70 -0
- package/tests/test_smartverify_der.js +110 -0
- package/utilities/blockchain-state.js +155 -155
- package/utilities/blockchain-state.json +103293 -5244
- package/utilities/miner-simulator.js +354 -358
- package/utilities/mock-utxo-generator.js +54 -54
- package/utilities/raw-tx-examples.js +120 -122
- package/utilities/success-demo.js +104 -105
- package/utilities/transaction-examples.js +188 -188
- package/utilities/utxo-manager.js +91 -91
- package/utilities/wallet-setup.js +79 -80
- package/utilities/working-signature-demo.js +108 -110
- package/SECURITY.md +0 -75
- package/architecture_demo.js +0 -247
- package/build/bsv-covenant.min.js +0 -10
- package/build/bsv-script-helper.min.js +0 -10
- package/build/bsv-security.min.js +0 -31
- package/build/bsv-smartcontract.min.js +0 -39
- package/build/bsv.bundle.js +0 -39
- package/build/bsv.min.js +0 -39
- package/complete_ltp_demo.js +0 -511
- package/shamir_demo.js +0 -121
- package/simple_demo.js +0 -204
- package/validation_test.js +0 -97
- /package/docs/{ADVANCED_COVENANT_DEVELOPMENT.md → advanced/ADVANCED_COVENANT_DEVELOPMENT.md} +0 -0
- /package/docs/{CUSTOM_SCRIPT_DEVELOPMENT.md → advanced/CUSTOM_SCRIPT_DEVELOPMENT.md} +0 -0
- /package/docs/{block.md → api/BLOCKS.md} +0 -0
- /package/docs/{ecies.md → api/ECIES.md} +0 -0
- /package/docs/{networks.md → api/NETWORKS.md} +0 -0
- /package/docs/{script.md → api/SCRIPTS.md} +0 -0
- /package/docs/{transaction.md → api/TRANSACTIONS.md} +0 -0
- /package/docs/{unspentoutput.md → api/UTXO.md} +0 -0
- /package/{test_shamir.js → tests/test_shamir.js} +0 -0
- /package/{test_standalone_shamir.html → tests/test_standalone_shamir.html} +0 -0
package/docs/README.md
CHANGED
|
@@ -1,84 +1,112 @@
|
|
|
1
1
|
# SmartLedger-BSV Documentation
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- **
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
1.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
###
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
###
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- **
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
- **
|
|
56
|
-
- **
|
|
57
|
-
- **
|
|
58
|
-
- **
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
- **
|
|
64
|
-
- **
|
|
65
|
-
- **
|
|
66
|
-
- **
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
3
|
+
**The Standard Bitcoin SV Library - Enhanced, Hardened, and Extended**
|
|
4
|
+
|
|
5
|
+
SmartLedger-BSV is a fully backward-compatible extension of bsv@1.5.6 with elliptic curve hardening and comprehensive additional modules for modern Bitcoin SV development.
|
|
6
|
+
|
|
7
|
+
## 🎯 **What Makes SmartLedger-BSV the Standard**
|
|
8
|
+
|
|
9
|
+
- **✅ 100% Backward Compatible** with bsv@1.5.6 - Drop-in replacement
|
|
10
|
+
- **🛡️ Security Hardened** - Enhanced elliptic curve implementations
|
|
11
|
+
- **📦 12 Modular Loading Options** - Use only what you need
|
|
12
|
+
- **⚖️ Legal Compliance Ready** - Built-in Legal Token Protocol (LTP)
|
|
13
|
+
- **🌐 Digital Identity Native** - W3C standard DIDs and Verifiable Credentials
|
|
14
|
+
- **🔐 Enterprise Security** - Shamir Secret Sharing and advanced cryptography
|
|
15
|
+
- **🔒 Smart Contract Framework** - Complete covenant development toolkit
|
|
16
|
+
- **📚 Production Ready** - Comprehensive documentation and examples
|
|
17
|
+
|
|
18
|
+
## 📚 **Documentation Structure**
|
|
19
|
+
|
|
20
|
+
### 🚀 **Getting Started**
|
|
21
|
+
Perfect for developers new to Bitcoin SV or migrating from other libraries.
|
|
22
|
+
|
|
23
|
+
- [**Quick Start Guide**](getting-started/QUICK_START.md) - Get running in 2 minutes
|
|
24
|
+
- [**Installation & Setup**](getting-started/INSTALLATION.md) - All installation methods
|
|
25
|
+
- [**Migration from bsv@1.5.6**](migration/FROM_BSV_1_5_6.md) - Seamless upgrade path
|
|
26
|
+
- [**Migration from BitcoinJS**](migration/FROM_BITCOINJS.md) - Switch from BitcoinJS-lib
|
|
27
|
+
- [**First Transaction**](getting-started/FIRST_TRANSACTION.md) - Hello World example
|
|
28
|
+
|
|
29
|
+
### 📖 **Core API Guides**
|
|
30
|
+
Complete guides for standard Bitcoin SV operations.
|
|
31
|
+
|
|
32
|
+
- [**Transactions**](api/TRANSACTIONS.md) - Create, sign, and broadcast transactions
|
|
33
|
+
- [**Addresses & Keys**](api/ADDRESSES_KEYS.md) - Generate and manage Bitcoin addresses
|
|
34
|
+
- [**Scripts**](api/SCRIPTS.md) - Bitcoin Script creation and execution
|
|
35
|
+
- [**Networks**](api/NETWORKS.md) - Mainnet, testnet, and custom networks
|
|
36
|
+
- [**ECIES Encryption**](api/ECIES.md) - Elliptic Curve encryption/decryption
|
|
37
|
+
- [**Message Signing**](api/MESSAGE_SIGNING.md) - Sign and verify messages
|
|
38
|
+
- [**HD Wallets**](api/HD_WALLETS.md) - Hierarchical Deterministic wallets
|
|
39
|
+
|
|
40
|
+
### � **Advanced Features**
|
|
41
|
+
Unique capabilities that set SmartLedger-BSV apart.
|
|
42
|
+
|
|
43
|
+
- [**Legal Token Protocol (LTP)**](advanced/LEGAL_TOKEN_PROTOCOL.md) - Property rights & obligations
|
|
44
|
+
- [**Global Digital Attestation (GDAF)**](advanced/DIGITAL_ATTESTATION.md) - DIDs & credentials
|
|
45
|
+
- [**Shamir Secret Sharing**](advanced/SHAMIR_SECRET_SHARING.md) - Threshold cryptography
|
|
46
|
+
- [**Smart Contract Framework**](advanced/SMART_CONTRACT_GUIDE.md) - Complete covenant development
|
|
47
|
+
- [**UTXO Management**](advanced/UTXO_MANAGER_GUIDE.md) - Advanced UTXO operations
|
|
48
|
+
- [**Custom Script Development**](advanced/CUSTOM_SCRIPT_DEVELOPMENT.md) - Build custom Bitcoin scripts
|
|
49
|
+
|
|
50
|
+
### 🎓 **Developer Guides**
|
|
51
|
+
Step-by-step tutorials for common development patterns.
|
|
52
|
+
|
|
53
|
+
- [**Building a Wallet**](guides/BUILDING_WALLET.md) - Complete wallet implementation
|
|
54
|
+
- [**Payment Processing**](guides/PAYMENT_PROCESSING.md) - Accept Bitcoin payments
|
|
55
|
+
- [**Multi-signature Transactions**](guides/MULTISIG_TRANSACTIONS.md) - Multi-party security
|
|
56
|
+
- [**Atomic Swaps**](guides/ATOMIC_SWAPS.md) - Trustless exchanges
|
|
57
|
+
- [**Micropayment Channels**](guides/MICROPAYMENT_CHANNELS.md) - Payment channels
|
|
58
|
+
- [**Data Storage on BSV**](guides/DATA_STORAGE.md) - Store data on-chain
|
|
59
|
+
|
|
60
|
+
### 🔬 **Advanced Development**
|
|
61
|
+
Production-ready patterns and advanced use cases.
|
|
62
|
+
|
|
63
|
+
- [**Covenant Development**](advanced/ADVANCED_COVENANT_DEVELOPMENT.md) - Production covenant patterns
|
|
64
|
+
- [**Smart Contract Security**](advanced/SMART_CONTRACT_SECURITY.md) - Security best practices
|
|
65
|
+
- [**Performance Optimization**](advanced/PERFORMANCE_OPTIMIZATION.md) - Scale your applications
|
|
66
|
+
- [**Testing Strategies**](advanced/TESTING_STRATEGIES.md) - Comprehensive testing
|
|
67
|
+
- [**Production Deployment**](advanced/PRODUCTION_DEPLOYMENT.md) - Deploy with confidence
|
|
68
|
+
|
|
69
|
+
### 📋 **Examples & Templates**
|
|
70
|
+
Ready-to-use code examples and project templates.
|
|
71
|
+
|
|
72
|
+
- [**Basic Examples**](../examples/basic/) - Simple transaction examples
|
|
73
|
+
- [**Smart Contract Examples**](../examples/covenants/) - Covenant patterns
|
|
74
|
+
- [**Advanced Examples**](../examples/covenants2/) - Production patterns
|
|
75
|
+
- [**Project Templates**](examples/TEMPLATES.md) - Starter projects
|
|
76
|
+
|
|
77
|
+
### 🔧 **Troubleshooting & Support**
|
|
78
|
+
Solutions to common issues and getting help.
|
|
79
|
+
|
|
80
|
+
- [**Common Issues**](troubleshooting/COMMON_ISSUES.md) - Frequently encountered problems
|
|
81
|
+
- [**Error Reference**](troubleshooting/ERROR_REFERENCE.md) - Complete error guide
|
|
82
|
+
- [**Performance Issues**](troubleshooting/PERFORMANCE_ISSUES.md) - Optimization tips
|
|
83
|
+
- [**Browser Compatibility**](troubleshooting/BROWSER_COMPATIBILITY.md) - Cross-browser support
|
|
84
|
+
- [**Getting Support**](troubleshooting/GETTING_SUPPORT.md) - Community and help
|
|
85
|
+
|
|
86
|
+
## 🔗 **Quick Navigation**
|
|
87
|
+
|
|
88
|
+
**I want to...**
|
|
89
|
+
- **Get started quickly** → [Quick Start Guide](getting-started/QUICK_START.md)
|
|
90
|
+
- **Migrate from bsv@1.5.6** → [Migration Guide](migration/FROM_BSV_1_5_6.md)
|
|
91
|
+
- **Learn smart contracts** → [Smart Contract Guide](advanced/SMART_CONTRACT_GUIDE.md)
|
|
92
|
+
- **Use legal tokens** → [Legal Token Protocol](advanced/LEGAL_TOKEN_PROTOCOL.md)
|
|
93
|
+
- **Implement digital identity** → [Digital Attestation Guide](advanced/DIGITAL_ATTESTATION.md)
|
|
94
|
+
- **Build a production app** → [Advanced Development](advanced/)
|
|
95
|
+
- **See working examples** → [Examples Directory](../examples/)
|
|
96
|
+
- **Get help** → [Troubleshooting](troubleshooting/)
|
|
97
|
+
|
|
98
|
+
## � **Library Comparison**
|
|
99
|
+
|
|
100
|
+
| Feature | SmartLedger-BSV | bsv@1.5.6 | BitcoinJS-lib |
|
|
101
|
+
|---------|-----------------|-----------|---------------|
|
|
102
|
+
| **Core BSV Support** | ✅ Full | ✅ Full | ❌ Bitcoin only |
|
|
103
|
+
| **Backward Compatibility** | ✅ 100% | - | ❌ Different API |
|
|
104
|
+
| **Security Hardening** | ✅ Yes | ❌ No | ❌ No |
|
|
105
|
+
| **Legal Tokens** | ✅ Built-in | ❌ No | ❌ No |
|
|
106
|
+
| **Digital Identity** | ✅ W3C Standard | ❌ No | ❌ No |
|
|
107
|
+
| **Smart Contracts** | ✅ Complete Framework | ❌ Basic | ❌ No |
|
|
108
|
+
| **Modular Loading** | ✅ 12 Options | ❌ Monolithic | ❌ Monolithic |
|
|
109
|
+
| **Production Ready** | ✅ Yes | ⚠️ Limited | ⚠️ Bitcoin only |
|
|
82
110
|
|
|
83
111
|
### 🔒 Covenant Development
|
|
84
112
|
```javascript
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
# Legal Token Protocol (LTP)
|
|
2
|
+
|
|
3
|
+
## What is LTP?
|
|
4
|
+
|
|
5
|
+
The Legal Token Protocol (LTP) is SmartLedger-BSV's comprehensive framework for creating **legally interpretable digital tokens** that represent real-world rights, obligations, and legal relationships with cryptographic proof and blockchain anchoring.
|
|
6
|
+
|
|
7
|
+
### Core Purpose
|
|
8
|
+
|
|
9
|
+
LTP bridges the gap between **traditional legal concepts** and **blockchain technology** by:
|
|
10
|
+
- **Digitizing Legal Rights**: Converting property titles, licenses, permits into cryptographically signed tokens
|
|
11
|
+
- **Managing Legal Obligations**: Creating enforceable digital obligations with payment schedules and compliance tracking
|
|
12
|
+
- **Ensuring Legal Compliance**: Providing jurisdiction-specific validation and regulatory compliance primitives
|
|
13
|
+
- **Maintaining Audit Trails**: Creating immutable records of legal token lifecycle events
|
|
14
|
+
|
|
15
|
+
### What Makes LTP Different
|
|
16
|
+
|
|
17
|
+
Unlike simple utility tokens or NFTs, LTP tokens are designed to be **legally meaningful**:
|
|
18
|
+
- **W3C Standards Compliant**: Built on Verifiable Credentials standard for interoperability
|
|
19
|
+
- **Jurisdiction-Aware**: Supports different legal frameworks (US, EU, etc.)
|
|
20
|
+
- **Privacy-Preserving**: Selective disclosure allows sharing only necessary information
|
|
21
|
+
- **Legally Binding**: Designed to work within existing legal frameworks and courts
|
|
22
|
+
|
|
23
|
+
## 🚀 Quick Start
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
const bsv = require('@smartledger/bsv');
|
|
27
|
+
|
|
28
|
+
// Create a property right token
|
|
29
|
+
const ownerKey = new bsv.PrivateKey();
|
|
30
|
+
const propertyData = {
|
|
31
|
+
type: 'PropertyTitle',
|
|
32
|
+
owner: 'did:smartledger:' + ownerKey.toPublicKey().toString(),
|
|
33
|
+
jurisdiction: 'US-CA',
|
|
34
|
+
property: {
|
|
35
|
+
address: '123 Main St, San Francisco, CA 94105',
|
|
36
|
+
parcelId: 'APN-12345678',
|
|
37
|
+
area: { value: 1000, unit: 'sqft' }
|
|
38
|
+
},
|
|
39
|
+
value: { amount: 850000, currency: 'USD' }
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const propertyToken = bsv.createRightToken(propertyData, ownerKey, {
|
|
43
|
+
addProof: true,
|
|
44
|
+
anchor: false,
|
|
45
|
+
register: false
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
console.log('Token created:', propertyToken.success);
|
|
49
|
+
console.log('Token ID:', propertyToken.token.id);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 📚 Complete API Reference
|
|
53
|
+
|
|
54
|
+
### Direct Token Functions
|
|
55
|
+
|
|
56
|
+
#### `bsv.createRightToken(data, privateKey, options)`
|
|
57
|
+
Creates a legal right token (property, vehicle, intellectual property, etc.)
|
|
58
|
+
|
|
59
|
+
**Parameters:**
|
|
60
|
+
- `data` - Token data object with type, owner, jurisdiction, and specific claim data
|
|
61
|
+
- `privateKey` - PrivateKey instance for signing
|
|
62
|
+
- `options` - Configuration options (addProof, anchor, register)
|
|
63
|
+
|
|
64
|
+
**Returns:** `{ success: boolean, token: Object, type: string }`
|
|
65
|
+
|
|
66
|
+
#### `bsv.verifyLegalToken(token, publicKey)`
|
|
67
|
+
Verifies a legal token's cryptographic signature and validity
|
|
68
|
+
|
|
69
|
+
**Parameters:**
|
|
70
|
+
- `token` - Token object to verify
|
|
71
|
+
- `publicKey` - Public key string for verification
|
|
72
|
+
|
|
73
|
+
**Returns:** `{ valid: boolean, publicKey: string, tokenHash: string }`
|
|
74
|
+
|
|
75
|
+
#### `bsv.validateLegalClaim(claimData, schemaType)`
|
|
76
|
+
Validates claim data against legal schemas
|
|
77
|
+
|
|
78
|
+
**Parameters:**
|
|
79
|
+
- `claimData` - Claim object to validate
|
|
80
|
+
- `schemaType` - Schema type ('PropertyTitle', 'VehicleTitle', etc.)
|
|
81
|
+
|
|
82
|
+
**Returns:** `{ valid: boolean, schema: string, requiredFields?: Array }`
|
|
83
|
+
|
|
84
|
+
#### `bsv.createSelectiveDisclosure(token, revealedFields, nonce)`
|
|
85
|
+
Creates selective disclosure proof for privacy protection
|
|
86
|
+
|
|
87
|
+
**Parameters:**
|
|
88
|
+
- `token` - Token to create disclosure proof for
|
|
89
|
+
- `revealedFields` - Array of field paths to reveal
|
|
90
|
+
- `nonce` - Unique nonce string
|
|
91
|
+
|
|
92
|
+
**Returns:** `{ success: boolean, proof: Object, disclosures: Array }`
|
|
93
|
+
|
|
94
|
+
#### `bsv.createLegalRegistry(config)`
|
|
95
|
+
Creates legal token registry configuration
|
|
96
|
+
|
|
97
|
+
**Parameters:**
|
|
98
|
+
- `config` - Registry configuration object
|
|
99
|
+
|
|
100
|
+
**Returns:** Registry configuration object
|
|
101
|
+
|
|
102
|
+
#### `bsv.createLegalValidityProof(token, jurisdiction, nonce)`
|
|
103
|
+
Creates legal validity proof for compliance
|
|
104
|
+
|
|
105
|
+
**Parameters:**
|
|
106
|
+
- `token` - Token to validate
|
|
107
|
+
- `jurisdiction` - Jurisdiction rules object
|
|
108
|
+
- `nonce` - Unique nonce string
|
|
109
|
+
|
|
110
|
+
**Returns:** `{ success: boolean, proof: Object, valid: boolean }`
|
|
111
|
+
|
|
112
|
+
### LTP Class Interface
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
const ltp = new bsv.LTP();
|
|
116
|
+
|
|
117
|
+
// Transfer a right token
|
|
118
|
+
const transfer = ltp.transferRight(token, newOwnerDID, ownerKey, {
|
|
119
|
+
reason: 'Sale',
|
|
120
|
+
consideration: { amount: 875000, currency: 'USD' }
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Create obligation from right
|
|
124
|
+
const obligation = ltp.createObligation(rightToken, obligationData, privateKey);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Primitives-Only Architecture
|
|
128
|
+
|
|
129
|
+
For maximum flexibility, use the preparation functions that return data for external systems to handle:
|
|
130
|
+
|
|
131
|
+
```javascript
|
|
132
|
+
// Prepare right token (no blockchain interaction)
|
|
133
|
+
const rightPrep = bsv.prepareRightToken(
|
|
134
|
+
'PropertyTitle',
|
|
135
|
+
issuerDID,
|
|
136
|
+
subjectDID,
|
|
137
|
+
claimData,
|
|
138
|
+
issuerPrivateKey,
|
|
139
|
+
options
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
// Prepare obligation token
|
|
143
|
+
const obligationPrep = bsv.prepareObligationToken(
|
|
144
|
+
'PaymentObligation',
|
|
145
|
+
issuerDID,
|
|
146
|
+
obligorDID,
|
|
147
|
+
obligationData,
|
|
148
|
+
issuerPrivateKey,
|
|
149
|
+
options
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
// Prepare selective disclosure proof
|
|
153
|
+
const disclosurePrep = bsv.prepareSelectiveDisclosure(
|
|
154
|
+
token,
|
|
155
|
+
revealedFields,
|
|
156
|
+
nonce
|
|
157
|
+
);
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## 🏗️ Architecture & Module Integration
|
|
161
|
+
|
|
162
|
+
### How LTP Integrates with SmartLedger-BSV
|
|
163
|
+
|
|
164
|
+
LTP is built on top of SmartLedger-BSV's modular architecture and integrates seamlessly with other modules:
|
|
165
|
+
|
|
166
|
+
#### **Foundation Layer (Required)**
|
|
167
|
+
- **Core BSV (`bsv.min.js`)**: Provides Bitcoin SV primitives (keys, transactions, addresses)
|
|
168
|
+
- **Cryptographic Functions**: Uses hardened elliptic curve implementations for all signatures
|
|
169
|
+
|
|
170
|
+
#### **Identity Layer (Recommended)**
|
|
171
|
+
- **GDAF Module (`bsv-gdaf.min.js`)**: Provides DID creation and Verifiable Credential standards
|
|
172
|
+
- **Integration**: LTP tokens reference DIDs for issuers, subjects, and obligors
|
|
173
|
+
|
|
174
|
+
#### **Smart Contract Layer (Optional)**
|
|
175
|
+
- **Smart Contract Module (`bsv-smartcontract.min.js`)**: Provides covenant enforcement
|
|
176
|
+
- **Integration**: LTP tokens can be protected by smart contract covenants for automatic enforcement
|
|
177
|
+
|
|
178
|
+
#### **Security Layer (Optional)**
|
|
179
|
+
- **Shamir Module (`bsv-shamir.min.js`)**: Provides threshold cryptography
|
|
180
|
+
- **Integration**: Can split LTP token signing keys across multiple parties
|
|
181
|
+
|
|
182
|
+
#### **Privacy Layer (Built-in)**
|
|
183
|
+
- **Selective Disclosure**: Native privacy-preserving proofs within LTP
|
|
184
|
+
- **ECIES Encryption**: Uses core BSV ECIES for encrypted data fields
|
|
185
|
+
|
|
186
|
+
### Primitives-Only Design Philosophy
|
|
187
|
+
|
|
188
|
+
LTP follows SmartLedger-BSV's **primitives-only architecture**:
|
|
189
|
+
|
|
190
|
+
**What LTP Provides (Preparation Functions):**
|
|
191
|
+
- ✅ **Legal Structure Validation**: Ensures tokens follow legal standards
|
|
192
|
+
- ✅ **Cryptographic Proof Generation**: Creates verifiable signatures and proofs
|
|
193
|
+
- ✅ **Compliance Checking**: Validates against jurisdiction-specific rules
|
|
194
|
+
- ✅ **Token Lifecycle Management**: Handles creation, transfer, and revocation
|
|
195
|
+
- ✅ **Registry Data Formatting**: Prepares data for external registry systems
|
|
196
|
+
- ✅ **Blockchain Commitment Preparation**: Creates anchoring data without publishing
|
|
197
|
+
|
|
198
|
+
**What External Systems Handle:**
|
|
199
|
+
- 🔗 **Blockchain Publishing**: Your application publishes to BSV blockchain
|
|
200
|
+
- 🔗 **Registry Storage**: Your database/registry stores token data
|
|
201
|
+
- 🔗 **Network Communication**: Your API handles network requests
|
|
202
|
+
- 🔗 **User Interfaces**: Your frontend displays and manages tokens
|
|
203
|
+
- 🔗 **Business Logic**: Your application handles domain-specific workflows
|
|
204
|
+
|
|
205
|
+
### Benefits of This Architecture
|
|
206
|
+
- **Maximum Flexibility**: Use any blockchain, database, or UI framework
|
|
207
|
+
- **No Vendor Lock-in**: Not tied to specific platforms or services
|
|
208
|
+
- **Enterprise Ready**: Clean separation allows enterprise integration
|
|
209
|
+
- **Legal Compliance**: Focus on legal correctness without implementation constraints
|
|
210
|
+
|
|
211
|
+
## 📋 What LTP Can Tokenize
|
|
212
|
+
|
|
213
|
+
### Real-World Legal Rights (Right Tokens)
|
|
214
|
+
- **🏠 PropertyTitle** - Real estate ownership, deeds, titles
|
|
215
|
+
- **🚗 VehicleTitle** - Car, boat, aircraft ownership documents
|
|
216
|
+
- **💡 IntellectualProperty** - Patents, trademarks, copyrights
|
|
217
|
+
- **🎵 MusicLicense** - Music publishing, performance rights
|
|
218
|
+
- **💻 SoftwareLicense** - Software usage, distribution rights
|
|
219
|
+
- **💰 FinancialInstrument** - Bonds, stocks, derivatives
|
|
220
|
+
- **📄 PromissoryNote** - IOUs, payment promises
|
|
221
|
+
- **🏅 ProfessionalLicense** - Professional certifications, permits
|
|
222
|
+
- **🎫 AccessRight** - Membership rights, access permissions
|
|
223
|
+
- **🗳️ VotingRight** - Shareholder voting, governance rights
|
|
224
|
+
|
|
225
|
+
### Real-World Legal Obligations (Obligation Tokens)
|
|
226
|
+
- **💵 PaymentObligation** - Loan payments, rent, mortgages
|
|
227
|
+
- **📦 DeliveryObligation** - Shipping, delivery requirements
|
|
228
|
+
- **🔧 MaintenanceObligation** - Maintenance contracts, warranties
|
|
229
|
+
- **📊 ComplianceObligation** - Regulatory reporting, compliance
|
|
230
|
+
- **📋 ReportingObligation** - Financial reporting, disclosures
|
|
231
|
+
- **🤐 ConfidentialityObligation** - NDAs, confidentiality agreements
|
|
232
|
+
- **🚫 NonCompeteObligation** - Non-compete agreements
|
|
233
|
+
- **🛡️ WarrantyObligation** - Product warranties, guarantees
|
|
234
|
+
|
|
235
|
+
### Module Relationships
|
|
236
|
+
|
|
237
|
+
Each token type leverages different SmartLedger-BSV capabilities:
|
|
238
|
+
|
|
239
|
+
```javascript
|
|
240
|
+
// Property title using multiple modules
|
|
241
|
+
const propertyToken = bsv.createRightToken({
|
|
242
|
+
type: 'PropertyTitle', // LTP: Legal structure
|
|
243
|
+
owner: ownerDID, // GDAF: Digital identity
|
|
244
|
+
jurisdiction: 'US-CA', // LTP: Legal compliance
|
|
245
|
+
// Signed with hardened crypto // Core: Enhanced security
|
|
246
|
+
// Can be covenant-protected // SmartContract: Enforcement
|
|
247
|
+
// Keys can use Shamir sharing // Shamir: Distributed control
|
|
248
|
+
});
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## � LTP Internal Architecture
|
|
252
|
+
|
|
253
|
+
LTP is composed of 6 specialized modules working together:
|
|
254
|
+
|
|
255
|
+
### Core Modules (`lib/ltp/`)
|
|
256
|
+
|
|
257
|
+
1. **`right.js`** - Legal rights token creation and validation
|
|
258
|
+
- Creates property titles, licenses, permits
|
|
259
|
+
- Handles token transfers and ownership changes
|
|
260
|
+
- Validates right types and legal structures
|
|
261
|
+
|
|
262
|
+
2. **`obligation.js`** - Legal obligation token management
|
|
263
|
+
- Creates payment, delivery, compliance obligations
|
|
264
|
+
- Tracks obligation lifecycle and fulfillment
|
|
265
|
+
- Manages breach detection and remediation
|
|
266
|
+
|
|
267
|
+
3. **`claim.js`** - Legal claim validation and attestation
|
|
268
|
+
- Validates claims against legal schemas
|
|
269
|
+
- Provides attestation and notarization primitives
|
|
270
|
+
- Handles bulk claim processing
|
|
271
|
+
|
|
272
|
+
4. **`proof.js`** - Cryptographic proof generation
|
|
273
|
+
- Creates signature proofs for authenticity
|
|
274
|
+
- Generates selective disclosure proofs for privacy
|
|
275
|
+
- Produces legal validity proofs for compliance
|
|
276
|
+
- Handles zero-knowledge proofs for sensitive data
|
|
277
|
+
|
|
278
|
+
5. **`registry.js`** - Token registry management
|
|
279
|
+
- Prepares registry configurations and policies
|
|
280
|
+
- Handles token registration and approval workflows
|
|
281
|
+
- Manages revocation and status tracking
|
|
282
|
+
- Provides search and audit capabilities
|
|
283
|
+
|
|
284
|
+
6. **`anchor.js`** - Blockchain anchoring preparation
|
|
285
|
+
- Prepares commitment hashes for blockchain storage
|
|
286
|
+
- Handles batch anchoring for efficiency
|
|
287
|
+
- Creates merkle proofs for token verification
|
|
288
|
+
- Formats revocation data for on-chain publishing
|
|
289
|
+
|
|
290
|
+
### How These Work Together
|
|
291
|
+
|
|
292
|
+
```javascript
|
|
293
|
+
// Complete workflow using all 6 modules
|
|
294
|
+
const claim = bsv.LTP.Claim.validate(propertyData, 'PropertyTitle'); // 1. Validate
|
|
295
|
+
const rightToken = bsv.LTP.Right.create(claim, ownerKey); // 2. Create right
|
|
296
|
+
const obligation = bsv.LTP.Obligation.create(rightToken, taxData); // 3. Create obligation
|
|
297
|
+
const proof = bsv.LTP.Proof.createSignature(rightToken, issuerKey); // 4. Generate proof
|
|
298
|
+
const registry = bsv.LTP.Registry.register(rightToken); // 5. Prepare registry
|
|
299
|
+
const anchor = bsv.LTP.Anchor.prepareCommitment(rightToken); // 6. Prepare anchoring
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## 🔐 Security & Trust Features
|
|
303
|
+
|
|
304
|
+
- **🔒 Cryptographic Signatures** - All tokens signed with enhanced elliptic curves
|
|
305
|
+
- **🎭 Selective Disclosure** - Privacy-preserving proof generation with zero-knowledge
|
|
306
|
+
- **⚖️ Legal Validity Proofs** - Jurisdiction-specific compliance verification
|
|
307
|
+
- **⛓️ Blockchain Anchoring** - Immutable commitment proofs on BSV blockchain
|
|
308
|
+
- **📚 Registry Management** - Complete token lifecycle tracking and audit trails
|
|
309
|
+
- **🛡️ Smart Contract Protection** - Optional covenant enforcement for automatic compliance
|
|
310
|
+
- **🔑 Multi-Signature Support** - Shamir secret sharing for distributed key management
|
|
311
|
+
|
|
312
|
+
## 🎯 Real-World Applications
|
|
313
|
+
|
|
314
|
+
LTP integrates with other SmartLedger-BSV modules for complete enterprise solutions:
|
|
315
|
+
|
|
316
|
+
### 🏡 Real Estate & Property Management
|
|
317
|
+
```javascript
|
|
318
|
+
// Complete property title system with GDAF identity verification
|
|
319
|
+
const identity = bsv.GDAF.createIdentity(ownerData); // Identity layer
|
|
320
|
+
const titleClaim = bsv.LTP.Claim.validate(propertyData, 'RealEstate'); // Legal validation
|
|
321
|
+
const propertyTitle = bsv.LTP.Right.create(titleClaim, ownerKey); // Create title token
|
|
322
|
+
const transferCovenant = bsv.SmartContract.createCovenant(titleRules); // Smart enforcement
|
|
323
|
+
const sharedKey = bsv.Shamir.split(ownerKey, 3, 5); // Distributed security
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### 💼 Corporate Governance & Compliance
|
|
327
|
+
```javascript
|
|
328
|
+
// Business license with automatic compliance monitoring
|
|
329
|
+
const businessLicense = bsv.LTP.Right.create(licenseData, corporateKey);
|
|
330
|
+
const complianceObligation = bsv.LTP.Obligation.create(license, regulations);
|
|
331
|
+
const auditCovenant = bsv.SmartContract.createAuditContract(complianceRules);
|
|
332
|
+
const executiveKeys = bsv.Shamir.split(corporateKey, 3, 7);
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### 🏦 Financial Services & Banking
|
|
336
|
+
```javascript
|
|
337
|
+
// Loan agreement with payment automation
|
|
338
|
+
const loanObligation = bsv.LTP.Obligation.create(loanTerms, borrowerKey);
|
|
339
|
+
const paymentCovenant = bsv.SmartContract.createPaymentSchedule(terms);
|
|
340
|
+
const creditProof = bsv.LTP.Proof.createSignature(creditData, bankKey);
|
|
341
|
+
const escrowKeys = bsv.Shamir.split(escrowKey, 2, 3);
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### 🎓 Education & Professional Certification
|
|
345
|
+
```javascript
|
|
346
|
+
// Academic credential with verification
|
|
347
|
+
const degreeData = bsv.GDAF.createCredential(graduateData);
|
|
348
|
+
const degreeClaim = bsv.LTP.Claim.validate(degreeData, 'AcademicDegree');
|
|
349
|
+
const diploma = bsv.LTP.Right.create(degreeClaim, universityKey);
|
|
350
|
+
const verificationProof = bsv.LTP.Proof.createValidity(diploma, accreditorKey);
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### 🚛 Supply Chain & Logistics
|
|
354
|
+
```javascript
|
|
355
|
+
// Delivery tracking with quality assurance
|
|
356
|
+
const deliveryObligation = bsv.LTP.Obligation.create(shipmentData, supplierKey);
|
|
357
|
+
const qualityContract = bsv.SmartContract.createQualityGates(standards);
|
|
358
|
+
const trackingProof = bsv.LTP.Proof.createSignature(locationData, carrierKey);
|
|
359
|
+
const insuranceKeys = bsv.Shamir.split(insuranceKey, 2, 4);
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### 🏛️ Government & Public Services
|
|
363
|
+
```javascript
|
|
364
|
+
// Government permit with regulatory compliance
|
|
365
|
+
const permitData = bsv.GDAF.createGovernmentID(citizenData);
|
|
366
|
+
const permitClaim = bsv.LTP.Claim.validate(permitData, 'BuildingPermit');
|
|
367
|
+
const buildingPermit = bsv.LTP.Right.create(permitClaim, governmentKey);
|
|
368
|
+
const complianceContract = bsv.SmartContract.createRegulatoryContract(codes);
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
## 📋 Token Type Categories
|
|
372
|
+
|
|
373
|
+
### Right Tokens 🏆
|
|
374
|
+
- **Property Titles** - Real estate, vehicles, patents, trademarks
|
|
375
|
+
- **Business Licenses** - Professional, operational, regulatory permits
|
|
376
|
+
- **Access Rights** - Security, membership, usage privileges
|
|
377
|
+
- **Intellectual Property** - Copyrights, licensing agreements, royalties
|
|
378
|
+
|
|
379
|
+
### Obligation Tokens 📝
|
|
380
|
+
- **Payment Obligations** - Invoices, loans, payment schedules, bonds
|
|
381
|
+
- **Delivery Obligations** - Supply contracts, service agreements, milestones
|
|
382
|
+
- **Compliance Obligations** - Regulatory, audit, reporting requirements
|
|
383
|
+
- **Performance Obligations** - SLAs, quality standards, warranty terms
|
|
384
|
+
|
|
385
|
+
### Legal Claims 🎖️
|
|
386
|
+
- **Identity Claims** - Certifications, credentials, qualifications, clearances
|
|
387
|
+
- **Property Claims** - Ownership, liens, encumbrances, easements
|
|
388
|
+
- **Performance Claims** - Warranties, guarantees, quality assurance
|
|
389
|
+
- **Compliance Claims** - Regulatory adherence, audit results, certifications
|
|
390
|
+
|
|
391
|
+
## 📖 Examples
|
|
392
|
+
|
|
393
|
+
See the working demonstration files:
|
|
394
|
+
- `demos/ltp_demo.js` - Complete LTP workflow
|
|
395
|
+
- `demos/ltp_primitives_demo.js` - Primitives-only architecture
|
|
396
|
+
- `demos/complete_ltp_demo.js` - End-to-end with real BSV keys
|
|
397
|
+
|
|
398
|
+
## 🌐 W3C Compliance
|
|
399
|
+
|
|
400
|
+
All LTP tokens follow W3C Verifiable Credential standards with SmartLedger extensions for legal compliance and Bitcoin SV blockchain integration.
|
|
401
|
+
|
|
402
|
+
## ⚖️ Legal Framework
|
|
403
|
+
|
|
404
|
+
The Legal Token Protocol is designed to work within existing legal frameworks and provides primitives for:
|
|
405
|
+
- Legal claim attestation and validation
|
|
406
|
+
- Jurisdictional compliance checking
|
|
407
|
+
- Regulatory proof generation
|
|
408
|
+
- Audit trail preparation
|
|
409
|
+
- Right and obligation lifecycle management
|
|
410
|
+
|
|
411
|
+
For trust law integration, see [Trust Protocol Mapping](../technical/trust_law.md).
|