@smartledger/bsv 3.2.1 → 3.3.2

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/README.md +289 -55
  3. package/architecture_demo.js +247 -0
  4. package/bsv-covenant.min.js +10 -0
  5. package/bsv-gdaf.min.js +37 -0
  6. package/bsv-ltp.min.js +37 -0
  7. package/bsv-script-helper.min.js +10 -0
  8. package/bsv-security.min.js +31 -0
  9. package/bsv-shamir.min.js +12 -0
  10. package/bsv-smartcontract.min.js +37 -0
  11. package/bsv.bundle.js +9 -9
  12. package/bsv.min.js +3 -3
  13. package/build/bsv-covenant.min.js +10 -0
  14. package/build/bsv-script-helper.min.js +10 -0
  15. package/build/bsv-security.min.js +31 -0
  16. package/build/bsv-smartcontract.min.js +39 -0
  17. package/build/bsv.bundle.js +39 -0
  18. package/build/bsv.min.js +39 -0
  19. package/build/webpack.bundle.config.js +22 -0
  20. package/build/webpack.config.js +18 -0
  21. package/build/webpack.covenant.config.js +27 -0
  22. package/build/webpack.gdaf.config.js +54 -0
  23. package/build/webpack.ltp.config.js +17 -0
  24. package/build/webpack.script-helper.config.js +27 -0
  25. package/build/webpack.security.config.js +23 -0
  26. package/build/webpack.smartcontract.config.js +25 -0
  27. package/build/webpack.subproject.config.js +6 -0
  28. package/bundle-entry.js +341 -0
  29. package/complete_ltp_demo.js +511 -0
  30. package/covenant-entry.js +44 -0
  31. package/docs/pushtx-key-insights.md +106 -0
  32. package/gdaf-entry.js +54 -0
  33. package/index.js +272 -5
  34. package/lib/crypto/shamir.js +360 -0
  35. package/lib/gdaf/attestation-signer.js +461 -0
  36. package/lib/gdaf/attestation-verifier.js +600 -0
  37. package/lib/gdaf/did-resolver.js +382 -0
  38. package/lib/gdaf/index.js +471 -0
  39. package/lib/gdaf/schema-validator.js +682 -0
  40. package/lib/gdaf/smartledger-anchor.js +486 -0
  41. package/lib/gdaf/zk-prover.js +507 -0
  42. package/lib/ltp/anchor.js +438 -0
  43. package/lib/ltp/claim.js +1026 -0
  44. package/lib/ltp/index.js +470 -0
  45. package/lib/ltp/obligation.js +945 -0
  46. package/lib/ltp/proof.js +828 -0
  47. package/lib/ltp/registry.js +702 -0
  48. package/lib/ltp/right.js +765 -0
  49. package/lib/smart_contract/API_REFERENCE.md +1 -1
  50. package/lib/smart_contract/EXAMPLES.md +2 -2
  51. package/lib/smart_contract/QUICK_START.md +2 -2
  52. package/lib/smart_contract/README.md +1 -1
  53. package/lib/smart_contract/index.js +4 -0
  54. package/ltp-entry.js +92 -0
  55. package/package.json +91 -20
  56. package/script-helper-entry.js +49 -0
  57. package/security-entry.js +70 -0
  58. package/shamir-entry.js +173 -0
  59. package/shamir_demo.js +121 -0
  60. package/simple_demo.js +204 -0
  61. package/smartcontract-entry.js +133 -0
  62. package/test_shamir.js +221 -0
  63. package/test_standalone_shamir.html +83 -0
  64. package/tests/bundle-completeness-test.html +131 -0
  65. package/tests/bundle-demo.html +476 -0
  66. package/tests/smartcontract-test.html +239 -0
  67. package/tests/standalone-modules-test.html +260 -0
  68. package/tests/test.html +612 -0
  69. package/tests/unpkg-demo.html +194 -0
  70. package/docs/nchain.md +0 -958
