@smartledger/bsv 3.3.2 → 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.
Files changed (79) hide show
  1. package/CHANGELOG.md +211 -83
  2. package/README.md +266 -71
  3. package/bsv-covenant.min.js +26 -3
  4. package/bsv-gdaf.min.js +11 -9
  5. package/bsv-ltp.min.js +10 -8
  6. package/bsv-script-helper.min.js +2 -2
  7. package/bsv-security.min.js +3 -24
  8. package/bsv-shamir.min.js +2 -2
  9. package/bsv-smartcontract.min.js +10 -8
  10. package/bsv.bundle.js +9 -9
  11. package/bsv.min.js +10 -8
  12. package/build/webpack.bundle.config.js +2 -2
  13. package/build/webpack.config.js +2 -2
  14. package/build/webpack.covenant.config.js +2 -2
  15. package/build/webpack.gdaf.config.js +6 -43
  16. package/build/webpack.script-helper.config.js +2 -2
  17. package/build/webpack.security.config.js +2 -2
  18. package/build/webpack.smartcontract.config.js +2 -2
  19. package/bundle-entry.js +1 -341
  20. package/covenant-entry.js +1 -44
  21. package/docs/DOCUMENTATION_REVIEW_REPORT.md +295 -0
  22. package/docs/MODULE_REFERENCE_COMPLETE.md +330 -0
  23. package/docs/README.md +107 -79
  24. package/docs/advanced/LEGAL_TOKEN_PROTOCOL.md +411 -0
  25. package/docs/advanced/SMART_CONTRACT_GUIDE.md +1255 -0
  26. package/docs/advanced/UTXO_MANAGER_GUIDE.md +851 -0
  27. package/docs/api/LTP.md +334 -0
  28. package/docs/getting-started/INSTALLATION.md +410 -0
  29. package/docs/getting-started/QUICK_START.md +180 -0
  30. package/docs/migration/FROM_BSV_1_5_6.md +260 -0
  31. package/docs/technical/GDAF_DEVELOPER_INTERFACE.md +187 -0
  32. package/docs/technical/GDAF_IMPLEMENTATION_COMPLETE.md +190 -0
  33. package/docs/technical/SHAMIR_INTEGRATION_SUMMARY.md +165 -0
  34. package/docs/technical/roadmap.md +1250 -0
  35. package/docs/technical/trust_law.md +142 -0
  36. package/gdaf-entry.js +2 -54
  37. package/index.js +32 -0
  38. package/ltp-entry.js +2 -92
  39. package/package.json +6 -4
  40. package/script-helper-entry.js +1 -49
  41. package/security-entry.js +1 -70
  42. package/shamir-entry.js +1 -173
  43. package/smartcontract-entry.js +1 -133
  44. package/tests/test_builtin_verify.js +117 -0
  45. package/tests/test_debug_integration.js +71 -0
  46. package/tests/test_ecdsa_little.js +70 -0
  47. package/tests/test_smartverify_der.js +110 -0
  48. package/utilities/blockchain-state.js +155 -155
  49. package/utilities/blockchain-state.json +103293 -5244
  50. package/utilities/miner-simulator.js +354 -358
  51. package/utilities/mock-utxo-generator.js +54 -54
  52. package/utilities/raw-tx-examples.js +120 -122
  53. package/utilities/success-demo.js +104 -105
  54. package/utilities/transaction-examples.js +188 -188
  55. package/utilities/utxo-manager.js +91 -91
  56. package/utilities/wallet-setup.js +79 -80
  57. package/utilities/working-signature-demo.js +108 -110
  58. package/SECURITY.md +0 -75
  59. package/architecture_demo.js +0 -247
  60. package/build/bsv-covenant.min.js +0 -10
  61. package/build/bsv-script-helper.min.js +0 -10
  62. package/build/bsv-security.min.js +0 -31
  63. package/build/bsv-smartcontract.min.js +0 -39
  64. package/build/bsv.bundle.js +0 -39
  65. package/build/bsv.min.js +0 -39
  66. package/complete_ltp_demo.js +0 -511
  67. package/shamir_demo.js +0 -121
  68. package/simple_demo.js +0 -204
  69. package/validation_test.js +0 -97
  70. /package/docs/{ADVANCED_COVENANT_DEVELOPMENT.md → advanced/ADVANCED_COVENANT_DEVELOPMENT.md} +0 -0
  71. /package/docs/{CUSTOM_SCRIPT_DEVELOPMENT.md → advanced/CUSTOM_SCRIPT_DEVELOPMENT.md} +0 -0
  72. /package/docs/{block.md → api/BLOCKS.md} +0 -0
  73. /package/docs/{ecies.md → api/ECIES.md} +0 -0
  74. /package/docs/{networks.md → api/NETWORKS.md} +0 -0
  75. /package/docs/{script.md → api/SCRIPTS.md} +0 -0
  76. /package/docs/{transaction.md → api/TRANSACTIONS.md} +0 -0
  77. /package/docs/{unspentoutput.md → api/UTXO.md} +0 -0
  78. /package/{test_shamir.js → tests/test_shamir.js} +0 -0
  79. /package/{test_standalone_shamir.html → tests/test_standalone_shamir.html} +0 -0
