@smartledger/bsv 5.5.3 → 6.0.1

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 (60) hide show
  1. package/CHANGELOG.md +142 -0
  2. package/README.md +38 -38
  3. package/bin/cli.js +35 -5
  4. package/bsv-covenant.min.js +6 -6
  5. package/bsv-gdaf.min.js +2 -2
  6. package/bsv-ltp.min.js +2 -2
  7. package/bsv-shamir.min.js +1 -1
  8. package/bsv-smartcontract.min.js +6 -6
  9. package/bsv-statuslist.min.js +5 -5
  10. package/bsv-vcjwt.min.js +1 -1
  11. package/bsv.bundle.js +2 -2
  12. package/bsv.d.ts +289 -10
  13. package/bsv.min.js +2 -2
  14. package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
  15. package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
  16. package/docs/getting-started/INSTALLATION.md +23 -23
  17. package/docs/getting-started/QUICK_START.md +7 -7
  18. package/docs/migration/FROM_BSV_1_5_6.md +5 -5
  19. package/index.js +4 -0
  20. package/lib/crypto/ecdsa.js +13 -0
  21. package/lib/crypto/shamir.js +16 -4
  22. package/lib/gdaf/did-resolver.js +3 -1
  23. package/lib/gdaf/smartledger-anchor.js +154 -12
  24. package/lib/ltp/anchor.js +16 -3
  25. package/lib/ltp/obligation.js +56 -8
  26. package/lib/ltp/proof.js +4 -2
  27. package/lib/ltp/right.js +86 -11
  28. package/lib/ordinals/README.md +170 -0
  29. package/lib/ordinals/bsv20.js +185 -0
  30. package/lib/ordinals/index.js +49 -0
  31. package/lib/ordinals/inscription.js +159 -0
  32. package/lib/ordinals/ordlock.js +560 -0
  33. package/lib/smart_contract/builder.js +27 -3
  34. package/lib/smart_contract/covenant.js +37 -10
  35. package/lib/smart_contract/covenant_builder.js +7 -5
  36. package/lib/smart_contract/index.js +28 -15
  37. package/lib/smart_contract/preimage.js +7 -7
  38. package/lib/smart_contract/pushtx.js +47 -7
  39. package/lib/smart_contract/token.js +69 -1
  40. package/lib/spv/headerchain.js +77 -0
  41. package/lib/spv/index.js +16 -0
  42. package/lib/spv/merkleproof.js +108 -0
  43. package/lib/statuslist/index.js +65 -24
  44. package/lib/vcjwt/index.js +6 -0
  45. package/package.json +1 -1
  46. package/test/credentials-test.js +22 -19
  47. package/test/crypto/shamir.js +9 -1
  48. package/test/crypto/shamir_rngcap.js +29 -0
  49. package/test/gdaf/anchor_spv.js +163 -0
  50. package/test/ltp/verify_failclosed.js +134 -0
  51. package/test/ordinals/bsv20.js +126 -0
  52. package/test/ordinals/inscription.js +71 -0
  53. package/test/ordinals/ordlock.js +552 -0
  54. package/test/smart_contract/extract_field.js +61 -0
  55. package/test/smart_contract/nonenforcing_guard.js +44 -0
  56. package/test/smart_contract/ordinal_transfer.js +83 -0
  57. package/test/smart_contract/sighash_marketplace.js +110 -0
  58. package/test/spv/headerchain.js +86 -0
  59. package/test/spv/merkleproof.js +133 -0
  60. package/test/statuslist/failclosed.js +78 -0
@@ -55,19 +55,19 @@ Three advanced modules totaling **~2.7MB** of functionality:
55
55
  - **Purpose**: Threshold cryptography for secure secret distribution
56
56
  - **Use Cases**: Backup keys, multi-party security, key recovery
57
57
  - **Features**: Split secrets into N shares, require M to reconstruct
58
- - **CDN**: `unpkg.com/@smartledger/bsv@5.5.3/bsv-shamir.min.js`
58
+ - **CDN**: `unpkg.com/@smartledger/bsv@6.0.1/bsv-shamir.min.js`
59
59
 
60
60
  #### **🌐 Global Digital Attestation Framework - GDAF (1184KB)**
61
61
  - **Purpose**: W3C Verifiable Credentials and decentralized identity