package/gdaf-entry.js ADDED
@@ -0,0 +1,54 @@
1
+ 'use strict'
2
+
3
+ /**
4
+ * GDAF (Global Digital Attestation Framework) Standalone Bundle
5
+ *
6
+ * Entry point for creating standalone distribution of the Global Digital
7
+ * Attestation Framework. This module can be built with webpack to create
8
+ * a standalone bundle for browser use.
9
+ */
10
+
11
+ // Core BSV dependencies for GDAF
12
+ var PublicKey = require('./lib/publickey')
13
+ var PrivateKey = require('./lib/privatekey')
14
+ var Address = require('./lib/address')
15
+ var Transaction = require('./lib/transaction')
16
+ var Script = require('./lib/script')
17
+ var Hash = require('./lib/crypto/hash')
18
+ var ECDSA = require('./lib/crypto/ecdsa')
19
+ var Signature = require('./lib/crypto/signature')
20
+
21
+ // GDAF modules
22
+ var GDAF = require('./lib/gdaf')
23
+
24
+ // Create minimal BSV context for GDAF
25
+ var bsvContext = {
26
+ PublicKey: PublicKey,
27
+ PrivateKey: PrivateKey,
28
+ Address: Address,
29
+ Transaction: Transaction,
30
+ Script: Script,
31
+ crypto: {
32
+ Hash: Hash,
33
+ ECDSA: ECDSA,
34
+ Signature: Signature
35
+ }
36
+ }
37
+
38
+ // Export GDAF with BSV context
39
+ module.exports = {
40
+ GDAF: GDAF,
41
+ bsv: bsvContext,
42
+
43
+ // Direct access to GDAF classes for convenience
44
+ DIDResolver: require('./lib/gdaf/did-resolver'),
45
+ AttestationSigner: require('./lib/gdaf/attestation-signer'),
46
+ AttestationVerifier: require('./lib/gdaf/attestation-verifier'),
47
+ ZKProver: require('./lib/gdaf/zk-prover'),
48
+ SmartLedgerAnchor: require('./lib/gdaf/smartledger-anchor'),
49
+ SchemaValidator: require('./lib/gdaf/schema-validator'),
50
+
51
+ // Utility functions
52
+ version: '1.0.0',
53
+ description: 'SmartLedger BSV Global Digital Attestation Framework'
54
+ }
package/index.js CHANGED
@@ -48,6 +48,7 @@ bsv.crypto.Hash = require('./lib/crypto/hash')
48
48
  bsv.crypto.Random = require('./lib/crypto/random')
49
49
  bsv.crypto.Point = require('./lib/crypto/point')
50
50
  bsv.crypto.Signature = require('./lib/crypto/signature')
51
+ bsv.crypto.Shamir = require('./lib/crypto/shamir')
51
52
 
52
53
  // SmartLedger security enhancements
53
54
  bsv.crypto.SmartVerify = require('./lib/crypto/smartledger_verify')
@@ -82,8 +83,14 @@ bsv.PrivateKey = require('./lib/privatekey')
82
83
  bsv.PublicKey = require('./lib/publickey')
83
84
  bsv.Script = require('./lib/script')
84
85
  bsv.Transaction = require('./lib/transaction')
86
+ bsv.Input = require('./lib/transaction').Input
87
+ bsv.Output = require('./lib/transaction').Output
88
+ bsv.UnspentOutput = require('./lib/transaction').UnspentOutput
85
89
  bsv.Message = require('./lib/message')
90
+ bsv.Mnemonic = require('./lib/mnemonic')
91
+ bsv.ECIES = require('./lib/ecies')
86
92
  bsv.Signature = require('./lib/crypto/signature')
93
+ bsv.Shamir = require('./lib/crypto/shamir')
87
94
 
88
95
  // SmartLedger security modules (top-level access)