@@ -0,0 +1,142 @@
1
+ Excellent. Below is the **Trust Protocol Mapping Document (Draft v1.0)** — a comprehensive bridge between *traditional common-law trust principles* (as represented in Weiss’s Concise Trustee Handbook and similar express-trust doctrines) and *SmartLedger’s modern digital legal architecture* (SmartLedger-BSV + LTP + GDAF + NotaryHash).
2
+
3
+ ---
4
+
5
+ # 🧾 **Trust Protocol Mapping Document (v1.0)**
6
+
7
+ ### *Bridging Express Trust Law and the Legal Token Protocol (LTP)*
8
+
9
+ ---
10
+
11
+ ## ⚖️ 1. Core Legal–Digital Mapping
12
+
13
+ | **Traditional Trust Element** | **Description (Common Law)** | **Digital Representation (SmartLedger Framework)** | **Implemented In** |
14
+ | ----------------------------- | ------------------------------------------------------------------------ | -------------------------------------------------------------------------- | ---------------------------------- |
15
+ | **Settlor (Grantor)** | Creator of the trust; provides property or rights to be held in trust. | DID representing issuing authority (may be individual, corporation, DAO). | `identity/` → `createDID()` |
16
+ | **Trustee(s)** | Hold and manage property for benefit of beneficiary; owe fiduciary duty. | DID(s) with VC attestation of role and fiduciary obligations. | `identity/`, `legal/ltp/`, `gdaf/` |
17
+ | **Beneficiary(ies)** | The party entitled to benefit from the trust corpus. | Subject DID(s) listed in claim or rights object. | `legal/ltp/` |
18
+ | **Corpus (Res)** | Property, asset, or rights being held. | Tokenized “claim” object within Legal Token Protocol. | `ltp/` |
19
+ | **Trust Instrument** | Written or oral declaration establishing trust terms. | JSON-LD trust schema anchored via NotaryHash; cryptographically signed. | `anchor/`, `gdaf/` |
20
+ | **Purpose Clause** | Lawful reason for trust (charitable, private, etc.). | `purpose` field in token schema (ISO 3166 jurisdictional & legal tags). | `ltp/schema` |
21
+ | **Jurisdiction (Situs)** | Governing law and forum. | `jurisdiction` field in credential metadata (ISO country + legal system). | `compliance/` |
22
+ | **Trust Certificate** | Document showing beneficial ownership or capital interest. | Token credential (VC or NFT-style right token) anchored on-chain. | `ltp/`, `gdaf/` |
23
+ | **Minutes / Accounting** | Trustee logs of actions, decisions, disbursements. | Verifiable “ActionLogCredential” anchored on-chain (audit trail). | `anchor/`, `gdaf/` |
24
+ | **Trustee Resolution** | Decision or vote by trustees. | Multi-sig or VC “ResolutionCredential” anchored + signed by quorum. | `ltp/`, `identity/` |
25
+ | **Revocation / Termination** | Ending or amending trust instrument. | `revokeRightToken(tokenId)` + updated anchor proof in revocation registry. | `ltp/` |
26
+ | **Liability & Indemnity** | Limits trustee liability or defines indemnification. | Schema fields `trusteeIndemnity`, `liabilityLimit`, hashed in corpus. | `ltp/schema` |
27
+ | **Audit & Oversight** | External or internal verification of compliance. | Chain-based audit credential + GDAF selective proof verification. | `gdaf/`, `anchor/` |
28
+
29
+ ---
30
+
31
+ ## 🧱 2. Protocol Flow Example: Creation → Management → Termination
32
+
33
+ 1. **Declaration Phase**
34
+
35
+ ```js
36
+ const settlorDid = SmartLedgerBSV.GDAF.createDID(pubKey);
37
+ const trusteeDid = SmartLedgerBSV.GDAF.createDID(trusteeKey);
38
+ const trustSchema = SmartLedgerBSV.LTP.createRightToken(
39
+ 'PrivateExpressTrust',
40
+ trusteeDid,
41
+ { corpus: 'DigitalAssetXYZ', purpose: 'Beneficiary Support', jurisdiction: 'US-VA' },
42
+ settlorKey
43
+ );
44
+ const txid = SmartLedgerBSV.Anchor.commitHash(trustSchema.rootHash, { purpose: 'trust-declaration' });
45
+ ```
46
+
47
+ 2. **Operation Phase**
48
+
49
+ * Trustees issue VC “TrusteeActionCredential” for each action (investment, distribution, amendment).
50
+ * Anchors created via NotaryHash.
51
+ * Beneficiaries view proofs using ZK disclosure of entitlement without revealing full corpus.
52
+
53
+ 3. **Termination Phase**
54
+
55
+ ```js
56
+ SmartLedgerBSV.LTP.revokeRightToken(trustSchema.id);
57
+ SmartLedgerBSV.Anchor.commitHash(revocationHash, { purpose: 'trust-termination' });
58
+ ```
59
+
60
+ ---
61
+
62
+ ## 🧩 3. Compliance & Legal Framework Overlay
63
+
64
+ | **Principle** | **SmartLedger Implementation** | **Effect** |
65
+ | ------------------ | ---------------------------------------------------------------- | -------------------------------------------- |
66
+ | *Lawful purpose* | Schema validation forbids unlawful or undefined `purpose` field. | Ensures digital trusts are legally valid. |
67
+ | *Fiduciary duty* | VC attestation + signature requirement for trustee actions. | Enforceable accountability. |
68
+ | *Privacy duty* | HMAC/commitment model, zero-knowledge field proofs. | GDPR & fiduciary confidentiality compliance. |
69
+ | *Accounting duty* | Immutable audit logs via anchor proofs. | Transparent stewardship. |
70
+ | *Right to redress* | Dispute resolution VC + signature chain. | Legal recourse framework. |
71
+
72
+ ---
73
+
74
+ ## 🔐 4. Schema Alignment
75
+
76
+ ### TrustCredential (example)
77
+
78
+ ```json
79
+ {
80
+ "@context": ["https://www.w3.org/2018/credentials/v1", "https://smartledger.org/ltp/trust/v1"],
81
+ "type": ["VerifiableCredential", "TrustCredential"],
82
+ "issuer": "did:smartledger:abcd1234",
83
+ "issuanceDate": "2025-10-22T00:00:00Z",
84
+ "credentialSubject": {
85
+ "trustName": "Ward Family Private Express Trust",
86
+ "settlor": "did:smartledger:settlor123",
87
+ "trustee": ["did:smartledger:trustee456"],
88
+ "beneficiary": ["did:smartledger:beneficiary789"],
89
+ "corpus": { "assetType": "DigitalProperty", "assetId": "hash:abcd" },
90
+ "purpose": "Estate Preservation",
91
+ "jurisdiction": "US-VA"
92
+ },
93
+ "proof": {
94
+ "type": "SmartLedgerSignature2025",
95
+ "created": "2025-10-22T00:00:00Z",
96
+ "proofPurpose": "assertionMethod",
97
+ "verificationMethod": "did:smartledger:abcd1234#keys-1",
98
+ "jws": "eyJhbGciOiJFUzI1NiIsInR5cCI6..."
99
+ }
100
+ }
101
+ ```
102
+
103
+ ---
104
+
105
+ ## 🧩 5. Inter-Protocol Integration
106
+
107
+ | **Component** | **Purpose** | **Trust-Mapping Equivalent** |
108
+ | -------------------------------- | ------------------------------------------------------- | --------------------------------------------------------------- |
109
+ | **SmartLedger-BSV Crypto Layer** | Provides signature, Shamir recovery, canonical hashing. | Legal “seal” of trustee instrument. |
110
+ | **GDAF (Identity)** | Defines DID, VC issuance, selective proof. | Identifies Settlor/Trustee/Beneficiary with attested authority. |
111
+ | **LTP (Legal Tokens)** | Encodes property, licenses, rights. | Defines trust corpus & certificates. |
112
+ | **NotaryHash** | Anchors proofs on-chain. | Ledgered minutes, immutable recordkeeping. |
113
+ | **Compliance Module** | Applies GDPR/eIDAS/KYC filters. | Ensures lawful privacy & admissibility. |
114
+
115
+ ---
116
+
117
+ ## 🌐 6. Future Extensions
118
+
119
+ | **Goal** | **Description** |
120
+ | ------------------------------------------- | -------------------------------------------------------------------- |
121
+ | **Multi-jurisdiction Templates** | Schema variants for US Common Law, UK Equity, EU Civil Trusts. |
122
+ | **Trustee Dashboard SDK** | UI toolkit to manage credentials, actions, audit logs. |
123
+ | **AI Compliance Auditor** | GDAF-linked AI validator for fiduciary & jurisdictional consistency. |
124
+ | **Integration with National ID frameworks** | Optional verification with eIDAS/eID. |
125
+
126
+ ---
127
+
128
+ ## 🧭 7. Conclusion
129
+
130
+ By aligning SmartLedger’s LTP & GDAF architecture with express trust law, the system transforms **trusts, contracts, and fiduciary duties** into **digitally verifiable legal primitives**.
131
+
132
+ Every trustee signature, declaration, and action can now be:
133
+ ✅ Proven on-chain
134
+ ✅ Audited under jurisdiction
135
+ ✅ Recovered by lawful heirs
136
+ ✅ Compliant with privacy & fiduciary standards
137
+
138
+ This makes SmartLedger’s infrastructure the **world’s first “Trust-as-Code” framework** — where **Law, Ledger, and Logic** converge.
139
+
140
+ ---
141
+
142
+ Would you like me to extend this into a **formal Trust Protocol Specification (TPS 1.0)** — with detailed JSON schemas, method signatures, and governance model (Trust Registrar, Revocation Registry, Jurisdiction Tags, etc.) so your LTP developers can begin implementation directly?
package/gdaf-entry.js CHANGED
@@ -1,54 +1,2 @@
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
- }
1
+ // GDAF module placeholder - will be implemented in future release
2
+ module.exports = require('./lib/smart_contract');
package/index.js CHANGED
@@ -332,6 +332,38 @@ bsv.formatRevocation = function(tokenId, revocationData) {
332
332
  return bsv.LTP.Anchor.formatRevocation(tokenId, revocationData)
333
333
  }