62
62
  - **Use Cases**: Identity verification, attestations, zero-knowledge proofs
63
63
  - **Features**: DID creation, credential issuance, selective disclosure
64
- - **CDN**: `unpkg.com/@smartledger/bsv@5.5.3/bsv-gdaf.min.js`
64
+ - **CDN**: `unpkg.com/@smartledger/bsv@6.0.1/bsv-gdaf.min.js`
65
65
 
66
66
  #### **⚖️ Legal Token Protocol - LTP (1184KB)**
67
67
  - **Purpose**: Legal compliance framework for tokenized assets
68
68
  - **Use Cases**: Property rights, obligations, compliant tokenization
69
69
  - **Features**: Legal primitives, compliance checking, attestation anchoring
70
- - **CDN**: `unpkg.com/@smartledger/bsv@5.5.3/bsv-ltp.min.js`
70
+ - **CDN**: `unpkg.com/@smartledger/bsv@6.0.1/bsv-ltp.min.js`
71
71
 
72
72
  ### **2. Incorrect File Sizes in Documentation**
73
73
 
@@ -81,18 +81,18 @@ Three advanced modules totaling **~2.7MB** of functionality:
81
81
 
82
82
  | Module | Size | Use Case | CDN Link |
83
83
  |--------|------|----------|----------|
84
- | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@5.5.3/bsv.min.js` |
85
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@5.5.3/bsv.bundle.js` |
86
- | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@5.5.3/bsv-smartcontract.min.js` |
87
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@5.5.3/bsv-covenant.min.js` |
88
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@5.5.3/bsv-script-helper.min.js` |
89
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@5.5.3/bsv-security.min.js` |
90
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@5.5.3/bsv-ecies.min.js` |
91
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@5.5.3/bsv-message.min.js` |
92
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@5.5.3/bsv-mnemonic.min.js` |
93
- | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@5.5.3/bsv-shamir.min.js` |
94
- | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@5.5.3/bsv-gdaf.min.js` |
95
- | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@5.5.3/bsv-ltp.min.js` |
84
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@6.0.1/bsv.min.js` |
85
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@6.0.1/bsv.bundle.js` |
86
+ | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@6.0.1/bsv-smartcontract.min.js` |
87
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@6.0.1/bsv-covenant.min.js` |
88
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@6.0.1/bsv-script-helper.min.js` |
89
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@6.0.1/bsv-security.min.js` |
90
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@6.0.1/bsv-ecies.min.js` |
91
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@6.0.1/bsv-message.min.js` |
92
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@6.0.1/bsv-mnemonic.min.js` |
93
+ | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@6.0.1/bsv-shamir.min.js` |
94
+ | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@6.0.1/bsv-gdaf.min.js` |
95
+ | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@6.0.1/bsv-ltp.min.js` |
96
96
 
97
97
  ## 🎯 **Updated Usage Examples**
98
98
 
@@ -100,22 +100,22 @@ Three advanced modules totaling **~2.7MB** of functionality:
100
100
 
101
101
  #### **1. Basic Development (~963KB)**
102
102
  ```html
103
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv.min.js"></script>
104
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-script-helper.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv.min.js"></script>
104
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-script-helper.min.js"></script>
105
105
  ```
106
106
 
107
107
  #### **2. Smart Contract Development (~2.7MB — each bundle re-embeds core BSV)**
108
108
  ```html
109
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv.min.js"></script>
110
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-covenant.min.js"></script>
111
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-smartcontract.min.js"></script>
109
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv.min.js"></script>
110
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-covenant.min.js"></script>
111
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-smartcontract.min.js"></script>
112
112
  ```
113
113
 
114
114
  #### **3. 🆕 Legal & Compliance Development (~3.2MB — each bundle re-embeds core BSV)**
115
115
  ```html
116
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv.min.js"></script>
117
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-ltp.min.js"></script>
118
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-gdaf.min.js"></script>
116
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv.min.js"></script>
117
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-ltp.min.js"></script>
118
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-gdaf.min.js"></script>
119
119
  <script>
120
120
  // Legal Token Protocol
121
121
  const legalToken = bsv.createLegalToken({
@@ -132,9 +132,9 @@ Three advanced modules totaling **~2.7MB** of functionality:
132
132
 
133
133
  #### **4. 🆕 Security & Cryptography (~1.4MB)**
134
134
  ```html