89
96
  bsv.SmartLedger = {
@@ -97,19 +104,279 @@ bsv.SmartLedger = {
97
104
  bsv.SmartVerify = require('./lib/crypto/smartledger_verify')
98
105
  bsv.EllipticFixed = require('./lib/crypto/elliptic-fixed')
99
106
 
100
- // SmartLedger Development & Testing Tools (Node.js only)
107
+ // SmartLedger Development & Testing Tools
108
+ try {
109
+ // SmartContract Framework - now available in both Node.js and browser
110
+ bsv.SmartContract = require('./lib/smart_contract')
111
+ } catch (e) {
112
+ // SmartContract not available - use standalone bsv-smartcontract.min.js
113
+ if (typeof window === 'undefined') {
114
+ console.warn('SmartContract module not available:', e.message)
115
+ }
116
+ }
117
+
118
+ // Node.js specific tools (advanced development tools)
101
119
  if (typeof window === 'undefined' && typeof require === 'function') {
102
120
  try {
103
121
  bsv.SmartUTXO = require('./lib/smartutxo')
104
122
  bsv.SmartMiner = require('./lib/smartminer')
105
123
  bsv.CustomScriptHelper = require('./lib/custom-script-helper')
106
-
107
- // Smart Contract Framework
108
- bsv.SmartContract = require('./lib/smart_contract')
109
124
  } catch (e) {
110
- // Browser environment - these tools not available
125
+ // Advanced tools not available
111
126
  }
112
127
  }
113
128
 
129
+ // Global Digital Attestation Framework (GDAF)
130
+ bsv.GDAF = require('./lib/gdaf')
131
+
132
+ // GDAF Direct Access Methods (for easier developer experience)
133
+ bsv.createDID = function(publicKey) {
134
+ var gdaf = new bsv.GDAF()
135
+ return gdaf.createDID(publicKey)
136
+ }
137
+
138
+ bsv.resolveDID = function(did) {
139
+ var gdaf = new bsv.GDAF()
140
+ return gdaf.resolveDID(did)
141
+ }
142
+
143
+ bsv.createEmailCredential = function(issuerDID, subjectDID, email, issuerPrivateKey) {
144
+ var gdaf = new bsv.GDAF()
145
+ return gdaf.createEmailCredential(issuerDID, subjectDID, email, issuerPrivateKey)
146
+ }
147
+
148
+ bsv.createAgeCredential = function(issuerDID, subjectDID, ageThreshold, birthDate, issuerPrivateKey) {
149
+ var gdaf = new bsv.GDAF()
150
+ return gdaf.createAgeCredential(issuerDID, subjectDID, ageThreshold, birthDate, issuerPrivateKey)
151
+ }
152
+
153
+ bsv.createKYCCredential = function(issuerDID, subjectDID, level, piiHashes, issuerPrivateKey) {
154
+ var gdaf = new bsv.GDAF()
155
+ return gdaf.createKYCCredential(issuerDID, subjectDID, level, piiHashes, issuerPrivateKey)
156
+ }
157
+
158
+ bsv.verifyCredential = function(credential, options) {
159
+ var gdaf = new bsv.GDAF()
160
+ return gdaf.verifyCredential(credential, options)
161
+ }
162
+
163
+ bsv.validateCredential = function(credential, schema) {
164
+ var gdaf = new bsv.GDAF()
165
+ return gdaf.validateCredential(credential, schema)
166
+ }
167
+
168
+ bsv.generateSelectiveProof = function(credential, revealedFields, nonce) {
169
+ var gdaf = new bsv.GDAF()
170
+ return gdaf.generateSelectiveProof(credential, revealedFields, nonce)
171
+ }
172
+
173
+ bsv.generateAgeProof = function(ageCredential, minimumAge, nonce) {
174
+ var gdaf = new bsv.GDAF()
175
+ return gdaf.generateAgeProof(ageCredential, minimumAge, nonce)
176
+ }
177
+
178
+ bsv.verifyAgeProof = function(proof, minimumAge, issuerDID) {
179
+ var gdaf = new bsv.GDAF()
180
+ return gdaf.verifyAgeProof(proof, minimumAge, issuerDID)
181
+ }
182
+
183
+ bsv.createPresentation = function(credentials, holderDID, holderPrivateKey, options) {
184
+ var gdaf = new bsv.GDAF()
185
+ return gdaf.createPresentation(credentials, holderDID, holderPrivateKey, options)
186
+ }
187
+
188
+ bsv.getCredentialSchemas = function() {
189
+ var gdaf = new bsv.GDAF()
190
+ return gdaf.getAllSchemas()
191
+ }
192
+
193
+ bsv.createCredentialTemplate = function(credentialType) {
194
+ var gdaf = new bsv.GDAF()
195
+ return gdaf.createTemplate(credentialType)
196
+ }
197
+
198
+ // Legal Token Protocol (LTP) - Primitives-Only Interface
199
+ bsv.LTP = require('./lib/ltp')
200
+
201
+ // LTP Right Token Primitives
202
+ bsv.prepareRightToken = function(type, issuerDID, subjectDID, claim, issuerPrivateKey, options) {
203
+ return bsv.LTP.Right.prepareRightToken(type, issuerDID, subjectDID, claim, issuerPrivateKey, options)
204
+ }
205
+
206
+ bsv.prepareRightTokenVerification = function(token, options) {
207
+ return bsv.LTP.Right.prepareRightTokenVerification(token, options)
208
+ }
209
+
210
+ bsv.prepareRightTokenTransfer = function(token, newOwnerDID, currentOwnerKey, options) {
211
+ return bsv.LTP.Right.prepareRightTokenTransfer(token, newOwnerDID, currentOwnerKey, options)
212
+ }
213
+
214
+ bsv.prepareRightTypeValidation = function(type) {
215
+ return bsv.LTP.Right.prepareRightTypeValidation(type)
216
+ }
217
+
218
+ // LTP Obligation Token Primitives
219
+ bsv.prepareObligationToken = function(type, issuerDID, obligorDID, obligation, issuerPrivateKey, options) {
220
+ return bsv.LTP.Obligation.prepareObligationToken(type, issuerDID, obligorDID, obligation, issuerPrivateKey, options)
221
+ }
222
+
223
+ bsv.prepareObligationVerification = function(token, options) {
224
+ return bsv.LTP.Obligation.prepareObligationVerification(token, options)
225
+ }
226
+
227
+ bsv.prepareObligationFulfillment = function(token, fulfillment, obligorKey, options) {
228
+ return bsv.LTP.Obligation.prepareObligationFulfillment(token, fulfillment, obligorKey, options)
229
+ }
230
+
231
+ bsv.prepareObligationBreachAssessment = function(token, breach, assessor) {
232
+ return bsv.LTP.Obligation.prepareObligationBreachAssessment(token, breach, assessor)
233
+ }
234
+
235
+ bsv.prepareObligationMonitoringReport = function(obligations, criteria) {
236
+ return bsv.LTP.Obligation.prepareObligationMonitoringReport(obligations, criteria)
237
+ }
238
+
239
+ // LTP Claim Validation Primitives
240
+ bsv.prepareClaimValidation = function(claim, schemaName) {
241
+ return bsv.LTP.Claim.prepareClaimValidation(claim, schemaName)
242
+ }
243
+
244
+ bsv.prepareClaimAttestation = function(claim, schemaName, attestor) {
245
+ return bsv.LTP.Claim.prepareClaimAttestation(claim, schemaName, attestor)
246
+ }
247
+
248
+ bsv.prepareClaimDispute = function(claimHash, disputant, dispute) {
249
+ return bsv.LTP.Claim.prepareClaimDispute(claimHash, disputant, dispute)
250
+ }
251
+
252
+ bsv.prepareBulkClaimValidation = function(claims, schemaName) {
253
+ return bsv.LTP.Claim.prepareBulkClaimValidation(claims, schemaName)
254
+ }
255
+
256
+ bsv.prepareClaimTemplate = function(schemaName, options) {
257
+ return bsv.LTP.Claim.prepareClaimTemplate(schemaName, options)
258
+ }
259
+
260
+ // LTP Proof Generation Primitives
261
+ bsv.prepareSignatureProof = function(token, privateKey, options) {
262
+ return bsv.LTP.Proof.prepareSignatureProof(token, privateKey, options)
263
+ }
264
+
265
+ bsv.prepareSignatureVerification = function(token, publicKey) {
266
+ return bsv.LTP.Proof.prepareSignatureVerification(token, publicKey)
267
+ }
268
+
269
+ bsv.prepareSelectiveDisclosure = function(token, revealedFields, nonce) {
270
+ return bsv.LTP.Proof.prepareSelectiveDisclosure(token, revealedFields, nonce)
271
+ }
272
+
273
+ bsv.prepareSelectiveDisclosureVerification = function(proof, expectedNonce) {
274
+ return bsv.LTP.Proof.prepareSelectiveDisclosureVerification(proof, expectedNonce)
275
+ }
276
+
277
+ bsv.prepareLegalValidityProof = function(token, jurisdiction, nonce) {
278
+ return bsv.LTP.Proof.prepareLegalValidityProof(token, jurisdiction, nonce)
279
+ }
280
+
281
+ bsv.prepareZeroKnowledgeProof = function(token, statement, nonce) {
282
+ return bsv.LTP.Proof.prepareZeroKnowledgeProof(token, statement, nonce)
283
+ }
284
+
285
+ // LTP Registry Management Primitives
286
+ bsv.prepareRegistry = function(config) {
287
+ return bsv.LTP.Registry.prepareRegistry(config)
288
+ }
289
+
290
+ bsv.prepareTokenRegistration = function(token, registryConfig, options) {
291
+ return bsv.LTP.Registry.prepareTokenRegistration(token, registryConfig, options)
292
+ }
293
+
294
+ bsv.prepareTokenApproval = function(tokenId, approver, registryConfig) {
295
+ return bsv.LTP.Registry.prepareTokenApproval(tokenId, approver, registryConfig)
296
+ }
297
+
298
+ bsv.prepareTokenRevocation = function(tokenId, revocation, registryConfig) {
299
+ return bsv.LTP.Registry.prepareTokenRevocation(tokenId, revocation, registryConfig)
300
+ }
301
+
302
+ bsv.prepareTokenStatusQuery = function(tokenId, registryConfig) {
303
+ return bsv.LTP.Registry.prepareTokenStatusQuery(tokenId, registryConfig)
304
+ }
305
+
306
+ bsv.prepareTokenSearch = function(criteria, registryConfig) {
307
+ return bsv.LTP.Registry.prepareTokenSearch(criteria, registryConfig)
308
+ }
309
+
310
+ bsv.prepareStatisticsQuery = function(registryConfig) {
311
+ return bsv.LTP.Registry.prepareStatisticsQuery(registryConfig)
312
+ }
313
+
314
+ bsv.prepareAuditLogQuery = function(registryConfig, options) {
315
+ return bsv.LTP.Registry.prepareAuditLogQuery(registryConfig, options)
316
+ }
317
+
318
+ // LTP Blockchain Anchoring Primitives
319
+ bsv.prepareTokenCommitment = function(token, options) {
320
+ return bsv.LTP.Anchor.prepareTokenCommitment(token, options)
321
+ }
322
+
323
+ bsv.prepareBatchCommitment = function(tokens, options) {
324
+ return bsv.LTP.Anchor.prepareBatchCommitment(tokens, options)
325
+ }
326
+
327
+ bsv.verifyTokenAnchor = function(token, txid, txData) {
328
+ return bsv.LTP.Anchor.verifyTokenAnchor(token, txid, txData)
329
+ }
330
+
331
+ bsv.formatRevocation = function(tokenId, revocationData) {
332
+ return bsv.LTP.Anchor.formatRevocation(tokenId, revocationData)
333
+ }
334
+
335
+ // LTP Static Data Access (unchanged)
336
+ bsv.getRightTypes = function() {
337
+ return bsv.LTP.Right.getRightTypes()
338
+ }
339
+
340
+ bsv.getObligationTypes = function() {
341
+ return bsv.LTP.Obligation.getObligationTypes()
342
+ }
343
+
344
+ bsv.getObligationPriority = function() {
345
+ return bsv.LTP.Obligation.getObligationPriority()
346
+ }
347
+
348
+ bsv.getObligationStatus = function() {
349
+ return bsv.LTP.Obligation.getObligationStatus()
350
+ }
351
+
352
+ bsv.getClaimSchemas = function() {
353
+ return bsv.LTP.Claim.getSchemas()
354
+ }
355
+
356
+ bsv.getClaimSchemaNames = function() {
357
+ return bsv.LTP.Claim.getSchemaNames()
358
+ }
359
+
360
+ bsv.getClaimSchema = function(schemaName) {
361
+ return bsv.LTP.Claim.getSchema(schemaName)
362
+ }
363
+
364
+ bsv.createClaimTemplate = function(schemaName) {
365
+ return bsv.LTP.Claim.createTemplate(schemaName)
366
+ }
367
+
368
+ // LTP Utility Functions
369
+ bsv.canonicalizeClaim = function(claim) {
370
+ return bsv.LTP.Claim.canonicalize(claim)
371
+ }
372
+
373
+ bsv.hashClaim = function(claim) {
374
+ return bsv.LTP.Claim.hash(claim)
375
+ }
376
+
377
+ bsv.addCustomClaimSchema = function(name, schema) {
378
+ return bsv.LTP.Claim.addSchema(name, schema)
379
+ }
380
+
114
381
  // Internal usage, exposed for testing/advanced tweaking
115
382
  bsv.Transaction.sighash = require('./lib/transaction/sighash')