334
334
 
335
+ // Backward Compatibility: Direct LTP Functions (Wrapper Layer)
336
+ // These functions provide the old-style direct API that demos expect
337
+
338
+ bsv.createRightToken = function(rightData, privateKey, options) {
339
+ var ltp = new bsv.LTP()
340
+ return ltp.createRightToken(rightData, privateKey, options)
341
+ }
342
+
343
+ bsv.verifyLegalToken = function(token, publicKey) {
344
+ var ltp = new bsv.LTP()
345
+ return ltp.verifyToken(token, publicKey)
346
+ }
347
+
348
+ bsv.validateLegalClaim = function(claimData, schemaType) {
349
+ var ltp = new bsv.LTP()
350
+ return ltp.validateClaim(claimData, schemaType)
351
+ }
352
+
353
+ bsv.createSelectiveDisclosure = function(token, revealedFields, nonce) {
354
+ var ltp = new bsv.LTP()
355
+ return ltp.createSelectiveDisclosure(token, revealedFields, nonce)
356
+ }
357
+
358
+ bsv.createLegalRegistry = function(config) {
359
+ return bsv.LTP.Registry.prepareRegistry(config)
360
+ }
361
+
362
+ bsv.createLegalValidityProof = function(token, jurisdiction, nonce) {
363
+ var ltp = new bsv.LTP()
364
+ return ltp.createLegalValidityProof(token, jurisdiction, nonce)
365
+ }
366
+
335
367
  // LTP Static Data Access (unchanged)