135
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv.min.js"></script>
136
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-security.min.js"></script>
137
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-shamir.min.js"></script>
135
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-security.min.js"></script>
137
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-shamir.min.js"></script>
138
138
  <script>
139
139
  // Shamir Secret Sharing
140
140
  const shares = bsv.splitSecret('my_secret_key', 5, 3); // 5 shares, 3 needed
@@ -146,7 +146,7 @@ Three advanced modules totaling **~2.7MB** of functionality:
146
146
 
147
147
  #### **5. Everything Bundle (937KB)**
148
148
  ```html
149
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv.bundle.js"></script>
149
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv.bundle.js"></script>
150
150
  <script>
151
151
  // Everything available immediately
152
152
  const shares = bsv.splitSecret('secret', 5, 3);
@@ -722,7 +722,7 @@ interface UTXO {
722
722
  <html>
723
723
  <head>
724
724
  <title>UTXO Manager Demo</title>
725
- <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@5.5.3/bsv.min.js"></script>
725
+ <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@6.0.1/bsv.min.js"></script>
726
726
  </head>
727
727
  <body>
728
728
  <script>
@@ -48,7 +48,7 @@ const tx: Transaction = new Transaction();
48
48
  #### **Core Library Only (937KB)**
49
49
  For basic Bitcoin SV operations:
50
50
  ```html
51
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv.min.js"></script>
51
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv.min.js"></script>
52
52
  <script>
53
53
  const privateKey = new bsv.PrivateKey();
54
54
  const address = privateKey.toAddress();
@@ -58,7 +58,7 @@ For basic Bitcoin SV operations:
58
58
  #### **Complete Bundle (937KB)**
59
59
  Everything in one file:
60
60
  ```html
61
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv.bundle.js"></script>
61
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv.bundle.js"></script>
62
62
  <script>
63
63
  // All features available immediately
64
64
  const shares = bsv.splitSecret('secret', 5, 3);
@@ -71,9 +71,9 @@ Everything in one file:
71
71
 
72
72
  #### **Smart Contract Development (~2.7MB total — each bundle is self-contained and re-embeds core BSV)**
73
73
  ```html
74
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv.min.js"></script>
75
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-covenant.min.js"></script>
76
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-smartcontract.min.js"></script>
74
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv.min.js"></script>
75
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-covenant.min.js"></script>
76
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-smartcontract.min.js"></script>
77
77
  <script>
78
78
  const covenant = bsv.SmartContract.createCovenantBuilder()
79
79
  .extractField('amount').push(50000).greaterThanOrEqual().build();
@@ -82,9 +82,9 @@ Everything in one file:
82
82
 
83
83
  #### **Legal & Identity Development (~3.2MB total — each bundle is self-contained and re-embeds core BSV)**
84
84
  ```html
85
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv.min.js"></script>
86
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-ltp.min.js"></script>
87
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-gdaf.min.js"></script>
85
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv.min.js"></script>
86
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-ltp.min.js"></script>
87
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-gdaf.min.js"></script>
88
88
  <script>
89
89
  // Legal Token Protocol
90
90
  const propertyToken = bsv.createPropertyToken({
@@ -98,9 +98,9 @@ Everything in one file:
98
98
 
99
99
  #### **Security & Cryptography (~1.4MB total — each bundle is self-contained and re-embeds core BSV)**
100
100
  ```html
101
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv.min.js"></script>
102
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-security.min.js"></script>
103
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-shamir.min.js"></script>
101
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv.min.js"></script>
102
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-security.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-shamir.min.js"></script>
104
104
  <script>
105
105
  // Threshold Cryptography
106
106
  const shares = bsv.splitSecret('my_secret_key', 5, 3);
@@ -114,18 +114,18 @@ Everything in one file:
114
114
 
115
115
  | Module | Size | Purpose | CDN Link |
116
116
  |--------|------|---------|----------|
