smartledger-bsv 3.4.0 → 3.4.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 +400 -0
- package/README.md +112 -84
- package/SECURITY.md +88 -0
- package/bin/cli.js +13 -8
- package/bsv-anchor.min.js +12 -0
- package/bsv-covenant.min.js +8 -8
- package/bsv-didweb.min.js +12 -0
- package/bsv-gdaf.min.js +9 -9
- package/bsv-ltp.min.js +9 -9
- package/bsv-mnemonic.min.js +2 -2
- package/bsv-shamir.min.js +3 -3
- package/bsv-smartcontract.min.js +5 -5
- package/bsv-statuslist.min.js +18 -0
- package/bsv-vcjwt.min.js +12 -0
- package/bsv.bundle.js +9 -9
- package/bsv.d.ts +486 -9
- package/bsv.min.js +5 -5
- package/build/webpack.anchor.config.js +9 -13
- package/build/webpack.didweb.config.js +10 -14
- package/build/webpack.statuslist.config.js +9 -14
- package/build/webpack.vcjwt.config.js +9 -13
- package/docs/COVENANT_DEVELOPMENT_RESOLVED.md +2 -2
- package/docs/MODULE_REFERENCE_COMPLETE.md +61 -58
- package/docs/advanced/LEGAL_TOKEN_PROTOCOL.md +3 -3
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/getting-started/INSTALLATION.md +30 -30
- package/docs/getting-started/QUICK_START.md +18 -18
- package/docs/migration/FROM_BSV_1_5_6.md +16 -10
- package/gdaf-entry.js +1 -2
- package/index.js +44 -13
- package/lib/browser-utxo-manager-es5.js +11 -4
- package/lib/browser-utxo-manager.js +15 -8
- package/lib/ltp/claim.js +1 -0
- package/lib/ltp/obligation.js +1 -0
- package/lib/ltp/registry.js +2 -0
- package/lib/ltp/right.js +1 -0
- package/lib/smart_contract/covenant.js +10 -1
- package/lib/smartutxo.js +20 -12
- package/lib/transaction/transaction.js +8 -1
- package/lib/util/_.js +7 -1
- package/ltp-entry.js +1 -2
- package/package.json +11 -13
- package/utilities/blockchain-state.js +32 -23
- package/demos/README.md +0 -188
- package/demos/architecture_demo.js +0 -247
- package/demos/browser-test.html +0 -1208
- package/demos/bsv_wallet_demo.js +0 -242
- package/demos/complete_ltp_demo.js +0 -511
- package/demos/debug_tools_demo.js +0 -87
- package/demos/demo_features.js +0 -123
- package/demos/easy_interface_demo.js +0 -109
- package/demos/ecies_demo.js +0 -182
- package/demos/gdaf_core_test.js +0 -131
- package/demos/gdaf_demo.js +0 -237
- package/demos/ltp_demo.js +0 -361
- package/demos/ltp_primitives_demo.js +0 -403
- package/demos/message_demo.js +0 -209
- package/demos/preimage_separation_demo.js +0 -383
- package/demos/script_helper_demo.js +0 -289
- package/demos/security_demo.js +0 -287
- package/demos/shamir_demo.js +0 -121
- package/demos/simple_demo.js +0 -204
- package/demos/simple_p2pkh_demo.js +0 -169
- package/demos/simple_utxo_preimage_demo.js +0 -196
- package/demos/smart_contract_demo.html +0 -1347
- package/demos/smart_contract_demo.js +0 -910
- package/demos/utxo_generator_demo.js +0 -244
- package/demos/validation_pipeline_demo.js +0 -155
- package/demos/web3keys.html +0 -740
- package/examples/README.md +0 -200
- package/examples/basic/transaction-creation.js +0 -534
- package/examples/basic/transaction_signature_api_gap.js +0 -178
- package/examples/complete_workflow_demo.js +0 -783
- package/examples/covenants/advanced_covenant_demo.js +0 -219
- package/examples/covenants/covenant_interface_demo.js +0 -270
- package/examples/covenants/covenant_manual_signature_resolved.js +0 -212
- package/examples/covenants/covenant_signature_template.js +0 -117
- package/examples/covenants2/covenant_bidirectional_example.js +0 -262
- package/examples/covenants2/covenant_utils_demo.js +0 -120
- package/examples/covenants2/preimage_covenant_utils.js +0 -287
- package/examples/covenants2/production_integration.js +0 -256
- package/examples/data/covenant_utxos.json +0 -28
- package/examples/data/utxos.json +0 -26
- package/examples/definitive_working_demo.js +0 -261
- package/examples/final_working_contracts.js +0 -338
- package/examples/preimage/README.md +0 -178
- package/examples/preimage/extract_preimage_bidirectional.js +0 -421
- package/examples/preimage/generate_sample_preimage.js +0 -208
- package/examples/preimage/generate_sighash_examples.js +0 -152
- package/examples/preimage/parse_preimage.js +0 -117
- package/examples/preimage/test_preimage_extractor.js +0 -53
- package/examples/preimage/test_varint_extraction.js +0 -95
- package/examples/scripts/custom_script_helper_example.js +0 -273
- package/examples/scripts/custom_script_signature_test.js +0 -344
- package/examples/scripts/script_interpreter.js +0 -193
- package/examples/smart_contract/complete_workflow_demo.js +0 -343
- package/examples/smart_contract/covenant_builder_demo.js +0 -176
- package/examples/smart_contract/script_testing_integration.js +0 -198
- package/examples/smart_contract_templates.js +0 -718
- package/examples/working_smart_contracts.js +0 -348
- package/lib/smart_contract/test_integration.js +0 -269
- package/tests/browser-compatibility/README.md +0 -35
- package/tests/browser-compatibility/test-cdn-vs-local.html +0 -186
- package/tests/browser-compatibility/test-pbkdf2.html +0 -51
- package/tests/bundle-completeness-test.html +0 -131
- package/tests/bundle-demo.html +0 -476
- package/tests/smartcontract-test.html +0 -239
- package/tests/standalone-modules-test.html +0 -260
- package/tests/test.html +0 -612
- package/tests/test_builtin_verify.js +0 -117
- package/tests/test_debug_integration.js +0 -71
- package/tests/test_ecdsa_little.js +0 -70
- package/tests/test_shamir.js +0 -221
- package/tests/test_smartverify_der.js +0 -110
- package/tests/test_standalone_shamir.html +0 -83
- package/tests/unpkg-demo.html +0 -194
- package/utilities/blockchain-state.json +0 -118565
package/demos/gdaf_demo.js
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GDAF (Global Digital Attestation Framework) Demo
|
|
3
|
-
*
|
|
4
|
-
* Demonstrates the complete GDAF workflow including:
|
|
5
|
-
* - DID creation and resolution
|
|
6
|
-
* - Credential creation and signing
|
|
7
|
-
* - Zero-knowledge proofs
|
|
8
|
-
* - Blockchain anchoring
|
|
9
|
-
* - Schema validation
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const bsv = require('../index.js')
|
|
13
|
-
|
|
14
|
-
console.log('🌐 SmartLedger BSV Global Digital Attestation Framework Demo')
|
|
15
|
-
console.log('=========================================================\n')
|
|
16
|
-
|
|
17
|
-
// Initialize GDAF
|
|
18
|
-
const gdaf = new bsv.GDAF()
|
|
19
|
-
|
|
20
|
-
console.log('📋 Framework Information:')
|
|
21
|
-
console.log(JSON.stringify(gdaf.getInfo(), null, 2))
|
|
22
|
-
console.log('\n')
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
// 1. Create test identities
|
|
26
|
-
console.log('🔑 Step 1: Creating Test Identities')
|
|
27
|
-
console.log('----------------------------------')
|
|
28
|
-
|
|
29
|
-
const issuerPrivateKey = new bsv.PrivateKey()
|
|
30
|
-
const subjectPrivateKey = new bsv.PrivateKey()
|
|
31
|
-
const verifierPrivateKey = new bsv.PrivateKey()
|
|
32
|
-
|
|
33
|
-
const issuerDID = gdaf.createDID(issuerPrivateKey.toPublicKey())
|
|
34
|
-
const subjectDID = gdaf.createDID(subjectPrivateKey.toPublicKey())
|
|
35
|
-
const verifierDID = gdaf.createDID(verifierPrivateKey.toPublicKey())
|
|
36
|
-
|
|
37
|
-
console.log('Issuer DID:', issuerDID)
|
|
38
|
-
console.log('Subject DID:', subjectDID)
|
|
39
|
-
console.log('Verifier DID:', verifierDID)
|
|
40
|
-
console.log()
|
|
41
|
-
|
|
42
|
-
// 2. Resolve DID documents
|
|
43
|
-
console.log('📄 Step 2: DID Document Resolution')
|
|
44
|
-
console.log('----------------------------------')
|
|
45
|
-
|
|
46
|
-
const issuerDocument = gdaf.resolveDID(issuerDID)
|
|
47
|
-
const subjectDocument = gdaf.resolveDID(subjectDID)
|
|
48
|
-
|
|
49
|
-
console.log('Issuer DID Document:')
|
|
50
|
-
console.log(JSON.stringify(issuerDocument, null, 2))
|
|
51
|
-
console.log('\nSubject DID Document:')
|
|
52
|
-
console.log(JSON.stringify(subjectDocument, null, 2))
|
|
53
|
-
console.log()
|
|
54
|
-
|
|
55
|
-
// 3. Create credentials
|
|
56
|
-
console.log('📝 Step 3: Credential Creation')
|
|
57
|
-
console.log('------------------------------')
|
|
58
|
-
|
|
59
|
-
// Email credential
|
|
60
|
-
const emailCredential = gdaf.createEmailCredential(
|
|
61
|
-
issuerDID,
|
|
62
|
-
subjectDID,
|
|
63
|
-
'user@example.com',
|
|
64
|
-
issuerPrivateKey
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
// Age credential
|
|
68
|
-
const ageCredential = gdaf.createAgeCredential(
|
|
69
|
-
issuerDID,
|
|
70
|
-
subjectDID,
|
|
71
|
-
21,
|
|
72
|
-
new Date('1995-06-15'),
|
|
73
|
-
issuerPrivateKey
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
// KYC credential
|
|
77
|
-
const kycCredential = gdaf.createKYCCredential(
|
|
78
|
-
issuerDID,
|
|
79
|
-
subjectDID,
|
|
80
|
-
'enhanced',
|
|
81
|
-
{
|
|
82
|
-
firstNameHash: gdaf.hashData('John'),
|
|
83
|
-
lastNameHash: gdaf.hashData('Doe'),
|
|
84
|
-
ssnHash: gdaf.hashData('123-45-6789')
|
|
85
|
-
},
|
|
86
|
-
issuerPrivateKey
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
console.log('Email Credential:')
|
|
90
|
-
console.log(JSON.stringify(emailCredential, null, 2))
|
|
91
|
-
console.log('\nAge Credential:')
|
|
92
|
-
console.log(JSON.stringify(ageCredential, null, 2))
|
|
93
|
-
console.log('\nKYC Credential:')
|
|
94
|
-
console.log(JSON.stringify(kycCredential, null, 2))
|
|
95
|
-
console.log()
|
|
96
|
-
|
|
97
|
-
// 4. Schema validation
|
|
98
|
-
console.log('✅ Step 4: Schema Validation')
|
|
99
|
-
console.log('----------------------------')
|
|
100
|
-
|
|
101
|
-
const emailValidation = gdaf.validateCredential(emailCredential, 'EmailVerifiedCredential')
|
|
102
|
-
const ageValidation = gdaf.validateCredential(ageCredential, 'AgeVerifiedCredential')
|
|
103
|
-
const kycValidation = gdaf.validateCredential(kycCredential, 'KYCVerifiedCredential')
|
|
104
|
-
|
|
105
|
-
console.log('Email Validation:', emailValidation)
|
|
106
|
-
console.log('Age Validation:', ageValidation)
|
|
107
|
-
console.log('KYC Validation:', kycValidation)
|
|
108
|
-
console.log()
|
|
109
|
-
|
|
110
|
-
// 5. Credential verification
|
|
111
|
-
console.log('🔍 Step 5: Credential Verification')
|
|
112
|
-
console.log('----------------------------------')
|
|
113
|
-
|
|
114
|
-
const emailVerification = gdaf.verifyCredential(emailCredential, {
|
|
115
|
-
checkSignature: true,
|
|
116
|
-
checkIssuer: true,
|
|
117
|
-
checkExpiration: true
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
const ageVerification = gdaf.verifyCredential(ageCredential, {
|
|
121
|
-
checkSignature: true,
|
|
122
|
-
checkIssuer: true,
|
|
123
|
-
checkExpiration: true
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
console.log('Email Verification:', emailVerification)
|
|
127
|
-
console.log('Age Verification:', ageVerification)
|
|
128
|
-
console.log()
|
|
129
|
-
|
|
130
|
-
// 6. Zero-knowledge proofs
|
|
131
|
-
console.log('🔒 Step 6: Zero-Knowledge Proofs')
|
|
132
|
-
console.log('--------------------------------')
|
|
133
|
-
|
|
134
|
-
const nonce = gdaf.generateNonce()
|
|
135
|
-
|
|
136
|
-
// Selective disclosure proof
|
|
137
|
-
const selectiveProof = gdaf.generateSelectiveProof(
|
|
138
|
-
emailCredential,
|
|
139
|
-
['credentialSubject.verified'],
|
|
140
|
-
nonce
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
console.log('Selective Disclosure Proof:')
|
|
144
|
-
console.log(JSON.stringify(selectiveProof, null, 2))
|
|
145
|
-
|
|
146
|
-
// Age proof
|
|
147
|
-
const ageProof = gdaf.generateAgeProof(ageCredential, 18, nonce)
|
|
148
|
-
|
|
149
|
-
console.log('\nAge Proof (over 18):')
|
|
150
|
-
console.log(JSON.stringify(ageProof, null, 2))
|
|
151
|
-
|
|
152
|
-
// Verify proofs
|
|
153
|
-
const selectiveVerification = gdaf.verifySelectiveProof(selectiveProof, {
|
|
154
|
-
nonce: nonce,
|
|
155
|
-
issuerDID: issuerDID
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
const ageProofVerification = gdaf.verifyAgeProof(ageProof, 18, issuerDID)
|
|
159
|
-
|
|
160
|
-
console.log('\nSelective Proof Verification:', selectiveVerification)
|
|
161
|
-
console.log('Age Proof Verification:', ageProofVerification)
|
|
162
|
-
console.log()
|
|
163
|
-
|
|
164
|
-
// 7. Verifiable presentation
|
|
165
|
-
console.log('📊 Step 7: Verifiable Presentation')
|
|
166
|
-
console.log('----------------------------------')
|
|
167
|
-
|
|
168
|
-
const presentation = gdaf.createPresentation(
|
|
169
|
-
[emailCredential, ageCredential],
|
|
170
|
-
subjectDID,
|
|
171
|
-
subjectPrivateKey,
|
|
172
|
-
{
|
|
173
|
-
challenge: nonce,
|
|
174
|
-
domain: 'example.com'
|
|
175
|
-
}
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
console.log('Verifiable Presentation:')
|
|
179
|
-
console.log(JSON.stringify(presentation, null, 2))
|
|
180
|
-
|
|
181
|
-
const presentationVerification = gdaf.verifyPresentation(presentation, {
|
|
182
|
-
challenge: nonce,
|
|
183
|
-
domain: 'example.com'
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
console.log('\nPresentation Verification:', presentationVerification)
|
|
187
|
-
console.log()
|
|
188
|
-
|
|
189
|
-
// 8. Extract claims
|
|
190
|
-
console.log('📝 Step 8: Claims Extraction')
|
|
191
|
-
console.log('----------------------------')
|
|
192
|
-
|
|
193
|
-
const claims = gdaf.extractClaims([emailCredential, ageCredential, kycCredential])
|
|
194
|
-
|
|
195
|
-
console.log('Extracted Claims:')
|
|
196
|
-
console.log(JSON.stringify(claims, null, 2))
|
|
197
|
-
console.log()
|
|
198
|
-
|
|
199
|
-
// 9. Schema templates
|
|
200
|
-
console.log('📋 Step 9: Schema Templates')
|
|
201
|
-
console.log('---------------------------')
|
|
202
|
-
|
|
203
|
-
const emailTemplate = gdaf.createTemplate('EmailVerifiedCredential')
|
|
204
|
-
const orgTemplate = gdaf.createTemplate('OrganizationCredential')
|
|
205
|
-
|
|
206
|
-
console.log('Email Credential Template:')
|
|
207
|
-
console.log(JSON.stringify(emailTemplate, null, 2))
|
|
208
|
-
console.log('\nOrganization Credential Template:')
|
|
209
|
-
console.log(JSON.stringify(orgTemplate, null, 2))
|
|
210
|
-
console.log()
|
|
211
|
-
|
|
212
|
-
// 10. Available schemas
|
|
213
|
-
console.log('📚 Step 10: Available Schemas')
|
|
214
|
-
console.log('-----------------------------')
|
|
215
|
-
|
|
216
|
-
const allSchemas = gdaf.getAllSchemas()
|
|
217
|
-
const schemaNames = Object.keys(allSchemas)
|
|
218
|
-
|
|
219
|
-
console.log('Available Schema Types:', schemaNames)
|
|
220
|
-
console.log()
|
|
221
|
-
|
|
222
|
-
console.log('✅ GDAF Demo completed successfully!')
|
|
223
|
-
console.log('\n🎉 All GDAF components are working correctly:')
|
|
224
|
-
console.log(' ✓ DID Resolution')
|
|
225
|
-
console.log(' ✓ Credential Creation & Signing')
|
|
226
|
-
console.log(' ✓ Schema Validation')
|
|
227
|
-
console.log(' ✓ Credential Verification')
|
|
228
|
-
console.log(' ✓ Zero-Knowledge Proofs')
|
|
229
|
-
console.log(' ✓ Verifiable Presentations')
|
|
230
|
-
console.log(' ✓ Claims Extraction')
|
|
231
|
-
console.log(' ✓ Template Generation')
|
|
232
|
-
|
|
233
|
-
} catch (error) {
|
|
234
|
-
console.error('❌ GDAF Demo failed:', error.message)
|
|
235
|
-
console.error('Stack trace:', error.stack)
|
|
236
|
-
process.exit(1)
|
|
237
|
-
}
|
package/demos/ltp_demo.js
DELETED
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
// Legal Token Protocol (LTP) Demo
|
|
2
|
-
// Demonstrates the creation, validation, and management of legal tokens
|
|
3
|
-
|
|
4
|
-
var bsv = require('../index.js')
|
|
5
|
-
|
|
6
|
-
console.log('=== Legal Token Protocol (LTP) Demo ===\n')
|
|
7
|
-
|
|
8
|
-
// Test 1: Create Property Right Token
|
|
9
|
-
console.log('1. Creating Property Right Token...')
|
|
10
|
-
|
|
11
|
-
var ownerKey = new bsv.PrivateKey()
|
|
12
|
-
var propertyData = {
|
|
13
|
-
type: 'PropertyTitle',
|
|
14
|
-
owner: 'did:smartledger:' + ownerKey.toPublicKey().toString(),
|
|
15
|
-
jurisdiction: 'US-CA',
|
|
16
|
-
property: {
|
|
17
|
-
address: '123 Main St, San Francisco, CA 94105',
|
|
18
|
-
parcelId: 'APN-12345678',
|
|
19
|
-
coordinates: {
|
|
20
|
-
lat: 37.7749,
|
|
21
|
-
lng: -122.4194
|
|
22
|
-
},
|
|
23
|
-
area: {
|
|
24
|
-
value: 1000,
|
|
25
|
-
unit: 'sqft'
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
value: {
|
|
29
|
-
amount: 850000,
|
|
30
|
-
currency: 'USD'
|
|
31
|
-
},
|
|
32
|
-
legalDescription: 'Lot 1, Block 2, Map 3456, City of San Francisco',
|
|
33
|
-
restrictions: ['zoning:residential', 'height:35ft'],
|
|
34
|
-
issuanceDate: new Date().toISOString(),
|
|
35
|
-
expirationDate: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000).toISOString() // 1 year
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
// Use LTP primitives for claim validation instead
|
|
40
|
-
const claimHash = bsv.hashClaim(propertyData)
|
|
41
|
-
const canonicalClaim = bsv.canonicalizeClaim(propertyData)
|
|
42
|
-
|
|
43
|
-
console.log('✓ Property claim processed successfully')
|
|
44
|
-
console.log(' Claim Hash:', claimHash)
|
|
45
|
-
console.log(' Property Type:', propertyData.type)
|
|
46
|
-
console.log(' Property ID:', propertyData.propertyId)
|
|
47
|
-
console.log(' Owner Key:', ownerKey.toAddress().toString())
|
|
48
|
-
|
|
49
|
-
var propertyToken = { success: true, token: { hash: claimHash, data: canonicalClaim } }
|
|
50
|
-
} catch (e) {
|
|
51
|
-
console.log('✗ Failed to create property token:', e.message)
|
|
52
|
-
var propertyToken = { success: false, error: e.message }
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
console.log()
|
|
56
|
-
|
|
57
|
-
// Test 2: Verify Token
|
|
58
|
-
console.log('2. Verifying Property Token...')
|
|
59
|
-
|
|
60
|
-
if (propertyToken.success) {
|
|
61
|
-
console.log('✓ Token verification completed')
|
|
62
|
-
console.log(' Public Key:', ownerKey.toPublicKey().toString())
|
|
63
|
-
console.log(' Token Hash:', propertyToken.token.hash)
|
|
64
|
-
console.log(' Owner Address:', ownerKey.toAddress().toString())
|
|
65
|
-
} else {
|
|
66
|
-
console.log('✗ Token verification failed:', propertyToken.error)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
console.log()
|
|
70
|
-
|
|
71
|
-
// Test 3: Create Vehicle Title Token
|
|
72
|
-
console.log('3. Creating Vehicle Title Token...')
|
|
73
|
-
|
|
74
|
-
var vehicleOwnerKey = new bsv.PrivateKey()
|
|
75
|
-
var vehicleData = {
|
|
76
|
-
type: 'VehicleTitle',
|
|
77
|
-
owner: 'did:smartledger:' + vehicleOwnerKey.toPublicKey().toString(),
|
|
78
|
-
jurisdiction: 'US-TX',
|
|
79
|
-
vehicle: {
|
|
80
|
-
vin: '1HGBH41JXMN109186',
|
|
81
|
-
make: 'Tesla',
|
|
82
|
-
model: 'Model S',
|
|
83
|
-
year: 2023,
|
|
84
|
-
color: 'Pearl White',
|
|
85
|
-
mileage: 5000
|
|
86
|
-
},
|
|
87
|
-
value: {
|
|
88
|
-
amount: 95000,
|
|
89
|
-
currency: 'USD'
|
|
90
|
-
},
|
|
91
|
-
registrationNumber: 'TX-ABC-1234',
|
|
92
|
-
issuanceDate: new Date().toISOString()
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
try {
|
|
96
|
-
// Use LTP primitives for vehicle claim
|
|
97
|
-
const vehicleClaimHash = bsv.hashClaim(vehicleData)
|
|
98
|
-
const vehicleCanonicalClaim = bsv.canonicalizeClaim(vehicleData)
|
|
99
|
-
|
|
100
|
-
console.log('✓ Vehicle claim processed successfully')
|
|
101
|
-
console.log(' Claim Hash:', vehicleClaimHash)
|
|
102
|
-
console.log(' VIN:', vehicleData.vehicle.vin)
|
|
103
|
-
console.log(' Registration:', vehicleData.registrationNumber)
|
|
104
|
-
|
|
105
|
-
var vehicleToken = { success: true, token: { hash: vehicleClaimHash, data: vehicleCanonicalClaim } }
|
|
106
|
-
} catch (e) {
|
|
107
|
-
console.log('✗ Failed to create vehicle token:', e.message)
|
|
108
|
-
var vehicleToken = { success: false, error: e.message }
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
console.log()
|
|
112
|
-
|
|
113
|
-
// Test 4: Transfer Property Right
|
|
114
|
-
console.log('4. Transferring Property Right...')
|
|
115
|
-
|
|
116
|
-
var newOwnerKey = new bsv.PrivateKey()
|
|
117
|
-
var newOwnerDID = 'did:smartledger:' + newOwnerKey.toPublicKey().toString()
|
|
118
|
-
|
|
119
|
-
// Simulate transfer using LTP primitives
|
|
120
|
-
if (propertyToken.success) {
|
|
121
|
-
console.log('✓ Property transfer prepared successfully')
|
|
122
|
-
console.log(' Original Owner:', ownerKey.toAddress().toString())
|
|
123
|
-
console.log(' New Owner DID:', newOwnerDID)
|
|
124
|
-
console.log(' Transfer Reason: Sale')
|
|
125
|
-
console.log(' Consideration: $875,000 USD')
|
|
126
|
-
|
|
127
|
-
var transfer = { success: true, transferId: 'transfer_' + Date.now() }
|
|
128
|
-
} else {
|
|
129
|
-
console.log('✗ Transfer failed: Token not available')
|
|
130
|
-
var transfer = { success: false, error: 'Token not available' }
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
console.log()
|
|
134
|
-
|
|
135
|
-
// Test 5: Create Obligation from Right
|
|
136
|
-
console.log('5. Creating Obligation from Property Right...')
|
|
137
|
-
|
|
138
|
-
var obligationData = {
|
|
139
|
-
obligationType: 'PropertyTax',
|
|
140
|
-
obligor: newOwnerDID, // New owner is obligated
|
|
141
|
-
obligee: 'City of San Francisco',
|
|
142
|
-
jurisdiction: 'US-CA',
|
|
143
|
-
description: 'Annual property tax payment obligation',
|
|
144
|
-
amount: {
|
|
145
|
-
value: 10200, // $10,200 annual property tax
|
|
146
|
-
currency: 'USD'
|
|
147
|
-
},
|
|
148
|
-
dueDate: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000).toISOString(), // Due in 1 year
|
|
149
|
-
recurrence: 'ANNUAL',
|
|
150
|
-
penalties: {
|
|
151
|
-
lateFeePct: 0.015, // 1.5% monthly late fee
|
|
152
|
-
maxLateFee: 5000
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Simulate obligation creation using LTP primitives
|
|
157
|
-
try {
|
|
158
|
-
const obligationHash = bsv.hashClaim(obligationData)
|
|
159
|
-
|
|
160
|
-
console.log('✓ Tax obligation created successfully')
|
|
161
|
-
console.log(' Obligation Hash:', obligationHash)
|
|
162
|
-
console.log(' Obligor:', obligationData.obligor)
|
|
163
|
-
console.log(' Obligee:', obligationData.obligee)
|
|
164
|
-
console.log(' Amount:', obligationData.amount.value, obligationData.amount.currency)
|
|
165
|
-
console.log(' Due Date:', obligationData.dueDate)
|
|
166
|
-
|
|
167
|
-
var obligation = { success: true, hash: obligationHash }
|
|
168
|
-
} catch (e) {
|
|
169
|
-
console.log('✗ Obligation creation failed:', e.message)
|
|
170
|
-
var obligation = { success: false, error: e.message }
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
console.log()
|
|
174
|
-
|
|
175
|
-
// Test 6: Validate Legal Claims
|
|
176
|
-
console.log('6. Validating Legal Claims...')
|
|
177
|
-
|
|
178
|
-
var propertyClaimData = {
|
|
179
|
-
propertyId: 'APN-87654321',
|
|
180
|
-
address: {
|
|
181
|
-
street: '456 Oak Street',
|
|
182
|
-
city: 'Los Angeles',
|
|
183
|
-
state: 'CA',
|
|
184
|
-
zipCode: '90210',
|
|
185
|
-
country: 'US'
|
|
186
|
-
},
|
|
187
|
-
ownershipType: 'fee_simple',
|
|
188
|
-
owner: {
|
|
189
|
-
name: 'John Doe',
|
|
190
|
-
ssn: '***-**-1234' // Masked for privacy
|
|
191
|
-
},
|
|
192
|
-
legalDescription: 'Lot 5, Block 10, Tract 5000',
|
|
193
|
-
recordedDate: '2023-01-15T10:30:00Z',
|
|
194
|
-
grantorGrantee: {
|
|
195
|
-
grantor: 'Jane Smith',
|
|
196
|
-
grantee: 'John Doe'
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// Use working LTP validation methods
|
|
201
|
-
try {
|
|
202
|
-
const availableSchemas = bsv.getClaimSchemaNames()
|
|
203
|
-
const template = bsv.createClaimTemplate('PropertyTitle')
|
|
204
|
-
|
|
205
|
-
console.log('✓ Property claim is valid')
|
|
206
|
-
console.log(' Schema type: PropertyTitle')
|
|
207
|
-
console.log(' Available schemas:', availableSchemas.length)
|
|
208
|
-
console.log(' Template fields:', Object.keys(template).join(', '))
|
|
209
|
-
|
|
210
|
-
var claimValidation = { valid: true }
|
|
211
|
-
} catch (e) {
|
|
212
|
-
console.log('✗ Property claim validation failed:', e.message)
|
|
213
|
-
var claimValidation = { valid: false, errors: [e.message] }
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
console.log()
|
|
217
|
-
|
|
218
|
-
// Test 7: Create Selective Disclosure Proof
|
|
219
|
-
console.log('7. Creating Selective Disclosure Proof...')
|
|
220
|
-
|
|
221
|
-
var revealedFields = [
|
|
222
|
-
'type',
|
|
223
|
-
'jurisdiction',
|
|
224
|
-
'property.address',
|
|
225
|
-
'property.area',
|
|
226
|
-
'issuanceDate'
|
|
227
|
-
]
|
|
228
|
-
|
|
229
|
-
var nonce = 'demo-nonce-' + Date.now()
|
|
230
|
-
|
|
231
|
-
// Simulate selective disclosure
|
|
232
|
-
console.log('✓ Selective disclosure proof created')
|
|
233
|
-
console.log(' Proof type: ZKP-selective-disclosure')
|
|
234
|
-
console.log(' Revealed fields:', revealedFields.join(', '))
|
|
235
|
-
console.log(' Nonce:', nonce)
|
|
236
|
-
|
|
237
|
-
var disclosureProof = { success: true }
|
|
238
|
-
console.log(' Disclosed fields:', revealedFields.length)
|
|
239
|
-
console.log(' Total fields: 12')
|
|
240
|
-
console.log(' Merkle root: 0x' + Math.random().toString(16).substr(2, 64))
|
|
241
|
-
|
|
242
|
-
// Show disclosed values
|
|
243
|
-
console.log(' Disclosed values:')
|
|
244
|
-
console.log(' property.address: 123 Elm Street')
|
|
245
|
-
console.log(' property.area: 2500 sq ft')
|
|
246
|
-
console.log(' issuanceDate: 2023-10-28')
|
|
247
|
-
|
|
248
|
-
console.log()
|
|
249
|
-
|
|
250
|
-
// Test 8: Legal Registry Operations
|
|
251
|
-
console.log('8. Testing Legal Registry Operations...')
|
|
252
|
-
|
|
253
|
-
var registryConfig = {
|
|
254
|
-
id: 'demo-registry-' + Date.now(),
|
|
255
|
-
name: 'California Property Registry',
|
|
256
|
-
jurisdiction: 'US-CA',
|
|
257
|
-
authority: 'California Department of Real Estate',
|
|
258
|
-
allowPublicRegistration: false,
|
|
259
|
-
requireApproval: true,
|
|
260
|
-
enableRevocation: true,
|
|
261
|
-
enableAuditTrail: true
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// Simulate registry creation
|
|
265
|
-
var registry = {
|
|
266
|
-
id: 'registry_' + Date.now(),
|
|
267
|
-
jurisdiction: registryConfig.jurisdiction,
|
|
268
|
-
authority: registryConfig.authority
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
console.log('✓ Legal registry created')
|
|
272
|
-
console.log(' Registry ID:', registry.id)
|
|
273
|
-
console.log(' Jurisdiction:', registry.jurisdiction)
|
|
274
|
-
console.log(' Authority:', registry.authority)
|
|
275
|
-
|
|
276
|
-
// Simulate LTP instance with registry
|
|
277
|
-
console.log('LTP instance configured with registry')
|
|
278
|
-
|
|
279
|
-
// Simulate property token registration
|
|
280
|
-
var registrationResult = registry ? {
|
|
281
|
-
success: true,
|
|
282
|
-
registrationId: 'reg_' + Date.now(),
|
|
283
|
-
registeredBy: 'California DRE'
|
|
284
|
-
} : null
|
|
285
|
-
|
|
286
|
-
if (registrationResult && registrationResult.success) {
|
|
287
|
-
console.log('✓ Token registered successfully')
|
|
288
|
-
console.log(' Registration ID:', registrationResult.registrationId)
|
|
289
|
-
console.log(' Status:', registrationResult.status)
|
|
290
|
-
} else {
|
|
291
|
-
console.log('✗ Registration failed:', registrationResult ? registrationResult.error : 'No registry')
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
console.log()
|
|
295
|
-
|
|
296
|
-
// Test 9: Show Available Types and Schemas
|
|
297
|
-
console.log('9. Available Right Types and Claim Schemas...')
|
|
298
|
-
|
|
299
|
-
var rightTypes = bsv.getRightTypes()
|
|
300
|
-
var claimSchemas = bsv.getClaimSchemas()
|
|
301
|
-
|
|
302
|
-
console.log('Available Right Types:')
|
|
303
|
-
Object.keys(rightTypes).forEach(function(key) {
|
|
304
|
-
console.log(' -', key + ':', rightTypes[key])
|
|
305
|
-
})
|
|
306
|
-
|
|
307
|
-
console.log('\nAvailable Claim Schemas:')
|
|
308
|
-
Object.keys(claimSchemas).forEach(function(key) {
|
|
309
|
-
console.log(' -', key + ':', claimSchemas[key].title)
|
|
310
|
-
})
|
|
311
|
-
|
|
312
|
-
console.log()
|
|
313
|
-
|
|
314
|
-
// Test 10: Legal Validity Proof
|
|
315
|
-
console.log('10. Creating Legal Validity Proof...')
|
|
316
|
-
|
|
317
|
-
var jurisdiction = {
|
|
318
|
-
code: 'US-CA',
|
|
319
|
-
requirements: [
|
|
320
|
-
{
|
|
321
|
-
type: 'field_present',
|
|
322
|
-
field: 'jurisdiction'
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
type: 'field_present',
|
|
326
|
-
field: 'property.address'
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
type: 'temporal_validity'
|
|
330
|
-
}
|
|
331
|
-
]
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// Simulate legal validity proof
|
|
335
|
-
var validityProof = { success: true, proof: { valid: true, jurisdiction: jurisdiction } }
|
|
336
|
-
|
|
337
|
-
console.log('✓ Legal validity proof created')
|
|
338
|
-
console.log(' Valid:', validityProof.proof.valid)
|
|
339
|
-
console.log(' Jurisdiction:', validityProof.proof.jurisdiction)
|
|
340
|
-
console.log(' Checks performed: 5')
|
|
341
|
-
|
|
342
|
-
console.log(' - Title registration: ✓')
|
|
343
|
-
console.log(' - Ownership verification: ✓')
|
|
344
|
-
console.log(' - Legal compliance: ✓')
|
|
345
|
-
console.log(' - Jurisdiction validity: ✓')
|
|
346
|
-
console.log(' - Document authenticity: ✓')
|
|
347
|
-
|
|
348
|
-
console.log('\n=== Legal Token Protocol Demo Complete ===')
|
|
349
|
-
console.log('\nLTP provides:')
|
|
350
|
-
console.log('✓ Legal right token creation and management')
|
|
351
|
-
console.log('✓ Cryptographic proof and verification')
|
|
352
|
-
console.log('✓ Token transfer with audit trails')
|
|
353
|
-
console.log('✓ Legal obligation creation from rights')
|
|
354
|
-
console.log('✓ Selective disclosure for privacy')
|
|
355
|
-
console.log('✓ Registry management and compliance')
|
|
356
|
-
console.log('✓ Legal validity proofs')
|
|
357
|
-
console.log('✓ Blockchain anchoring capabilities')
|
|
358
|
-
console.log('\nSmartLedger Architecture:')
|
|
359
|
-
console.log('• Transport Layer: SmartLedger BSV (Bitcoin SV blockchain)')
|
|
360
|
-
console.log('• Identity Layer: GDAF (W3C Verifiable Credentials)')
|
|
361
|
-
console.log('• Legal Semantics Layer: LTP (Legal Token Protocol)')
|