336
368
  bsv.getRightTypes = function() {
337
369
  return bsv.LTP.Right.getRightTypes()
package/ltp-entry.js CHANGED
@@ -1,92 +1,2 @@
1
- /**
2
- * SmartLedger-BSV Legal Token Protocol (LTP) - Standalone Entry Point
3
- *
4
- * This entry point provides the complete Legal Token Protocol framework
5
- * as a standalone module for browser and Node.js environments.
6
- *
7
- * Features:
8
- * - Complete LTP primitives-only architecture
9
- * - Legal claim validation and attestation
10
- * - Right and obligation token management
11
- * - Cryptographic proof generation
12
- * - Registry and blockchain anchoring preparation
13
- * - Full W3C compatibility and legal compliance
14
- */
15
-
16
- const bsv = require('./index.js')
17
-
18
- // Export LTP functionality as standalone module
19
- module.exports = {
20
- // Core BSV functionality needed for LTP
21
- PrivateKey: bsv.PrivateKey,
22
- PublicKey: bsv.PublicKey,
23
- Address: bsv.Address,
24
- Transaction: bsv.Transaction,
25
- Script: bsv.Script,
26
- crypto: bsv.crypto,
27
-
28
- // Complete LTP framework
29
- LTP: bsv.LTP,
30
-
31
- // Right Token Primitives
32
- prepareRightToken: bsv.prepareRightToken,
33
- prepareRightTokenVerification: bsv.prepareRightTokenVerification,
34
- prepareRightTokenTransfer: bsv.prepareRightTokenTransfer,
35
- prepareRightTypeValidation: bsv.prepareRightTypeValidation,
36
-
37
- // Obligation Token Primitives
38
- prepareObligationToken: bsv.prepareObligationToken,
39
- prepareObligationVerification: bsv.prepareObligationVerification,
40
- prepareObligationFulfillment: bsv.prepareObligationFulfillment,
41
- prepareObligationBreachAssessment: bsv.prepareObligationBreachAssessment,
42
- prepareObligationMonitoringReport: bsv.prepareObligationMonitoringReport,
43
-
44
- // Claim Validation Primitives
45
- prepareClaimValidation: bsv.prepareClaimValidation,
46
- prepareClaimAttestation: bsv.prepareClaimAttestation,
47
- prepareClaimDispute: bsv.prepareClaimDispute,
48
- prepareBulkClaimValidation: bsv.prepareBulkClaimValidation,
49
- prepareClaimTemplate: bsv.prepareClaimTemplate,
50
-
51
- // Proof Generation Primitives
52
- prepareSignatureProof: bsv.prepareSignatureProof,
53
- prepareSignatureVerification: bsv.prepareSignatureVerification,
54
- prepareSelectiveDisclosure: bsv.prepareSelectiveDisclosure,
55
- prepareSelectiveDisclosureVerification: bsv.prepareSelectiveDisclosureVerification,
56
- prepareLegalValidityProof: bsv.prepareLegalValidityProof,
57
- prepareZeroKnowledgeProof: bsv.prepareZeroKnowledgeProof,
58
-
59
- // Registry Management Primitives
60
- prepareRegistry: bsv.prepareRegistry,
61
- prepareTokenRegistration: bsv.prepareTokenRegistration,
62
- prepareTokenApproval: bsv.prepareTokenApproval,
63
- prepareTokenRevocation: bsv.prepareTokenRevocation,
64
- prepareTokenStatusQuery: bsv.prepareTokenStatusQuery,
65
- prepareTokenSearch: bsv.prepareTokenSearch,
66
- prepareStatisticsQuery: bsv.prepareStatisticsQuery,
67
- prepareAuditLogQuery: bsv.prepareAuditLogQuery,
68
-
69
- // Blockchain Anchoring Primitives
70
- prepareTokenCommitment: bsv.prepareTokenCommitment,
71
- prepareBatchCommitment: bsv.prepareBatchCommitment,
72
- verifyTokenAnchor: bsv.verifyTokenAnchor,
73
- formatRevocation: bsv.formatRevocation,
74
-
75
- // Utility Functions
76
- getRightTypes: bsv.getRightTypes,
77
- getObligationTypes: bsv.getObligationTypes,
78
- getObligationPriority: bsv.getObligationPriority,
79
- getObligationStatus: bsv.getObligationStatus,
80
- getClaimSchemas: bsv.getClaimSchemas,
81
- getClaimSchemaNames: bsv.getClaimSchemaNames,
82
- getClaimSchema: bsv.getClaimSchema,
83
- createClaimTemplate: bsv.createClaimTemplate,
84
- canonicalizeClaim: bsv.canonicalizeClaim,
85
- hashClaim: bsv.hashClaim,
86
- addCustomClaimSchema: bsv.addCustomClaimSchema,
87
-
88
- // Version and metadata
89
- version: '3.3.0',
90
- framework: 'Legal Token Protocol',
91
- architecture: 'primitives-only'
92
- }
1
+ // LTP module placeholder - will be implemented in future release
2
+ module.exports = require('./lib/smart_contract');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@smartledger/bsv",
3
- "version": "3.3.2",
4
- "description": "🚀 Complete Bitcoin SV development framework with Legal Token Protocol (LTP), Global Digital Attestation Framework (GDAF), Shamir Secret Sharing, and 9 flexible loading options. Includes primitives-only architecture for maximum integration flexibility, SmartContract framework, covenant builder, and comprehensive Bitcoin SV API. Perfect for legal tokens, DeFi, smart contracts, and secure Bitcoin applications.",
3
+ "version": "3.3.3",
4
+ "description": "🚀 Complete Bitcoin SV development framework with Legal Token Protocol (LTP), Global Digital Attestation Framework (GDAF), Shamir Secret Sharing, and 12 flexible loading options. Includes primitives-only architecture for maximum integration flexibility, SmartContract framework, covenant builder, and comprehensive Bitcoin SV API. Perfect for legal tokens, DeFi, smart contracts, and secure Bitcoin applications.",
5
5
  "author": "SmartLedger Technology <hello@smartledger.technology> (https://smartledger.technology)",
6
6
  "homepage": "https://github.com/codenlighten/smartledger-bsv#readme",
7
7
  "bugs": {
@@ -10,7 +10,7 @@
10
10
  "main": "index.js",
11
11
  "scripts": {
12
12
  "lint": "standard",
13
- "test": "standard && mocha",
13
+ "test": "mocha",
14
14
  "test:ltp": "node complete_ltp_demo.js",
15
15
  "test:ltp-primitives": "node simple_demo.js",
16
16
  "test:architecture": "node architecture_demo.js",
@@ -27,6 +27,7 @@
27
27
  "build-mnemonic": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack mnemonic/index.js --config build/webpack.subproject.config.js --output-library bsvMnemonic -o bsv-mnemonic.min.js",
28
28
  "build-shamir": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack shamir-entry.js --config build/webpack.subproject.config.js --output-library bsvShamir -o bsv-shamir.min.js",
29
29
  "build-ltp": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack ltp-entry.js --config build/webpack.ltp.config.js",
30
+ "build-gdaf": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack gdaf-entry.js --config build/webpack.gdaf.config.js",
30
31
  "build-smartcontract": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack smartcontract-entry.js --config build/webpack.smartcontract.config.js",
31
32
  "build-covenant": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack covenant-entry.js --config build/webpack.covenant.config.js",
32
33
  "build-script-helper": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack script-helper-entry.js --config build/webpack.script-helper.config.js",
@@ -34,7 +35,8 @@
34
35
  "build-bundle": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack bundle-entry.js --config build/webpack.bundle.config.js",
35
36
  "build": "npm run build-bsv && npm run build-ecies && npm run build-message && npm run build-mnemonic && npm run build-shamir && npm run build-smartcontract",
36
37
  "build-specialized": "npm run build-covenant && npm run build-script-helper && npm run build-security",
37
- "build-all": "npm run build && npm run build-bundle && npm run build-specialized",
38
+ "build-advanced": "npm run build-ltp && npm run build-gdaf",
39
+ "build-all": "npm run build && npm run build-bundle && npm run build-specialized && npm run build-advanced",
38
40
  "test:browser": "echo 'Open tests/standalone-modules-test.html in browser for comprehensive testing'",
39
41
  "test:bundle": "echo 'Open tests/bundle-completeness-test.html in browser to verify bundle completeness'",
40
42
  "demo": "npm run test:covenants",
@@ -1,49 +1 @@
1
- /**
2
- * SmartLedger BSV Custom Script Helper - Standalone Module
3
- *
4
- * Simplified API for custom script development and signing
5
- * Requires main BSV library to be loaded first.
6
- *
7
- * Usage:
8
- * <script src="bsv.min.js"></script>
9
- * <script src="bsv-script-helper.min.js"></script>
10
- * <script>
11
- * const sig = bsvScriptHelper.createSignature(tx, key, 0, script, sats);
12
- * </script>
13
- */
14
-
15
- 'use strict'
16
-
17
- // Verify BSV library is available
18
- if (typeof bsv === 'undefined') {
19
- throw new Error('CustomScriptHelper requires BSV library. Load bsv.min.js first.');
20
- }
21
-
22
- // Load CustomScriptHelper
23
- const CustomScriptHelper = require('./lib/custom-script-helper.js');
24
-
25
- // Browser compatibility
26
- if (typeof window !== 'undefined') {
27
- window.bsvScriptHelper = {
28
- CustomScriptHelper: CustomScriptHelper,
29
- createSignature: CustomScriptHelper.createSignature,
30
- verifySignature: CustomScriptHelper.verifySignature,
31
- createMultisigSignature: CustomScriptHelper.createMultisigSignature,
32
- version: bsv.version || 'unknown'
33
- };
34
-
35
- // Also attach to main bsv object if available
36
- if (typeof bsv !== 'undefined') {
37
- bsv.CustomScriptHelper = CustomScriptHelper;
38
- }
39
-
40
- console.log('CustomScriptHelper standalone module loaded');
41
- }
42
-
43
- module.exports = {
44
- CustomScriptHelper: CustomScriptHelper,
45
- createSignature: CustomScriptHelper.createSignature,
46
- verifySignature: CustomScriptHelper.verifySignature,
47
- createMultisigSignature: CustomScriptHelper.createMultisigSignature,
48
- version: bsv.version || 'unknown'
49
- };
1
+ module.exports = require('./lib/custom-script-helper');
package/security-entry.js CHANGED
@@ -1,70 +1 @@
1
- /**
2
- * SmartLedger BSV Security Module - Standalone Module
3
- *
4
- * SmartLedger security enhancements and elliptic curve fixes
5
- * Can be used standalone or with main BSV library.
6
- *
7
- * Usage:
8
- * <script src="bsv-security.min.js"></script>
9
- * <script>
10
- * const verified = bsvSecurity.SmartVerify.verify(sig, hash, pubkey);
11
- * </script>
12
- */
13
-
14
- 'use strict'
15
-
16
- // Load security modules
17
- const SmartVerify = require('./lib/crypto/smartledger_verify');
18
- const EllipticFixed = require('./lib/crypto/elliptic-fixed');
19
-
20
- // Browser compatibility
21
- if (typeof window !== 'undefined') {
22
- window.bsvSecurity = {
23
- SmartVerify: SmartVerify,
24
- EllipticFixed: EllipticFixed,
25
- SmartLedger: {
26
- version: 'v3.2.1',
27
- hardenedBy: 'SmartLedger',
28
- baseVersion: 'v1.5.6',
29
- securityFeatures: [
30
- 'canonical-signatures',
31
- 'malleability-protection',
32
- 'enhanced-validation',
33
- 'elliptic-patches'
34
- ],
35
- SmartVerify: SmartVerify,
36
- EllipticFixed: EllipticFixed
37
- },
38
- version: 'v3.2.1'
39
- };
40
-
41
- // Also attach to main bsv object if available
42
- if (typeof bsv !== 'undefined') {
43
- bsv.SmartVerify = SmartVerify;
44
- bsv.EllipticFixed = EllipticFixed;
45
- if (!bsv.SmartLedger) {
46
- bsv.SmartLedger = window.bsvSecurity.SmartLedger;
47
- }
48
- }
49
-
50
- console.log('SmartLedger Security standalone module loaded');
51
- }
52
-
53
- module.exports = {
54
- SmartVerify: SmartVerify,
55
- EllipticFixed: EllipticFixed,
56
- SmartLedger: {
57
- version: 'v3.2.1',
58
- hardenedBy: 'SmartLedger',
59
- baseVersion: 'v1.5.6',
60
- securityFeatures: [
61
- 'canonical-signatures',
62
- 'malleability-protection',
63
- 'enhanced-validation',
64
- 'elliptic-patches'
65
- ],
66
- SmartVerify: SmartVerify,
67
- EllipticFixed: EllipticFixed
68
- },
69
- version: 'v3.2.1'
70
- };
1
+ module.exports = require('./lib/smartminer');
package/shamir-entry.js CHANGED
@@ -1,173 +1 @@
1
- 'use strict'
2
-
3
- /**
4
- * BSV Shamir Secret Sharing - Standalone Module
5
- * Secure secret distribution using Shamir's Secret Sharing algorithm
6
- *
7
- * Usage:
8
- * // Split a secret into shares
9
- * var shares = bsvShamir.split('my secret', 3, 5) // 3-of-5 threshold
10
- *
11
- * // Reconstruct secret from shares
12
- * var secret = bsvShamir.combine(shares.slice(0, 3))
13
- *
14
- * Features:
15
- * - Cryptographically secure threshold secret sharing
16
- * - Support for any threshold (k) and total shares (n) where k <= n
17
- * - Handles arbitrary secret sizes through chunking
18
- * - Share verification and integrity checking
19
- * - Compatible with BSV cryptographic ecosystem
20
- */
21
-
22
- // Initialize dependencies for browser compatibility
23
- var deps = {}
24
- try {
25
- deps.bnjs = require('bn.js')
26
- deps.Buffer = (typeof Buffer !== 'undefined') ? Buffer : null
27
- } catch (e) {
28
- // Browser environment - dependencies should be available globally
29
- if (typeof window !== 'undefined') {
30
- deps.bnjs = window.BN || (window.bsv && window.bsv.deps && window.bsv.deps.bnjs)
31
- deps.Buffer = window.Buffer || (window.bsv && window.bsv.deps && window.bsv.deps.Buffer)
32
- }
33
- }
34
-
35
- // Ensure we have required dependencies
36
- if (!deps.bnjs) {
37
- throw new Error('BN.js dependency not found. Please include bn.js or bsv.min.js')
38
- }
39
-
40
- if (!deps.Buffer) {
41
- // Provide minimal Buffer polyfill for basic operations
42
- deps.Buffer = {
43
- isBuffer: function(obj) { return obj && obj.constructor && obj.constructor.name === 'Buffer' },
44
- from: function(data, encoding) {
45
- if (typeof data === 'string') {
46
- if (encoding === 'hex') {
47
- return new Uint8Array(data.match(/.{2}/g).map(byte => parseInt(byte, 16)))
48
- }
49
- return new Uint8Array(Array.from(data).map(c => c.charCodeAt(0)))
50
- }
51
- return new Uint8Array(data)
52
- },
53
- concat: function(arrays) {
54
- var totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0)
55
- var result = new Uint8Array(totalLength)
56
- var offset = 0
57
- for (var i = 0; i < arrays.length; i++) {
58
- result.set(arrays[i], offset)
59
- offset += arrays[i].length
60
- }
61
- return result
62
- }
63
- }
64
- }
65
-
66
- // Import the core Shamir implementation
67
- var Shamir = require('./lib/crypto/shamir')
68
-
69
- // Create standalone module interface
70
- var bsvShamir = {
71
- /**
72
- * Split a secret into threshold shares
73
- * @param {String|Buffer} secret - Secret to split
74
- * @param {Number} threshold - Minimum shares needed to reconstruct
75
- * @param {Number} shares - Total shares to generate
76
- * @returns {Array} Array of share objects
77
- */
78
- split: function(secret, threshold, shares) {
79
- return Shamir.split(secret, threshold, shares)
80
- },
81
-
82
- /**
83
- * Combine shares to reconstruct secret
84
- * @param {Array} shares - Array of share objects
85
- * @returns {Buffer} Reconstructed secret
86
- */
87
- combine: function(shares) {
88
- return Shamir.combine(shares)
89
- },
90
-
91
- /**
92
- * Verify if a share is valid
93
- * @param {Object} share - Share to verify
94
- * @returns {Boolean} True if valid
95
- */
96
- verifyShare: function(share) {
97
- return Shamir.verifyShare(share)
98
- },
99
-
100
- /**
101
- * Generate test vectors for validation
102
- * @returns {Object} Test data with secret, shares, and reconstruction
103
- */
104
- generateTestVectors: function() {
105
- return Shamir.generateTestVectors()
106
- },
107
-
108
- /**
109
- * Create a simple demo showing basic usage
110
- * @returns {Object} Demo results
111
- */
112
- demo: function() {
113
- console.log('=== BSV Shamir Secret Sharing Demo ===')
114
-
115
- var originalSecret = 'Bitcoin SV is the original Bitcoin!'
116
- var threshold = 3
117
- var totalShares = 5
118
-
119
- console.log('Original secret:', originalSecret)
120
- console.log('Creating', totalShares, 'shares with threshold of', threshold)
121
-
122
- // Split the secret
123
- var shares = bsvShamir.split(originalSecret, threshold, totalShares)
124
- console.log('Generated', shares.length, 'shares')
125
-
126
- // Show first share structure (truncated for display)
127
- var displayShare = JSON.parse(JSON.stringify(shares[0]))
128
- if (displayShare.chunks && displayShare.chunks.length > 0) {
129
- displayShare.chunks = displayShare.chunks.slice(0, 1) // Show only first chunk
130
- displayShare.chunks[0].y = displayShare.chunks[0].y.substring(0, 20) + '...'
131
- }
132
- console.log('Sample share structure:', displayShare)
133
-
134
- // Reconstruct with minimum shares
135
- var minShares = shares.slice(0, threshold)
136
- var reconstructed = bsvShamir.combine(minShares)
137
- var reconstructedSecret = reconstructed.toString('utf8')
138
-
139
- console.log('Reconstructed secret:', reconstructedSecret)
140
- console.log('Reconstruction successful:', originalSecret === reconstructedSecret)
141
-
142
- return {
143
- original: originalSecret,
144
- threshold: threshold,
145
- totalShares: totalShares,
146
- shares: shares,
147
- reconstructed: reconstructedSecret,
148
- success: originalSecret === reconstructedSecret
149
- }
150
- },
151
-
152
- // Expose version and metadata
153
- version: '3.2.2',
154
- algorithm: 'Shamir Secret Sharing',
155
- description: 'Threshold cryptography for secure secret distribution'
156
- }
157
-
158
- // Browser compatibility
159
- if (typeof window !== 'undefined') {
160
- window.bsvShamir = bsvShamir
161
- }
162
-
163
- // Node.js compatibility
164
- if (typeof module !== 'undefined' && module.exports) {
165
- module.exports = bsvShamir
166
- }
167
-
168
- // AMD compatibility
169
- if (typeof define === 'function' && define.amd) {
170
- define(function() {
171
- return bsvShamir
172
- })
173
- }
1
+ module.exports = require('./lib/crypto/shamir');