117
- | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@5.5.3/bsv.min.js` |
118
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@5.5.3/bsv.bundle.js` |
119
- | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@5.5.3/bsv-smartcontract.min.js` |
120
- | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@5.5.3/bsv-ltp.min.js` |
121
- | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@5.5.3/bsv-gdaf.min.js` |
122
- | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@5.5.3/bsv-shamir.min.js` |
123
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@5.5.3/bsv-security.min.js` |
124
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@5.5.3/bsv-mnemonic.min.js` |
125
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@5.5.3/bsv-ecies.min.js` |
126
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@5.5.3/bsv-covenant.min.js` |
127
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@5.5.3/bsv-script-helper.min.js` |
128
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@5.5.3/bsv-message.min.js` |
117
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@6.0.1/bsv.min.js` |
118
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@6.0.1/bsv.bundle.js` |
119
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@6.0.1/bsv-smartcontract.min.js` |
120
+ | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@6.0.1/bsv-ltp.min.js` |
121
+ | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@6.0.1/bsv-gdaf.min.js` |
122
+ | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@6.0.1/bsv-shamir.min.js` |
123
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@6.0.1/bsv-security.min.js` |
124
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@6.0.1/bsv-mnemonic.min.js` |
125
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@6.0.1/bsv-ecies.min.js` |
126
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@6.0.1/bsv-covenant.min.js` |
127
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@6.0.1/bsv-script-helper.min.js` |
128
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@6.0.1/bsv-message.min.js` |
129
129
 
130
130
  ## ⚙️ **Development Environment Setup**
131
131
 
@@ -14,10 +14,10 @@ npm install @smartledger/bsv
14
14
  ### Browser CDN (Instant)
15
15
  ```html
16
16
  <!-- Core library (937KB) -->
17
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv.min.js"></script>
17
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv.min.js"></script>
18
18
 
19
19
  <!-- Everything included (937KB) -->
20
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv.bundle.js"></script>
20
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv.bundle.js"></script>
21
21
  ```
22
22
 
23
23
  ## 💰 **Your First Transaction (60 seconds)**
@@ -127,19 +127,19 @@ SmartLedger-BSV offers 12 different loading options - use only what you need:
127
127
 
128
128
  ```html
129
129
  <!-- Core BSV only (937KB) -->
130
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv.min.js"></script>
130
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv.min.js"></script>
131
131
 
132
132
  <!-- Smart contracts (937KB) -->
133
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-smartcontract.min.js"></script>
133
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-smartcontract.min.js"></script>
134
134
 
135
135
  <!-- Legal tokens (1.16MB) -->
136
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-ltp.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-ltp.min.js"></script>
137
137
 
138
138
  <!-- Digital identity (1.16MB) -->
139
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-gdaf.min.js"></script>
139
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-gdaf.min.js"></script>
140
140
 
141
141
  <!-- Everything (937KB) -->
142
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv.bundle.js"></script>
142
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv.bundle.js"></script>
143
143
  ```
144
144
 
145
145
  ## ⚡ **Key Advantages**
@@ -159,17 +159,17 @@ const recovered = bsv.reconstructSecret([shares[0], shares[2], shares[4]]);
159
159
  ### **New Modular Options**
160
160
  ```html
161
161
  <!-- Core compatibility (same size as bsv@1.5.6) -->
162
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv.min.js"></script>
162
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv.min.js"></script>
163
163
 
164
164
  <!-- Add smart contracts when ready -->
165
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-smartcontract.min.js"></script>
165
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-smartcontract.min.js"></script>
166
166
 
167
167
  <!-- Add advanced features as needed -->
168
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-ltp.min.js"></script>
169
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv-gdaf.min.js"></script>
168
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-ltp.min.js"></script>
169
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv-gdaf.min.js"></script>
170
170
 
171
171
  <!-- Everything in one file -->
172
- <script src="https://unpkg.com/@smartledger/bsv@5.5.3/bsv.bundle.js"></script>
172
+ <script src="https://unpkg.com/@smartledger/bsv@6.0.1/bsv.bundle.js"></script>
173
173
  ```
174
174
 
175
175
  ## 🔍 **Testing Your Migration**
package/index.js CHANGED
@@ -94,6 +94,7 @@ bsv.Address = require('./lib/address')
94
94
  bsv.Block = require('./lib/block')
95
95
  bsv.MerkleBlock = require('./lib/block/merkleblock')
96
96
  bsv.BlockHeader = require('./lib/block/blockheader')
97
+ bsv.SPV = require('./lib/spv')
97
98
  bsv.HDPrivateKey = require('./lib/hdprivatekey.js')
98
99
  bsv.HDPublicKey = require('./lib/hdpublickey.js')
99
100
  bsv.Networks = require('./lib/networks')
