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/README.md
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
**🚀 Complete Bitcoin SV Development Framework with W3C Verifiable Credentials, DID:web, Legal Compliance, and 16 Flexible Loading Options**
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/@smartledger/bsv)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
[](https://bitcoinsv.com/)
|
|
8
8
|
[](#loading-options)
|
|
9
9
|
[](#verifiable-credentials)
|
|
10
10
|
|
|
11
|
-
The most comprehensive and flexible Bitcoin SV library available. **
|
|
11
|
+
The most comprehensive and flexible Bitcoin SV library available. **In v3.4.x**: Legally-recognizable DID:web + VC-JWT toolkit with ES256/ES256K support, StatusList2021 revocation, and BSV anchoring. Choose from 16 different distribution methods: standalone modules, complete bundle, or mix-and-match approach.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
> **v3.4.1 (bugfix)**: credential bundles now actually ship to npm consumers, `prepublishOnly` builds the full set, and `Transaction.shuffleOutputs()` uses a CSPRNG. See [CHANGELOG](./CHANGELOG.md#341---2026-05-18).
|
|
14
|
+
|
|
15
|
+
## 🆕 **v3.4.x - Legally-Recognizable Credentials**
|
|
14
16
|
|
|
15
17
|
### **Why This Matters**
|
|
16
18
|
- ✅ **W3C Standards**: Full VC-JWT and DID:web compliance for legal recognition
|
|
@@ -23,8 +25,8 @@ The most comprehensive and flexible Bitcoin SV library available. **NEW in v3.4.
|
|
|
23
25
|
### **Quick Start - Issue Your First Verifiable Credential**
|
|
24
26
|
|
|
25
27
|
```bash
|
|
26
|
-
# Install SmartLedger BSV v3.4.
|
|
27
|
-
npm install @smartledger/bsv@3.4.
|
|
28
|
+
# Install SmartLedger BSV v3.4.4
|
|
29
|
+
npm install @smartledger/bsv@3.4.4
|
|
28
30
|
|
|
29
31
|
# Initialize DID:web issuer (generates ES256 keys)
|
|
30
32
|
npx smartledger-bsv didweb init --domain example.com --alg ES256
|
|
@@ -133,42 +135,42 @@ console.log('Status:', status) // 'revoked'
|
|
|
133
135
|
### **Core Modules**
|
|
134
136
|
| Module | Size | Use Case | CDN |
|
|
135
137
|
|--------|------|----------|-----|
|
|
136
|
-
| **bsv.min.js** |
|
|
137
|
-
| **bsv.bundle.js** |
|
|
138
|
+
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js` |
|
|
139
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@3.4.4/bsv.bundle.js` |
|
|
138
140
|
|
|
139
|
-
### **🆕 W3C Verifiable Credentials (v3.4.
|
|
141
|
+
### **🆕 W3C Verifiable Credentials (v3.4.x)**
|
|
140
142
|
| Module | Size | Use Case | CDN |
|
|
141
143
|
|--------|------|----------|-----|
|
|
142
|
-
| **🟢 bsv-didweb.min.js** |
|
|
143
|
-
| **🟢 bsv-vcjwt.min.js** |
|
|
144
|
-
| **🟢 bsv-statuslist.min.js** |
|
|
145
|
-
| **🟢 bsv-anchor.min.js** |
|
|
144
|
+
| **🟢 bsv-didweb.min.js** | 419KB | **DID:web generation** | `unpkg.com/@smartledger/bsv@3.4.4/bsv-didweb.min.js` |
|
|
145
|
+
| **🟢 bsv-vcjwt.min.js** | 419KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@3.4.4/bsv-vcjwt.min.js` |
|
|
146
|
+
| **🟢 bsv-statuslist.min.js** | 487KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@3.4.4/bsv-statuslist.min.js` |
|
|
147
|
+
| **🟢 bsv-anchor.min.js** | 418KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@3.4.4/bsv-anchor.min.js` |
|
|
146
148
|
|
|
147
149
|
### **Smart Contract & Development**
|
|
148
150
|
| Module | Size | Use Case | CDN |
|
|
149
151
|
|--------|------|----------|-----|
|
|
150
|
-
| **bsv-smartcontract.min.js** |
|
|
151
|
-
| **bsv-covenant.min.js** |
|
|
152
|
-
| **bsv-script-helper.min.js** |
|
|
153
|
-
| **bsv-security.min.js** |
|
|
152
|
+
| **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@3.4.4/bsv-smartcontract.min.js` |
|
|
153
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@3.4.4/bsv-covenant.min.js` |
|
|
154
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@3.4.4/bsv-script-helper.min.js` |
|
|
155
|
+
| **bsv-security.min.js** | 26KB | Security enhancements | `unpkg.com/@smartledger/bsv@3.4.4/bsv-security.min.js` |
|
|
154
156
|
|
|
155
157
|
### **Legal & Compliance**
|
|
156
158
|
| Module | Size | Use Case | CDN |
|
|
157
159
|
|--------|------|----------|-----|
|
|
158
|
-
| **bsv-ltp.min.js** |
|
|
159
|
-
| **bsv-gdaf.min.js** |
|
|
160
|
+
| **bsv-ltp.min.js** | 1184KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@3.4.4/bsv-ltp.min.js` |
|
|
161
|
+
| **bsv-gdaf.min.js** | 1184KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@3.4.4/bsv-gdaf.min.js` |
|
|
160
162
|
|
|
161
163
|
### **Advanced Cryptography**
|
|
162
164
|
| Module | Size | Use Case | CDN |
|
|
163
165
|
|--------|------|----------|-----|
|
|
164
|
-
| **bsv-shamir.min.js** |
|
|
166
|
+
| **bsv-shamir.min.js** | 432KB | Threshold Cryptography | `unpkg.com/@smartledger/bsv@3.4.4/bsv-shamir.min.js` |
|
|
165
167
|
|
|
166
168
|
### **Utilities**
|
|
167
169
|
| Module | Size | Use Case | CDN |
|
|
168
170
|
|--------|------|----------|-----|
|
|
169
|
-
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@3.4.
|
|
170
|
-
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@3.4.
|
|
171
|
-
| **bsv-mnemonic.min.js** |
|
|
171
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@3.4.4/bsv-ecies.min.js` |
|
|
172
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@3.4.4/bsv-message.min.js` |
|
|
173
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@3.4.4/bsv-mnemonic.min.js` |
|
|
172
174
|
|
|
173
175
|
## ⚡ **2-Minute Quick Start**
|
|
174
176
|
|
|
@@ -179,10 +181,10 @@ Get started with Bitcoin SV development in under 2 minutes:
|
|
|
179
181
|
npm install @smartledger/bsv
|
|
180
182
|
|
|
181
183
|
# Or include in HTML
|
|
182
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.4.
|
|
184
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
183
185
|
```
|
|
184
186
|
|
|
185
|
-
> **🔧 v3.4.
|
|
187
|
+
> **🔧 v3.4.x:** Legally-recognizable W3C Verifiable Credentials with DID:web + VC-JWT toolkit. ES256/ES256K support, StatusList2021 revocation, and privacy-preserving BSV anchoring. Complete CLI tooling included! v3.4.1 ensures these bundles ship to npm consumers; see CHANGELOG.
|
|
186
188
|
|
|
187
189
|
**Basic Transaction (30 seconds):**
|
|
188
190
|
```javascript
|
|
@@ -247,7 +249,7 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
|
|
|
247
249
|
- 🌐 [Digital Identity Guide](docs/GDAF_DIGITAL_ATTESTATION_GUIDE.md)
|
|
248
250
|
- � [Threshold Cryptography Guide](docs/SHAMIR_SECRET_SHARING_GUIDE.md)
|
|
249
251
|
- �️ [UTXO Manager Guide](docs/UTXO_MANAGER_GUIDE.md)
|
|
250
|
-
- 💡 [Examples Directory](examples
|
|
252
|
+
- 💡 [Examples Directory](https://github.com/codenlighten/smartledger-bsv/tree/main/examples)
|
|
251
253
|
|
|
252
254
|
## 🔧 **API Reference**
|
|
253
255
|
|
|
@@ -265,28 +267,28 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
|
|
|
265
267
|
| **Debug Tools** | `SmartContract.examineStack()` | Analyze script | `SmartContract.examineStack(script)` |
|
|
266
268
|
| | `interpretScript()` | Execute script | `SmartContract.interpretScript(script)` |
|
|
267
269
|
| | `getScriptMetrics()` | Performance data | `SmartContract.getScriptMetrics(script)` |
|
|
268
|
-
| **Security** | `SmartVerify.verify()` |
|
|
269
|
-
| | `EllipticFixed.sign()` |
|
|
270
|
+
| **Security (opt-in)** | `SmartVerify.verify()` | Hardened verify with strict input validation — call explicitly; default `signature.verify()` does NOT route through this | `SmartVerify.verify(sig, hash, pubkey)` |
|
|
271
|
+
| | `EllipticFixed.sign()` | Canonicalized signing wrapper around elliptic | `EllipticFixed.sign(hash, privateKey)` |
|
|
270
272
|
|
|
271
273
|
> 💡 **Tip:** All methods include comprehensive error handling and validation. See [documentation links](#documentation) for detailed guides.
|
|
272
274
|
|
|
273
275
|
## 📚 **Quick Start Examples**
|
|
274
276
|
|
|
275
|
-
### 🔧 **Basic Development** (
|
|
277
|
+
### 🔧 **Basic Development** (~963KB total)
|
|
276
278
|
```html
|
|
277
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
278
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
279
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
280
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-script-helper.min.js"></script>
|
|
279
281
|
<script>
|
|
280
282
|
const privateKey = new bsv.PrivateKey();
|
|
281
283
|
const utxos = new bsv.SmartContract.UTXOGenerator().createRealUTXOs(2, 100000);
|
|
282
284
|
</script>
|
|
283
285
|
```
|
|
284
286
|
|
|
285
|
-
### 🔒 **Smart Contract Development** (
|
|
287
|
+
### 🔒 **Smart Contract Development** (~2.7MB total — each bundle re-embeds core BSV)
|
|
286
288
|
```html
|
|
287
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
288
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
289
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
289
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
290
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-covenant.min.js"></script>
|
|
291
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-smartcontract.min.js"></script>
|
|
290
292
|
<script>
|
|
291
293
|
const covenant = bsv.SmartContract.createCovenantBuilder()
|
|
292
294
|
.extractField('amount').push(50000).greaterThanOrEqual().verify().build();
|
|
@@ -294,11 +296,11 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
|
|
|
294
296
|
</script>
|
|
295
297
|
```
|
|
296
298
|
|
|
297
|
-
### 🆕 **Legal & Identity Development** (
|
|
299
|
+
### 🆕 **Legal & Identity Development** (~3.2MB total — each bundle re-embeds core BSV)
|
|
298
300
|
```html
|
|
299
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
300
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
301
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
301
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
302
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-ltp.min.js"></script>
|
|
303
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-gdaf.min.js"></script>
|
|
302
304
|
<script>
|
|
303
305
|
// Legal Token Protocol
|
|
304
306
|
const propertyToken = bsv.createPropertyToken({
|
|
@@ -310,11 +312,11 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
|
|
|
310
312
|
</script>
|
|
311
313
|
```
|
|
312
314
|
|
|
313
|
-
### 🆕 **Security & Cryptography** (1.
|
|
315
|
+
### 🆕 **Security & Cryptography** (~1.4MB total)
|
|
314
316
|
```html
|
|
315
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
316
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
317
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
317
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
318
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-security.min.js"></script>
|
|
319
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-shamir.min.js"></script>
|
|
318
320
|
<script>
|
|
319
321
|
// Threshold Cryptography
|
|
320
322
|
const shares = bsv.splitSecret('my_secret_key', 5, 3); // 5 shares, 3 needed
|
|
@@ -324,9 +326,9 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
|
|
|
324
326
|
</script>
|
|
325
327
|
```
|
|
326
328
|
|
|
327
|
-
### 🎯 **Everything Bundle** (
|
|
329
|
+
### 🎯 **Everything Bundle** (937KB)
|
|
328
330
|
```html
|
|
329
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
331
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.bundle.js"></script>
|
|
330
332
|
<script>
|
|
331
333
|
// Everything available immediately
|
|
332
334
|
const shares = bsv.splitSecret('secret', 5, 3); // Shamir Secret Sharing
|
|
@@ -346,7 +348,7 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
|
|
|
346
348
|
|
|
347
349
|
### 💼 **Core Library Excellence**
|
|
348
350
|
- ✅ **Complete BSV API**: Full Bitcoin SV blockchain operations → [API Reference](#api-reference)
|
|
349
|
-
- ✅ **
|
|
351
|
+
- ✅ **Opt-in security helpers**: `bsv.SmartVerify` and `bsv.EllipticFixed` add input validation and low-`s` canonicalization on top of standard verification — **not on the default verify path**, see [Security](#-security)
|
|
350
352
|
- ✅ **Browser + Node.js**: Universal compatibility with proper polyfills → [Loading Options](#12-loading-options--choose-your-approach)
|
|
351
353
|
- ✅ **TypeScript Ready**: Complete type definitions included
|
|
352
354
|
- ✅ **Ultra-Low Fees**: 0.01 sats/byte configuration (91% fee reduction)
|
|
@@ -354,14 +356,14 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
|
|
|
354
356
|
### 🛠️ **Advanced Development Tools**
|
|
355
357
|
- 🔧 **JavaScript-to-Script**: High-level covenant development with 121 opcode mapping → [Covenant Guide](docs/ADVANCED_COVENANT_DEVELOPMENT.md)
|
|
356
358
|
- 🔧 **UTXO Generator**: Create authentic test UTXOs for development → [UTXO Guide](docs/UTXO_MANAGER_GUIDE.md)
|
|
357
|
-
- 🔧 **Preimage Parser**: Complete BIP-143 field extraction and manipulation → [Preimage Tools](examples/preimage
|
|
358
|
-
- � **Debug Framework**: Script interpreter, stack examiner, and optimizer → [Debug Examples](tests/smartcontract-test.html)
|
|
359
|
+
- 🔧 **Preimage Parser**: Complete BIP-143 field extraction and manipulation → [Preimage Tools](https://github.com/codenlighten/smartledger-bsv/tree/main/examples/preimage)
|
|
360
|
+
- � **Debug Framework**: Script interpreter, stack examiner, and optimizer → [Debug Examples](https://github.com/codenlighten/smartledger-bsv/blob/main/tests/smartcontract-test.html)
|
|
359
361
|
- � **PUSHTX Integration**: nChain techniques for advanced covenant patterns → [PUSHTX Insights](docs/pushtx-key-insights.md)
|
|
360
362
|
|
|
361
363
|
### 📦 **Flexible Architecture**
|
|
362
|
-
- 📦 **
|
|
363
|
-
- 📦 **Standalone Modules**: Independent legal, identity, and crypto modules → [Standalone Test](tests/standalone-modules-test.html)
|
|
364
|
-
- 📦 **Complete Bundle**: Everything in one file for convenience → [Bundle Demo](tests/bundle-demo.html)
|
|
364
|
+
- 📦 **16 Modular Options**: Load only what you need (26KB to 1184KB) → [Loading Strategy](#loading-strategy-examples)
|
|
365
|
+
- 📦 **Standalone Modules**: Independent legal, identity, and crypto modules → [Standalone Test](https://github.com/codenlighten/smartledger-bsv/blob/main/tests/standalone-modules-test.html)
|
|
366
|
+
- 📦 **Complete Bundle**: Everything in one file for convenience → [Bundle Demo](https://github.com/codenlighten/smartledger-bsv/blob/main/tests/bundle-demo.html)
|
|
365
367
|
- 📦 **CDN Ready**: All modules available via unpkg and jsDelivr
|
|
366
368
|
- 📦 **Webpack Optimized**: Tree-shakeable and build-tool friendly
|
|
367
369
|
|
|
@@ -404,21 +406,21 @@ const contractTx = covenant.createCovenantTransaction({
|
|
|
404
406
|
|
|
405
407
|
### Browser CDN (Choose Your Loading Strategy)
|
|
406
408
|
|
|
407
|
-
#### 1. **Minimal Setup** - Core + Script Helper (
|
|
409
|
+
#### 1. **Minimal Setup** - Core + Script Helper (~963KB)
|
|
408
410
|
```html
|
|
409
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
410
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
411
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
412
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-script-helper.min.js"></script>
|
|
411
413
|
<script>
|
|
412
414
|
const tx = new bsv.Transaction();
|
|
413
415
|
const sig = bsvScriptHelper.createSignature(tx, privateKey, 0, script, satoshis);
|
|
414
416
|
</script>
|
|
415
417
|
```
|
|
416
418
|
|
|
417
|
-
#### 2. **DeFi Development** - Core + Covenants + Debug (
|
|
419
|
+
#### 2. **DeFi Development** - Core + Covenants + Debug (~2.7MB — each bundle re-embeds core BSV)
|
|
418
420
|
```html
|
|
419
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
420
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
421
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
421
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
422
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-covenant.min.js"></script>
|
|
423
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-smartcontract.min.js"></script>
|
|
422
424
|
<script>
|
|
423
425
|
const covenant = new bsvCovenant.CovenantInterface();
|
|
424
426
|
const debugInfo = SmartContract.interpretScript(script);
|
|
@@ -426,19 +428,19 @@ const contractTx = covenant.createCovenantTransaction({
|
|
|
426
428
|
</script>
|
|
427
429
|
```
|
|
428
430
|
|
|
429
|
-
#### 3. **Security First** - Core + Enhanced Security (
|
|
431
|
+
#### 3. **Security First** - Core + Enhanced Security (~963KB)
|
|
430
432
|
```html
|
|
431
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
432
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
433
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.min.js"></script>
|
|
434
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv-security.min.js"></script>
|
|
433
435
|
<script>
|
|
434
436
|
const verified = bsvSecurity.SmartVerify.verify(signature, hash, publicKey);
|
|
435
437
|
const enhanced = bsvSecurity.EllipticFixed.createSignature(privateKey, hash);
|
|
436
438
|
</script>
|
|
437
439
|
```
|
|
438
440
|
|
|
439
|
-
#### 4. **Everything Bundle** - One File Solution (
|
|
441
|
+
#### 4. **Everything Bundle** - One File Solution (937KB)
|
|
440
442
|
```html
|
|
441
|
-
<script src="https://unpkg.com/@smartledger/bsv@3.
|
|
443
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.4.4/bsv.bundle.js"></script>
|
|
442
444
|
<script>
|
|
443
445
|
// Everything available under bsv namespace
|
|
444
446
|
const keys = bsv.SmartLedgerBundle.generateKeys();
|
|
@@ -696,11 +698,37 @@ const timelockScript = helper.createTimelockScript(
|
|
|
696
698
|
|
|
697
699
|
## 🔐 Security
|
|
698
700
|
|
|
699
|
-
###
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
-
|
|
701
|
+
### What's actually in the box
|
|
702
|
+
|
|
703
|
+
| Surface | Status | Notes |
|
|
704
|
+
|---------|--------|-------|
|
|
705
|
+
| `elliptic@6.6.1` (pinned) | upstream-patched | All known CVEs through 6.6.1 are fixed by elliptic itself. SmartLedger does not patch elliptic's source. |
|
|
706
|
+
| Default `transaction.verify()` / `signature.verify()` / `Message().verify()` | uses BSV's own `lib/crypto/ecdsa.js` | This path does **not** import elliptic and is **not** routed through `SmartVerify` or `EllipticFixed`. |
|
|
707
|
+
| `bsv.SmartVerify` (opt-in helper) | available | Hardened standalone verify: rejects `r=0`, `s=0`, `r≥n`, `s≥n`; canonicalizes `s` to low half. Built on BSV's own `BN`/`ECDSA`. You must call it explicitly. |
|
|
708
|
+
| `bsv.EllipticFixed` (opt-in helper) | available | Wraps the elliptic `secp256k1` instance with the same input checks + low-`s` on sign. Only matters if you use elliptic directly. |
|
|
709
|
+
| `signature.validate()` / `isCanonical()` / `toCanonical()` | available | Real methods on `bsv.Signature`. |
|
|
710
|
+
| DER canonicalization on TX signing | available | BSV's signature path produces low-`s` DER by default. |
|
|
711
|
+
| BIP143 preimage utilities | available | `lib/smart_contract/preimage.js` and `examples/preimage/`. |
|
|
712
|
+
|
|
713
|
+
### Using the opt-in helpers
|
|
714
|
+
|
|
715
|
+
```js
|
|
716
|
+
const bsv = require('@smartledger/bsv')
|
|
717
|
+
|
|
718
|
+
// Hardened verify (recommended if you accept signatures from untrusted sources):
|
|
719
|
+
const ok = bsv.SmartVerify.smartVerify(msgHashBuffer, derSigBuffer, publicKey)
|
|
720
|
+
|
|
721
|
+
// Or call BSV's own ECDSA via the standard API (no SmartVerify hardening):
|
|
722
|
+
const okDefault = bsv.crypto.ECDSA.verify(msgHashBuffer, signature, publicKey)
|
|
723
|
+
```
|
|
724
|
+
|
|
725
|
+
### What this library does **not** claim
|
|
726
|
+
|
|
727
|
+
- It does not silently route every `verify()` call through `SmartVerify`. If you want the strict input validation on every verification, call `SmartVerify` explicitly or wrap `bsv.Signature.prototype.verify`.
|
|
728
|
+
- It does not patch the elliptic library's source — the patches in `lib/crypto/elliptic-fixed.js` add input validation on top of an already-upstream-patched `elliptic@6.6.1`.
|
|
729
|
+
- It does not turn `bsv.isHardened = true` into an automatic guarantee. That property indicates the hardening helpers ship; whether they're used is up to your code.
|
|
730
|
+
|
|
731
|
+
A planned 3.5.0 will offer an opt-in flag to route the default verify path through `SmartVerify` so the protection is on by default for new users.
|
|
704
732
|
|
|
705
733
|
## 📝 Changelog
|
|
706
734
|
|
|
@@ -749,18 +777,18 @@ const timelockScript = helper.createTimelockScript(
|
|
|
749
777
|
|
|
750
778
|
### 🔧 **Technical Resources**
|
|
751
779
|
- **[SmartContract Integration](SMARTCONTRACT_INTEGRATION.md)** - Debug tools and analysis
|
|
752
|
-
- **[Examples Directory](examples
|
|
753
|
-
- **[Test Suite](tests
|
|
780
|
+
- **[Examples Directory](https://github.com/codenlighten/smartledger-bsv/tree/main/examples)** - Working code samples
|
|
781
|
+
- **[Test Suite](https://github.com/codenlighten/smartledger-bsv/tree/main/tests)** - Comprehensive testing examples
|
|
754
782
|
- **[Build System](build/)** - Webpack configurations
|
|
755
783
|
|
|
756
784
|
### 🌐 **Loading Strategy Examples**
|
|
757
785
|
|
|
758
786
|
| **Use Case** | **Recommended Load** | **Size** | **Features** |
|
|
759
787
|
|--------------|---------------------|----------|--------------|
|
|
760
|
-
| **Simple Transactions** | `bsv.min.js` |
|
|
761
|
-
| **DeFi Development** | Core + Covenant + Debug |
|
|
762
|
-
| **Enterprise Apps** | `bsv.bundle.js` |
|
|
763
|
-
| **Mobile/Lightweight** | Core + Script Helper |
|
|
788
|
+
| **Simple Transactions** | `bsv.min.js` | 937KB | Core BSV + SmartContract |
|
|
789
|
+
| **DeFi Development** | Core + Covenant + Debug | ~2.7MB | Advanced contracts + tools (bundles re-embed core BSV) |
|
|
790
|
+
| **Enterprise Apps** | `bsv.bundle.js` | 937KB | Everything included |
|
|
791
|
+
| **Mobile/Lightweight** | Core + Script Helper | ~963KB | Essential tools only |
|
|
764
792
|
| **Research/Analysis** | Core + SmartContract | 900KB | Full debug capabilities |
|
|
765
793
|
|
|
766
794
|
### 🔗 **Cross-References**
|
|
@@ -771,19 +799,19 @@ const timelockScript = helper.createTimelockScript(
|
|
|
771
799
|
- [API Reference](#api-reference) → [Method Documentation](docs/)
|
|
772
800
|
|
|
773
801
|
**From Examples → Implementation:**
|
|
774
|
-
- [Covenant Examples](examples/covenants
|
|
775
|
-
- [Script Examples](examples/scripts
|
|
776
|
-
- [Test Files](tests
|
|
802
|
+
- [Covenant Examples](https://github.com/codenlighten/smartledger-bsv/tree/main/examples/covenants) → [Production Guide](docs/ADVANCED_COVENANT_DEVELOPMENT.md#production-guidelines)
|
|
803
|
+
- [Script Examples](https://github.com/codenlighten/smartledger-bsv/tree/main/examples/scripts) → [Custom Script Guide](docs/CUSTOM_SCRIPT_DEVELOPMENT.md)
|
|
804
|
+
- [Test Files](https://github.com/codenlighten/smartledger-bsv/tree/main/tests) → [Integration Examples](https://github.com/codenlighten/smartledger-bsv/tree/main/examples)
|
|
777
805
|
|
|
778
806
|
**From Concepts → Code:**
|
|
779
|
-
- [PUSHTX Theory](docs/pushtx-key-insights.md) → [Covenant Implementation](examples/covenants/advanced_covenant_demo.js)
|
|
807
|
+
- [PUSHTX Theory](docs/pushtx-key-insights.md) → [Covenant Implementation](https://github.com/codenlighten/smartledger-bsv/blob/main/examples/covenants/advanced_covenant_demo.js)
|
|
780
808
|
- [Security Features](#smart-security) → [Implementation](lib/crypto/smartledger_verify.js)
|
|
781
|
-
- [Debug Tools](#debug-tools) → [Usage Examples](tests/smartcontract-test.html)
|
|
809
|
+
- [Debug Tools](#debug-tools) → [Usage Examples](https://github.com/codenlighten/smartledger-bsv/blob/main/tests/smartcontract-test.html)
|
|
782
810
|
|
|
783
811
|
### 🎓 **Learning Path**
|
|
784
812
|
|
|
785
813
|
1. **Start**: [2-Minute Quick Start](#2-minute-quick-start)
|
|
786
|
-
2. **Practice**: [Examples Directory](examples
|
|
814
|
+
2. **Practice**: [Examples Directory](https://github.com/codenlighten/smartledger-bsv/tree/main/examples)
|
|
787
815
|
3. **Build**: [Custom Script Guide](docs/CUSTOM_SCRIPT_DEVELOPMENT.md)
|
|
788
816
|
4. **Advanced**: [Covenant Development](docs/ADVANCED_COVENANT_DEVELOPMENT.md)
|
|
789
817
|
5. **Deploy**: [Production Guidelines](docs/ADVANCED_COVENANT_DEVELOPMENT.md#production-guidelines)
|
|
@@ -811,11 +839,11 @@ const timelockScript = helper.createTimelockScript(
|
|
|
811
839
|
- [🔧 **Integration Guide**](SMARTCONTRACT_INTEGRATION.md) - Smart contract integration
|
|
812
840
|
|
|
813
841
|
### 📋 **Examples & Demos**
|
|
814
|
-
- [� **Interactive Demos**](demos
|
|
815
|
-
- [�📁 **Examples Directory**](examples
|
|
816
|
-
- [🎯 **Basic Examples**](examples/basic
|
|
817
|
-
- [🔒 **Covenant Examples**](examples/covenants
|
|
818
|
-
- [📊 **Advanced Examples**](examples/covenants2
|
|
842
|
+
- [� **Interactive Demos**](https://github.com/codenlighten/smartledger-bsv/tree/main/demos) - **NEW!** HTML & Node.js smart contract demos
|
|
843
|
+
- [�📁 **Examples Directory**](https://github.com/codenlighten/smartledger-bsv/tree/main/examples) - Working code examples
|
|
844
|
+
- [🎯 **Basic Examples**](https://github.com/codenlighten/smartledger-bsv/tree/main/examples/basic) - Simple transactions & addresses
|
|
845
|
+
- [🔒 **Covenant Examples**](https://github.com/codenlighten/smartledger-bsv/tree/main/examples/covenants) - Smart contract patterns
|
|
846
|
+
- [📊 **Advanced Examples**](https://github.com/codenlighten/smartledger-bsv/tree/main/examples/covenants2) - Production patterns
|
|
819
847
|
|
|
820
848
|
**🎮 Try the Interactive Demos:**
|
|
821
849
|
```bash
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
Thank you for helping keep `@smartledger/bsv` and its users safe.
|
|
4
|
+
|
|
5
|
+
## Supported Versions
|
|
6
|
+
|
|
7
|
+
Security fixes are applied to the latest minor release line. Earlier releases
|
|
8
|
+
are not patched; please upgrade.
|
|
9
|
+
|
|
10
|
+
| Version | Supported |
|
|
11
|
+
| ------- | ------------------ |
|
|
12
|
+
| 3.4.x | :white_check_mark: |
|
|
13
|
+
| < 3.4 | :x: |
|
|
14
|
+
|
|
15
|
+
## Reporting a Vulnerability
|
|
16
|
+
|
|
17
|
+
**Please do not report security vulnerabilities through public GitHub issues,
|
|
18
|
+
discussions, or pull requests.**
|
|
19
|
+
|
|
20
|
+
Report privately via either of:
|
|
21
|
+
|
|
22
|
+
- **GitHub Security Advisories** (preferred):
|
|
23
|
+
<https://github.com/codenlighten/smartledger-bsv/security/advisories/new>
|
|
24
|
+
- **Email:** `hello@smartledger.technology`
|
|
25
|
+
|
|
26
|
+
When reporting, please include as much of the following as you can:
|
|
27
|
+
|
|
28
|
+
- Affected version(s) and platform (Node.js version, browser, CDN vs. npm)
|
|
29
|
+
- A minimal reproduction (code snippet, transaction hex, or test vector)
|
|
30
|
+
- Impact assessment — what an attacker can do with the bug
|
|
31
|
+
- Any suggested mitigation
|
|
32
|
+
|
|
33
|
+
We aim to acknowledge new reports within **3 business days** and to provide a
|
|
34
|
+
remediation timeline within **10 business days**. Coordinated disclosure is
|
|
35
|
+
appreciated; we will credit reporters in the release notes unless you prefer
|
|
36
|
+
to remain anonymous.
|
|
37
|
+
|
|
38
|
+
## In Scope
|
|
39
|
+
|
|
40
|
+
- Cryptographic correctness bugs in `lib/crypto/` (ECDSA, BN, Hash, Random,
|
|
41
|
+
Point, Signature, Shamir).
|
|
42
|
+
- Signature/transaction malleability or forgery affecting the default verify
|
|
43
|
+
path (`lib/crypto/ecdsa.js`) or the opt-in helpers (`SmartVerify`,
|
|
44
|
+
`EllipticFixed`).
|
|
45
|
+
- Key-generation, HD-derivation (BIP-32), or mnemonic (BIP-39) flaws that
|
|
46
|
+
weaken entropy or leak material.
|
|
47
|
+
- Issues in DID:web, VC-JWT, StatusList2021, or Anchor modules that allow
|
|
48
|
+
forgery, replay, or unauthorized revocation.
|
|
49
|
+
- Bugs in BIP-143 preimage handling, covenant construction, or LTP/GDAF
|
|
50
|
+
signing paths.
|
|
51
|
+
- Supply-chain concerns about pinned runtime dependencies
|
|
52
|
+
(`elliptic@6.6.1`, `bn.js@4.11.9`, `bs58@4.0.1`, etc.).
|
|
53
|
+
|
|
54
|
+
## Out of Scope
|
|
55
|
+
|
|
56
|
+
- Vulnerabilities in development-only dependencies (`webpack 4`, `standard 12`,
|
|
57
|
+
`mocha 8`, etc.). These are tracked separately and addressed in the planned
|
|
58
|
+
3.5.0 toolchain upgrade.
|
|
59
|
+
- Issues that require a malicious local environment (compromised Node, browser
|
|
60
|
+
extension, or filesystem) to exploit.
|
|
61
|
+
- Denial-of-service from intentionally malformed inputs that do **not** cross
|
|
62
|
+
a trust boundary (e.g., feeding garbage to a library function in your own
|
|
63
|
+
process and observing it throw).
|
|
64
|
+
- Stylistic, naming, or documentation issues unrelated to security claims —
|
|
65
|
+
please open a regular issue or PR for those.
|
|
66
|
+
|
|
67
|
+
## Security Posture
|
|
68
|
+
|
|
69
|
+
`@smartledger/bsv` ships **opt-in** hardening helpers — `bsv.SmartVerify`,
|
|
70
|
+
`bsv.EllipticFixed`, and `signature.toCanonical()` — that you must call
|
|
71
|
+
explicitly. The default `transaction.verify()` / `signature.verify()` /
|
|
72
|
+
`Message().verify()` paths use BSV's own pure-JS ECDSA in
|
|
73
|
+
`lib/crypto/ecdsa.js` and are **not** routed through `SmartVerify`.
|
|
74
|
+
|
|
75
|
+
See the [Security section of the README](./README.md#-security) for the full
|
|
76
|
+
"what's in the box" table and usage examples for the opt-in helpers. A
|
|
77
|
+
planned 3.5.0 will offer an opt-in flag to route the default verify path
|
|
78
|
+
through `SmartVerify` so the protection is on by default for new users.
|
|
79
|
+
|
|
80
|
+
## Disclosure History
|
|
81
|
+
|
|
82
|
+
Significant security-relevant changes are documented in
|
|
83
|
+
[`CHANGELOG.md`](./CHANGELOG.md). Recent entries of note:
|
|
84
|
+
|
|
85
|
+
- **3.4.2 / 3.4.3** — corrected documentation overclaims about which
|
|
86
|
+
hardening is on by default vs. opt-in.
|
|
87
|
+
- **3.4.1** — `Transaction.shuffleOutputs()` now draws entropy from
|
|
88
|
+
`bsv.crypto.Random` (CSPRNG) instead of `Math.random`.
|
package/bin/cli.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
var fs = require('fs')
|
|
10
10
|
var path = require('path')
|
|
11
|
+
var pkg = require('../package.json')
|
|
11
12
|
var didweb = require('../lib/didweb')
|
|
12
13
|
var vcjwt = require('../lib/vcjwt')
|
|
13
14
|
var statuslist = require('../lib/statuslist')
|
|
@@ -43,8 +44,13 @@ function writeJsonFile(filepath, data) {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
async function main() {
|
|
46
|
-
if (
|
|
47
|
-
console.log(
|
|
47
|
+
if (command === '--version' || command === '-v') {
|
|
48
|
+
console.log(pkg.version)
|
|
49
|
+
process.exit(0)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!command || command === '--help' || command === '-h' || command === 'help') {
|
|
53
|
+
console.log('SmartLedger BSV CLI v' + pkg.version)
|
|
48
54
|
console.log('')
|
|
49
55
|
console.log('Usage:')
|
|
50
56
|
console.log(' smartledger-bsv didweb <subcommand> [options]')
|
|
@@ -205,15 +211,14 @@ async function handleVc(subcommand, opts) {
|
|
|
205
211
|
|
|
206
212
|
console.error('Verifying credential...')
|
|
207
213
|
|
|
208
|
-
// Simple resolver that reads from .well-known
|
|
209
|
-
|
|
210
|
-
|
|
214
|
+
// Simple resolver that reads from .well-known. lib/vcjwt expects
|
|
215
|
+
// `{ jwks: { keys: [...] } }`; jwks.json on disk is the raw JWKS,
|
|
216
|
+
// so wrap it.
|
|
217
|
+
var didResolver = async function (did) {
|
|
211
218
|
var jwksPath = path.join(process.cwd(), '.well-known', 'jwks.json')
|
|
212
|
-
|
|
213
219
|
if (fs.existsSync(jwksPath)) {
|
|
214
|
-
return readJsonFile(jwksPath)
|
|
220
|
+
return { jwks: readJsonFile(jwksPath) }
|
|
215
221
|
}
|
|
216
|
-
|
|
217
222
|
throw new Error('Cannot resolve DID: ' + did)
|
|
218
223
|
}
|
|
219
224
|
|