smartledger-bsv 3.3.2 → 3.3.4
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 +220 -79
- package/README.md +283 -71
- package/bsv-covenant.min.js +26 -3
- package/bsv-gdaf.min.js +11 -9
- package/bsv-ltp.min.js +10 -8
- package/bsv-mnemonic.min.js +4 -4
- 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/demos/README.md +188 -0
- package/{architecture_demo.js → demos/architecture_demo.js} +2 -2
- package/demos/bsv_wallet_demo.js +242 -0
- package/{complete_ltp_demo.js → demos/complete_ltp_demo.js} +1 -1
- package/demos/debug_tools_demo.js +87 -0
- package/demos/demo_features.js +123 -0
- package/demos/easy_interface_demo.js +109 -0
- package/demos/ecies_demo.js +182 -0
- package/demos/gdaf_core_test.js +131 -0
- package/demos/gdaf_demo.js +237 -0
- package/demos/ltp_demo.js +361 -0
- package/demos/ltp_primitives_demo.js +403 -0
- package/demos/message_demo.js +209 -0
- package/demos/preimage_separation_demo.js +383 -0
- package/demos/script_helper_demo.js +289 -0
- package/demos/security_demo.js +287 -0
- package/{shamir_demo.js → demos/shamir_demo.js} +1 -1
- package/{simple_demo.js → demos/simple_demo.js} +1 -1
- package/demos/simple_p2pkh_demo.js +169 -0
- package/demos/simple_utxo_preimage_demo.js +196 -0
- package/demos/smart_contract_demo.html +1347 -0
- package/demos/smart_contract_demo.js +910 -0
- package/demos/utxo_generator_demo.js +244 -0
- package/demos/validation_pipeline_demo.js +155 -0
- package/demos/web3keys.html +740 -0
- package/docs/BUNDLE_UPDATE_SUMMARY.md +40 -0
- package/docs/DOCUMENTATION_REVIEW_REPORT.md +295 -0
- package/docs/FIX_CREATEHMAC_ISSUE.md +91 -0
- package/docs/MODULE_REFERENCE_COMPLETE.md +330 -0
- package/docs/README.md +107 -79
- package/docs/SMARTLEDGER_BSV_USAGE_ANSWERS.md +477 -0
- package/docs/SMARTLEDGER_BSV_USAGE_EXAMPLES.js +372 -0
- package/docs/SMARTLEDGER_BSV_USAGE_GUIDE.md +555 -0
- package/docs/SMART_CONTRACT_DEVELOPMENT_GUIDE.md +1459 -0
- 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/examples/complete_workflow_demo.js +783 -0
- package/examples/definitive_working_demo.js +261 -0
- package/examples/final_working_contracts.js +338 -0
- package/examples/smart_contract_templates.js +718 -0
- package/examples/working_smart_contracts.js +348 -0
- package/gdaf-entry.js +2 -54
- package/index.js +32 -0
- package/lib/mnemonic/pbkdf2.browser.js +69 -0
- package/lib/mnemonic/pbkdf2.js +2 -68
- package/lib/mnemonic/pbkdf2.node.js +68 -0
- package/ltp-entry.js +2 -92
- package/package.json +21 -8
- 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/browser-compatibility/README.md +35 -0
- package/tests/browser-compatibility/test-cdn-vs-local.html +186 -0
- package/tests/browser-compatibility/test-pbkdf2.html +51 -0
- 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/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/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/api/LTP.md
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
# Legal Token Protocol (LTP) API Reference
|
|
2
|
+
|
|
3
|
+
Complete API documentation for SmartLedger-BSV Legal Token Protocol.
|
|
4
|
+
|
|
5
|
+
## Core Functions
|
|
6
|
+
|
|
7
|
+
### Direct Token Operations
|
|
8
|
+
|
|
9
|
+
#### `bsv.createRightToken(data, privateKey, options)`
|
|
10
|
+
|
|
11
|
+
Creates a legal right token with cryptographic signature.
|
|
12
|
+
|
|
13
|
+
**Parameters:**
|
|
14
|
+
- `data` (Object) - Token data structure
|
|
15
|
+
- `type` (String) - Token type from supported types
|
|
16
|
+
- `owner` (String) - Owner DID
|
|
17
|
+
- `jurisdiction` (String) - Legal jurisdiction
|
|
18
|
+
- Additional type-specific fields
|
|
19
|
+
- `privateKey` (PrivateKey) - Signing key
|
|
20
|
+
- `options` (Object) - Configuration options
|
|
21
|
+
- `addProof` (Boolean) - Add cryptographic proof (default: true)
|
|
22
|
+
- `anchor` (Boolean) - Blockchain anchoring (default: false)
|
|
23
|
+
- `register` (Boolean) - Registry registration (default: false)
|
|
24
|
+
|
|
25
|
+
**Returns:**
|
|
26
|
+
```javascript
|
|
27
|
+
{
|
|
28
|
+
success: Boolean,
|
|
29
|
+
token: {
|
|
30
|
+
id: String, // Unique token ID
|
|
31
|
+
type: Array, // W3C VC types
|
|
32
|
+
issuer: String, // Issuer DID
|
|
33
|
+
issuanceDate: String, // ISO timestamp
|
|
34
|
+
credentialSubject: Object, // Token claims
|
|
35
|
+
proof: Object, // Cryptographic proof
|
|
36
|
+
tokenHash: String // Token hash
|
|
37
|
+
},
|
|
38
|
+
type: String // Token type
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### `bsv.verifyLegalToken(token, publicKey)`
|
|
43
|
+
|
|
44
|
+
Verifies token cryptographic signature and structure.
|
|
45
|
+
|
|
46
|
+
**Parameters:**
|
|
47
|
+
- `token` (Object) - Token to verify
|
|
48
|
+
- `publicKey` (String) - Verification public key
|
|
49
|
+
|
|
50
|
+
**Returns:**
|
|
51
|
+
```javascript
|
|
52
|
+
{
|
|
53
|
+
valid: Boolean,
|
|
54
|
+
publicKey: String,
|
|
55
|
+
tokenHash: String,
|
|
56
|
+
error?: String
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### `bsv.validateLegalClaim(claimData, schemaType)`
|
|
61
|
+
|
|
62
|
+
Validates claim data against legal schemas.
|
|
63
|
+
|
|
64
|
+
**Parameters:**
|
|
65
|
+
- `claimData` (Object) - Claim to validate
|
|
66
|
+
- `schemaType` (String) - Schema type
|
|
67
|
+
|
|
68
|
+
**Returns:**
|
|
69
|
+
```javascript
|
|
70
|
+
{
|
|
71
|
+
valid: Boolean,
|
|
72
|
+
schema: String,
|
|
73
|
+
requiredFields?: Array,
|
|
74
|
+
errors?: Array
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Privacy Functions
|
|
79
|
+
|
|
80
|
+
#### `bsv.createSelectiveDisclosure(token, revealedFields, nonce)`
|
|
81
|
+
|
|
82
|
+
Creates selective disclosure proof for privacy.
|
|
83
|
+
|
|
84
|
+
**Parameters:**
|
|
85
|
+
- `token` (Object) - Token for disclosure
|
|
86
|
+
- `revealedFields` (Array) - Field paths to reveal
|
|
87
|
+
- `nonce` (String) - Unique nonce
|
|
88
|
+
|
|
89
|
+
**Returns:**
|
|
90
|
+
```javascript
|
|
91
|
+
{
|
|
92
|
+
success: Boolean,
|
|
93
|
+
proof: {
|
|
94
|
+
type: String,
|
|
95
|
+
disclosures: Array,
|
|
96
|
+
totalFields: Number,
|
|
97
|
+
merkleRoot: String
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Registry Functions
|
|
103
|
+
|
|
104
|
+
#### `bsv.createLegalRegistry(config)`
|
|
105
|
+
|
|
106
|
+
Creates registry configuration.
|
|
107
|
+
|
|
108
|
+
**Parameters:**
|
|
109
|
+
- `config` (Object) - Registry configuration
|
|
110
|
+
|
|
111
|
+
**Returns:**
|
|
112
|
+
```javascript
|
|
113
|
+
{
|
|
114
|
+
success: Boolean,
|
|
115
|
+
registry: {
|
|
116
|
+
id: String,
|
|
117
|
+
name: String,
|
|
118
|
+
jurisdiction: String,
|
|
119
|
+
authority: String,
|
|
120
|
+
created: String
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
#### `bsv.createLegalValidityProof(token, jurisdiction, nonce)`
|
|
126
|
+
|
|
127
|
+
Creates legal validity proof.
|
|
128
|
+
|
|
129
|
+
**Parameters:**
|
|
130
|
+
- `token` (Object) - Token to validate
|
|
131
|
+
- `jurisdiction` (Object) - Jurisdiction rules
|
|
132
|
+
- `nonce` (String) - Proof nonce
|
|
133
|
+
|
|
134
|
+
**Returns:**
|
|
135
|
+
```javascript
|
|
136
|
+
{
|
|
137
|
+
success: Boolean,
|
|
138
|
+
proof: {
|
|
139
|
+
type: String,
|
|
140
|
+
jurisdiction: String,
|
|
141
|
+
valid: Boolean,
|
|
142
|
+
checks: Array,
|
|
143
|
+
complianceHash: String
|
|
144
|
+
},
|
|
145
|
+
valid: Boolean
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## LTP Class
|
|
150
|
+
|
|
151
|
+
### Constructor
|
|
152
|
+
|
|
153
|
+
```javascript
|
|
154
|
+
const ltp = new bsv.LTP(config);
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Parameters:**
|
|
158
|
+
- `config` (Object) - Optional configuration
|
|
159
|
+
|
|
160
|
+
### Instance Methods
|
|
161
|
+
|
|
162
|
+
#### `ltp.createRightToken(rightData, privateKey, options)`
|
|
163
|
+
|
|
164
|
+
Creates right token via class instance.
|
|
165
|
+
|
|
166
|
+
#### `ltp.transferRight(token, newOwner, ownerKey, options)`
|
|
167
|
+
|
|
168
|
+
Transfers right token to new owner.
|
|
169
|
+
|
|
170
|
+
**Parameters:**
|
|
171
|
+
- `token` (Object) - Token to transfer
|
|
172
|
+
- `newOwner` (String) - New owner DID
|
|
173
|
+
- `ownerKey` (PrivateKey) - Current owner key
|
|
174
|
+
- `options` (Object) - Transfer options
|
|
175
|
+
|
|
176
|
+
**Returns:**
|
|
177
|
+
```javascript
|
|
178
|
+
{
|
|
179
|
+
success: Boolean,
|
|
180
|
+
token: Object, // Updated token
|
|
181
|
+
transferId: String, // Transfer ID
|
|
182
|
+
transferredAt: String, // Timestamp
|
|
183
|
+
transferProof: Object // Transfer proof
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### `ltp.createObligation(rightToken, obligationData, privateKey)`
|
|
188
|
+
|
|
189
|
+
Creates obligation from right token.
|
|
190
|
+
|
|
191
|
+
**Parameters:**
|
|
192
|
+
- `rightToken` (Object) - Source right token
|
|
193
|
+
- `obligationData` (Object) - Obligation details
|
|
194
|
+
- `privateKey` (PrivateKey) - Signing key
|
|
195
|
+
|
|
196
|
+
## Primitives API
|
|
197
|
+
|
|
198
|
+
### Preparation Functions
|
|
199
|
+
|
|
200
|
+
#### `bsv.prepareRightToken(type, issuerDID, subjectDID, claim, issuerPrivateKey, options)`
|
|
201
|
+
|
|
202
|
+
Prepares right token data (no external operations).
|
|
203
|
+
|
|
204
|
+
**Parameters:**
|
|
205
|
+
- `type` (String) - Right type
|
|
206
|
+
- `issuerDID` (String) - Issuer DID
|
|
207
|
+
- `subjectDID` (String) - Subject DID
|
|
208
|
+
- `claim` (Object) - Claim data
|
|
209
|
+
- `issuerPrivateKey` (PrivateKey) - Signing key
|
|
210
|
+
- `options` (Object) - Options
|
|
211
|
+
|
|
212
|
+
**Returns:**
|
|
213
|
+
```javascript
|
|
214
|
+
{
|
|
215
|
+
success: Boolean,
|
|
216
|
+
rightToken: Object, // Prepared token
|
|
217
|
+
tokenHash: String, // Token hash
|
|
218
|
+
metadata: {
|
|
219
|
+
type: String,
|
|
220
|
+
issuer: String,
|
|
221
|
+
subject: String,
|
|
222
|
+
transferable: Boolean,
|
|
223
|
+
jurisdiction: String
|
|
224
|
+
},
|
|
225
|
+
externalOperations: Object // Operations for external systems
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
#### `bsv.prepareObligationToken(type, issuerDID, obligorDID, obligation, issuerPrivateKey, options)`
|
|
230
|
+
|
|
231
|
+
Prepares obligation token data.
|
|
232
|
+
|
|
233
|
+
#### `bsv.prepareSelectiveDisclosure(token, revealedFields, nonce)`
|
|
234
|
+
|
|
235
|
+
Prepares selective disclosure proof data.
|
|
236
|
+
|
|
237
|
+
#### `bsv.prepareLegalValidityProof(token, jurisdiction, nonce)`
|
|
238
|
+
|
|
239
|
+
Prepares legal validity proof data.
|
|
240
|
+
|
|
241
|
+
#### `bsv.prepareTokenCommitment(token, options)`
|
|
242
|
+
|
|
243
|
+
Prepares blockchain commitment data.
|
|
244
|
+
|
|
245
|
+
#### `bsv.prepareBatchCommitment(tokens, options)`
|
|
246
|
+
|
|
247
|
+
Prepares batch commitment for multiple tokens.
|
|
248
|
+
|
|
249
|
+
## Supported Types
|
|
250
|
+
|
|
251
|
+
### Right Types
|
|
252
|
+
|
|
253
|
+
- `PropertyTitle` - Real estate ownership
|
|
254
|
+
- `VehicleTitle` - Vehicle ownership
|
|
255
|
+
- `IntellectualProperty` - IP rights
|
|
256
|
+
- `MusicLicense` - Music licensing
|
|
257
|
+
- `SoftwareLicense` - Software licensing
|
|
258
|
+
- `FinancialInstrument` - Financial instruments
|
|
259
|
+
- `PromissoryNote` - Promissory notes
|
|
260
|
+
- `Bond` - Bond instruments
|
|
261
|
+
- `EquityShare` - Equity shares
|
|
262
|
+
- `ProfessionalLicense` - Professional licenses
|
|
263
|
+
- `RegulatoryPermit` - Regulatory permits
|
|
264
|
+
- `AccessRight` - Access rights
|
|
265
|
+
- `VotingRight` - Voting rights
|
|
266
|
+
- `RoyaltyRight` - Royalty rights
|
|
267
|
+
- `UsageRight` - Usage rights
|
|
268
|
+
|
|
269
|
+
### Obligation Types
|
|
270
|
+
|
|
271
|
+
- `PaymentObligation` - Payment duties
|
|
272
|
+
- `DeliveryObligation` - Delivery requirements
|
|
273
|
+
- `PerformanceObligation` - Performance duties
|
|
274
|
+
- `MaintenanceObligation` - Maintenance requirements
|
|
275
|
+
- `ComplianceObligation` - Regulatory compliance
|
|
276
|
+
- `ReportingObligation` - Reporting duties
|
|
277
|
+
- `ConfidentialityObligation` - Confidentiality requirements
|
|
278
|
+
- `NonCompeteObligation` - Non-compete agreements
|
|
279
|
+
- `WarrantyObligation` - Warranty obligations
|
|
280
|
+
- `SupportObligation` - Support requirements
|
|
281
|
+
|
|
282
|
+
### Status Values
|
|
283
|
+
|
|
284
|
+
- `PENDING` - Awaiting action
|
|
285
|
+
- `ACTIVE` - Currently active
|
|
286
|
+
- `IN_PROGRESS` - In progress
|
|
287
|
+
- `COMPLETED` - Completed successfully
|
|
288
|
+
- `OVERDUE` - Past due date
|
|
289
|
+
- `BREACHED` - Obligation breached
|
|
290
|
+
- `WAIVED` - Waived by authority
|
|
291
|
+
- `TERMINATED` - Terminated
|
|
292
|
+
|
|
293
|
+
## Utility Functions
|
|
294
|
+
|
|
295
|
+
### `bsv.getRightTypes()`
|
|
296
|
+
|
|
297
|
+
Returns available right types.
|
|
298
|
+
|
|
299
|
+
### `bsv.getObligationTypes()`
|
|
300
|
+
|
|
301
|
+
Returns available obligation types.
|
|
302
|
+
|
|
303
|
+
### `bsv.getClaimSchemas()`
|
|
304
|
+
|
|
305
|
+
Returns available claim schemas.
|
|
306
|
+
|
|
307
|
+
### `bsv.canonicalizeClaim(claim)`
|
|
308
|
+
|
|
309
|
+
Canonicalizes claim for consistent hashing.
|
|
310
|
+
|
|
311
|
+
### `bsv.hashClaim(claim)`
|
|
312
|
+
|
|
313
|
+
Creates hash of claim data.
|
|
314
|
+
|
|
315
|
+
## Error Handling
|
|
316
|
+
|
|
317
|
+
All LTP functions return result objects with success indicators:
|
|
318
|
+
|
|
319
|
+
```javascript
|
|
320
|
+
{
|
|
321
|
+
success: Boolean,
|
|
322
|
+
// ... result data if successful
|
|
323
|
+
error?: String // Error message if failed
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
Always check the `success` field before using result data.
|
|
328
|
+
|
|
329
|
+
## Examples
|
|
330
|
+
|
|
331
|
+
See working examples in:
|
|
332
|
+
- `demos/ltp_demo.js`
|
|
333
|
+
- `demos/ltp_primitives_demo.js`
|
|
334
|
+
- `demos/complete_ltp_demo.js`
|