@@ -182,6 +183,9 @@ if (typeof window === 'undefined' && typeof require === 'function') {
182
183
  }
183
184
  }
184
185
 
186
+ // Ordinals (1Sat Ordinals inscriptions + marketplace)
187
+ bsv.Ordinals = require('./lib/ordinals')
188
+
185
189
  // Global Digital Attestation Framework (GDAF)
186
190
  bsv.GDAF = require('./lib/gdaf')
187
191
 
@@ -287,6 +287,10 @@ ECDSA.prototype.toString = function () {
287
287
  return JSON.stringify(obj)
288
288
  }
289
289
 
290
+ // NOTE: verify() returns the ECDSA *instance* (for chaining, e.g.
291
+ // `.sign().verify()`), NOT a boolean. The pass/fail result is on `.verified`.
292
+ // Treating the return value as a boolean is ALWAYS truthy and silently accepts
293
+ // forged signatures — use `.verify().verified` or the `verifyBool()` helper.
290
294
  ECDSA.prototype.verify = function () {
291
295
  if (!this.sigError()) {
292
296
  this.verified = true
@@ -296,6 +300,15 @@ ECDSA.prototype.verify = function () {
296
300
  return this
297
301
  }
298
302
 
303
+ /**
304
+ * Boolean verification — the safe form. Returns `true` only when the signature
305
+ * is valid, avoiding the truthy-instance trap of verify().
306
+ * @returns {Boolean}
307
+ */
308
+ ECDSA.prototype.verifyBool = function () {
309
+ return this.verify().verified === true
310
+ }
311
+
299
312
  ECDSA.sign = function (hashbuf, privkey, endian) {
300
313
  return ECDSA().set({
301
314
  hashbuf: hashbuf,
@@ -21,7 +21,13 @@ function secretsLib () {
21
21
  // null. Returning null would otherwise either crash secrets.js validation
22
22
  // (`rng(bits).length` → TypeError) or silently corrupt a share coefficient
23
23
  // (`parseInt(null, 2)` → NaN). With a CSPRNG a re-draw is astronomically rare.
24
- for (;;) {
24
+ // Bounded rejection sampling. Each all-zero draw has probability 2^-bits
25
+ // (~1/256 for the default 8-bit field), so a redraw is rare and terminates in
26
+ // ~1 iteration with a real CSPRNG. The cap converts a broken/stubbed RNG that
27
+ // returns all-zero forever (e.g. a bundle that mocks crypto to Buffer.alloc)
28
+ // from an unrecoverable hang into a clear, fail-fast error.
29
+ var MAX_REDRAWS = 64
30
+ for (var attempt = 0; attempt < MAX_REDRAWS; attempt++) {
25
31
  var bytes = Random.getRandomBuffer(Math.ceil(bits / 8))
26
32
  var str = ''
27
33
  for (var i = 0; i < bytes.length; i++) {
@@ -30,6 +36,8 @@ function secretsLib () {
30
36
  str = str.slice(0, bits)
31
37
  if (/1/.test(str)) return str
32
38
  }
39
+ throw new Error('shamir: CSPRNG returned all-zero draws ' + MAX_REDRAWS +
40
+ ' times in a row — refusing to hang on a degenerate/stubbed random source')
33
41
  })
34
42
  _secrets = s
35
43
  return _secrets
@@ -77,9 +85,13 @@ function Shamir (options) {
77
85
  * @param {Number} threshold - Minimum shares needed to reconstruct (>= 2)
78
86
  * @param {Number} shares - Total shares to generate (>= threshold, <= 255)
79
87
  * @param {Object} [options]
80
- * @param {Boolean} [options.checksum=true] - embed a truncated SHA-256 of the
88
+ * @param {Boolean} [options.checksum=false] - embed a truncated SHA-256 of the
81
89
  * secret in each share so combine() can detect a wrong/tampered share set.
82
- * Set false to avoid disclosing any hash of the secret.
90
+ * OFF BY DEFAULT: the checksum is a hash of the secret present in EVERY share,
91
+ * so a single shareholder (below threshold) can brute-force a low-entropy secret
92
+ * offline by matching it — defeating the threshold. Enable only for high-entropy
93
+ * secrets where tamper-detection outweighs that leak. (splitId already detects
94
+ * mixing shares from different splits without disclosing anything about the secret.)
83
95
  * @returns {Array} Array of v2 share objects
84
96
  */
85
97
  Shamir.split = function (secret, threshold, shares, options) {
@@ -104,7 +116,7 @@ Shamir.split = function (secret, threshold, shares, options) {
104
116
  var rawShares = secretsLib().share(markedHex, shares, threshold)
105
117
 
106
118
  var splitId = Random.getRandomBuffer(8).toString('hex')
107
- var useChecksum = options.checksum !== false
119
+ var useChecksum = options.checksum === true
108
120
  var checksum = useChecksum
109
121
  ? Hash.sha256(secretBuffer).slice(0, 4).toString('hex')
110
122
  : null
@@ -278,7 +278,9 @@ DIDResolver.verifyOwnership = function(did, signature, message) {
278
278
  ecdsa.pubkey = publicKey
279
279
  ecdsa.sig = sig
280
280
 
281
- return ecdsa.verify()
281
+ // ECDSA.prototype.verify() returns the instance (always truthy); the boolean
282
+ // result lives on .verified. Returning the instance would accept ANY signature.
283
+ return ecdsa.verify().verified === true
282
284
  } catch (e) {
283
285
  return false
284
286
  }
@@ -6,6 +6,7 @@ var Script = bsv.Script
6
6
  var PrivateKey = bsv.PrivateKey
7
7
  var Address = bsv.Address
8
8
  var Hash = bsv.crypto.Hash
9
+ var SPV = bsv.SPV
9
10
  var $ = bsv.util.preconditions
10
11
 
11
12
  /**
@@ -384,30 +385,171 @@ SmartLedgerAnchor.parseAnchorData = function(data) {
384
385
  }
385
386
 
386
387
  /**
387
- * Verify anchor proof
388
- * @param {String} txid - Transaction ID
389
- * @param {String} expectedHash - Expected anchored hash
390
- * @returns {Promise<Object>} Verification result
388
+ * Verify an anchor proof against the chain.
389
+ *
390
+ * SECURITY: this MUST NOT fabricate a result. An attestation/legal-token system
391
+ * that reports `verified: true` for an unverified txid silently validates a bogus
392
+ * anchor — the worst possible failure mode. Real verification requires querying a
393
+ * trusted BSV source (SPV proof, full node, or block explorer) for the transaction,
394
+ * confirming it is mined, and checking that one of its OP_RETURN outputs actually
395
+ * commits to `expectedHash`. There is no built-in chain access here, so the caller
396
+ * must inject a `chainProvider`; without one we fail closed by throwing rather than
397
+ * returning a stub.
398
+ *
399
+ * @param {String} txid - Transaction ID to verify.
400
+ * @param {String} expectedHash - Hex hash the anchor is expected to commit to.
401
+ * @param {Object} [options]
402
+ * @param {Function} options.chainProvider - async (txid) => {
403
+ * confirmations:Number, blockHeight:Number, opReturns:String[] (hex payloads) }
404
+ * backed by a trusted BSV source.
405
+ * @param {Number} [options.minConfirmations=1] - required confirmations.
406
+ * @returns {Promise<Object>} Verification result with `verified` reflecting the
407
+ * real inclusion + commitment check.
391
408
  */
392
- SmartLedgerAnchor.verifyAnchor = async function(txid, expectedHash) {
393
- // Note: In production, this would query blockchain APIs
394
- // For now, return a mock verification result
395
-
409
+ SmartLedgerAnchor.verifyAnchor = async function(txid, expectedHash, options) {
410
+ options = options || {}
411
+ if (!txid || !expectedHash) {
412
+ throw new Error('verifyAnchor requires both txid and expectedHash')
413
+ }
414
+
415
+ // Path A — TRUSTLESS SPV: a Merkle proof + block header proves the tx is mined,
416
+ // and the raw tx (bound to txid by its hash) proves it commits to expectedHash.
417
+ // No trust in the data provider: a forged branch cannot hash to a PoW-backed root.
418
+ // Optionally pass a headerChain (tx's block first, then descendants) to also prove
419
+ // confirmations under real work.
420
+ if (options.spvProof && (options.header || options.headerChain) && options.rawTx) {
421
+ return SmartLedgerAnchor._verifyAnchorSPV(txid, expectedHash, options)
422
+ }
423
+
424
+ // Path B — a caller-injected TRUSTED chain provider (full node / SPV service).
425
+ if (typeof options.chainProvider !== 'function') {
426
+ throw new Error(
427
+ 'verifyAnchor needs either a trustless SPV proof — { spvProof: { index, nodes }, ' +
428
+ 'header, rawTx } — or a trusted options.chainProvider(txid) returning ' +
429
+ '{ confirmations, blockHeight, opReturns }. Refusing to fabricate a result.'
430
+ )
431
+ }
432
+
433
+ var minConfirmations = options.minConfirmations != null ? options.minConfirmations : 1
434
+ var chain = await options.chainProvider(txid)
435
+
436
+ var confirmations = (chain && chain.confirmations) || 0
437
+ var opReturns = (chain && chain.opReturns) || []
438
+ var wanted = String(expectedHash).toLowerCase()
439
+ // The anchor is valid only if a real OP_RETURN on this mined tx commits to the
440
+ // expected hash. Match on the hash payload, not on substring of the whole tx.
441
+ var committed = opReturns.some(function(payload) {
442
+ return String(payload).toLowerCase().indexOf(wanted) !== -1
443
+ })
444
+
445
+ var verified = confirmations >= minConfirmations && committed
446
+
396
447
  return {
397
- verified: true,
448
+ verified: verified,
398
449
  txid: txid,
399
450
  hash: expectedHash,
451
+ committed: committed,
452
+ confirmations: confirmations,
453
+ blockHeight: (chain && chain.blockHeight) || null,
400
454
  timestamp: new Date().toISOString(),
401
- confirmations: 6, // Mock confirmations
402
- blockHeight: 800000, // Mock block height
403
455
  proof: {
404
456
  type: 'blockchain_anchor',
405
457
  protocol: 'SMARTLEDGER.ATTEST',
406
- network: 'mainnet'
458
+ network: options.network || 'mainnet'
407
459
  }
408
460
  }
409
461
  }
410
462
 
463
+ /**
464
+ * Trustless SPV anchor verification: prove the anchoring tx is mined AND commits to
465
+ * expectedHash, using only a Merkle proof, a block header, and the raw tx bytes.
466
+ * @private
467
+ */
468
+ SmartLedgerAnchor._verifyAnchorSPV = function(txid, expectedHash, options) {
469
+ var proof = options.spvProof || {}
470
+
471
+ // Optional confirmations proof: a header chain with the tx's block first, then its
472
+ // descendants. The block containing the tx is the chain anchor.
473
+ var chainResult = null
474
+ var inclusionHeader = options.header
475
+ if (options.headerChain) {
476
+ chainResult = SPV.verifyHeaderChain(options.headerChain, {
477
+ requirePow: options.requirePow !== false,
478
+ trustedHash: options.trustedHash
479
+ })
480
+ inclusionHeader = options.headerChain[0]
481
+ }
482
+
483
+ var inclusion = SPV.verifyTxInclusion({
484
+ txid: txid,
485
+ index: proof.index,
486
+ nodes: proof.nodes,
487
+ header: inclusionHeader,
488
+ requirePow: options.requirePow !== false
489
+ })
490
+
491
+ // Bind the raw tx to the proven txid (double-SHA256, reversed to display order),
492
+ // then confirm one of its OP_RETURN outputs commits to expectedHash.
493
+ var raw = Buffer.isBuffer(options.rawTx) ? options.rawTx : Buffer.from(options.rawTx, 'hex')
494
+ var computedTxid = Buffer.from(Hash.sha256sha256(raw)).reverse().toString('hex')
495
+ var txidBound = computedTxid.toLowerCase() === String(txid).toLowerCase()
496
+ var committed = txidBound && SmartLedgerAnchor._rawTxCommitsTo(raw, expectedHash)
497
+
498
+ // Confirmations: number of blocks in the supplied chain (tx's block + descendants).
499
+ var confirmations = chainResult ? chainResult.count : (options.header ? 1 : 0)
500
+ var minConfirmations = options.minConfirmations != null ? options.minConfirmations : 1
501
+ var chainOk = chainResult ? chainResult.valid : true
502
+ var enoughConfirmations = confirmations >= minConfirmations
503
+
504
+ return {
505
+ verified: inclusion.valid && txidBound && committed && chainOk && enoughConfirmations,
506
+ chainVerified: inclusion.valid, // a real, PoW-backed inclusion proof passed
507
+ committed: committed,
508
+ txidBound: txidBound,
509
+ powValid: inclusion.powValid,
510
+ confirmations: confirmations,
511
+ headerChainValid: chainResult ? chainResult.valid : null,
512
+ headerChainReason: chainResult ? (chainResult.reason || null) : null,
513
+ tipHash: chainResult ? chainResult.tipHash : null,
514
+ txid: txid,
515
+ hash: expectedHash,
516
+ blockHash: inclusion.blockHash,
517
+ merkleRoot: inclusion.merkleRoot,
518
+ timestamp: new Date().toISOString(),
519
+ proof: {
520
+ type: chainResult ? 'spv_merkle_inclusion_with_confirmations' : 'spv_merkle_inclusion',
521
+ protocol: 'SMARTLEDGER.ATTEST',
522
+ network: options.network || 'mainnet'
523
+ }
524
+ }
525
+ }
526
+
527
+ /**
528
+ * True if any OP_RETURN output of the raw tx carries a data push equal to (or
529
+ * containing) `expectedHash`.
530
+ * @private
531
+ */
532
+ SmartLedgerAnchor._rawTxCommitsTo = function(rawTx, expectedHash) {
533
+ var wanted = String(expectedHash).toLowerCase()
534
+ var tx
535
+ try {
536
+ tx = new Transaction(rawTx)
537
+ } catch (e) {
538
+ return false
539
+ }
540
+ return tx.outputs.some(function(out) {
541
+ var script = out.script
542
+ if (!script || !script.chunks || !script.chunks.length) return false
543
+ // OP_RETURN (0x6a) or OP_FALSE OP_RETURN (0x00 0x6a) data carrier.
544
+ var isOpReturn = script.chunks[0].opcodenum === 0x6a ||
545
+ (script.chunks[0].opcodenum === 0x00 && script.chunks[1] && script.chunks[1].opcodenum === 0x6a)
546
+ if (!isOpReturn) return false
547
+ return script.chunks.some(function(chunk) {
548
+ return chunk.buf && chunk.buf.toString('hex').toLowerCase().indexOf(wanted) !== -1
549
+ })
550
+ })
551
+ }
552
+
411
553
  /**
412
554
  * Get anchoring cost estimate
413
555
  * @param {Number} numHashes - Number of hashes to anchor
package/lib/ltp/anchor.js CHANGED
@@ -99,11 +99,21 @@ var LTPAnchor = {
99
99
  },
100
100
 
101
101
  /**
102
- * Verify token anchor using external transaction data
102
+ * Verify that CALLER-SUPPLIED transaction data commits to the token.
103
+ *
104
+ * ⚠️ This does NOT prove the token is anchored on-chain. It only checks that the
105
+ * OP_RETURN in the `txData` you pass matches the token's commitment. It performs
106
+ * NO chain query, NO SPV/inclusion proof, and does NOT confirm `txData` actually
107
+ * corresponds to `txid` or to a mined transaction. An attacker can fabricate
108
+ * `txData` with a matching OP_RETURN and get `valid:true`. Treat `valid` as
109
+ * "commitment matches the supplied data" only; obtain `txData` from a TRUSTED
110
+ * source and verify inclusion separately (SPV / trusted node) before relying on it.
111
+ * `chainVerified` is always false here to make that explicit.
112
+ *
103
113
  * @param {Object} token - Token to verify
104
114
  * @param {String} txid - Transaction ID from external anchor
105
- * @param {Object} txData - Transaction data from blockchain
106
- * @returns {Object} Verification result
115
+ * @param {Object} txData - Transaction data (must come from a trusted source)
116
+ * @returns {Object} { valid, chainVerified:false, ... }
107
117
  */
108
118
  verifyTokenAnchor: function(token, txid, txData) {
109
119
  $.checkArgument(token && typeof token === 'object', 'Invalid token')
@@ -128,6 +138,9 @@ var LTPAnchor = {
128
138
 
129
139
  return {
130
140
  valid: commitmentValid,
141
+ // Commitment-match only — NOT an on-chain inclusion proof. The caller must
142
+ // verify txData came from a trusted source / SPV before trusting this.
143
+ chainVerified: false,
131
144
  txid: txid,
132
145
  commitment: expectedCommitment,
133
146
  anchorData: opReturnData,