smartledger-bsv 4.0.1 → 4.1.0

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 CHANGED
@@ -5,6 +5,75 @@ All notable changes to SmartLedger-BSV will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [4.1.0] - 2026-06-07
9
+
10
+ ### Added
11
+
12
+ - **`Interpreter.useGenesisLimits([max])` — one-call opt-in for
13
+ post-Genesis BSV consensus.** The bundled `Script.Interpreter`
14
+ hardcoded the *pre-Genesis* consensus caps that BSV removed at the
15
+ Genesis upgrade (February 2020): 520-byte stack elements, 4-byte
16
+ script numbers, 201 non-push opcodes per script. Those caps make this
17
+ library's own flagship features impossible to evaluate — OP_PUSH_TX
18
+ covenants push a ~585-byte preimage element, do 32-byte modular
19
+ arithmetic (`OP_ADD`/`OP_MOD`), and run a few hundred opcodes.
20
+
21
+ ```js
22
+ // Default: bound the limits to a safe ceiling.
23
+ // 64 KB covers every covenant pattern seen in production and blocks
24
+ // memory-exhaustion via oversized pushes from untrusted scripts.
25
+ bsv.Script.Interpreter.useGenesisLimits(64 * 1024)
26
+
27
+ // Or fully unbounded (~2 GB) — only safe for trusted scripts:
28
+ // bsv.Script.Interpreter.useGenesisLimits()
29
+ ```
30
+
31
+ Defaults are unchanged out of the box (520 / 4 / 201) — existing
32
+ consumers see zero behavior change unless they opt in. The call
33
+ mutates static properties on the `Interpreter` constructor and
34
+ therefore affects every subsequent `new Interpreter()` in the
35
+ process; treat it as an app-startup setting, not per-request.
36
+
37
+ - **`Interpreter.MAX_OPS_PER_SCRIPT`** exposed as a named constant
38
+ (= 201). Replaces the two hardcoded `> 201` checks in `Interpreter.step`.
39
+
40
+ - **`bsv.d.ts`** now types `Interpreter.MAX_SCRIPT_ELEMENT_SIZE`,
41
+ `MAXIMUM_ELEMENT_SIZE`, `MAX_OPS_PER_SCRIPT`, and `useGenesisLimits()`.
42
+
43
+ ### Fixed
44
+
45
+ - **`Interpreter.MAXIMUM_ELEMENT_SIZE` was a dead knob in the numeric
46
+ opcodes.** The constant was defined as `4` but never threaded into the
47
+ `BN.fromScriptNumBuffer(buf, fRequireMinimal, size)` calls in
48
+ `OP_ADD`/`OP_SUB`/`OP_MUL`/`OP_DIV`/`OP_MOD`/`OP_BOOLAND`/`OP_BOOLOR`/
49
+ `OP_NUMEQUAL`/`OP_NUMEQUALVERIFY`/`OP_NUMNOTEQUAL`/`OP_LESSTHAN`/
50
+ `OP_GREATERTHAN`/`OP_LESSTHANOREQUAL`/`OP_GREATERTHANOREQUAL`/`OP_MIN`/
51
+ `OP_MAX` (binary) and `OP_WITHIN` (ternary). The 3rd `size` argument was
52
+ always omitted, so BN fell back to its own 4-byte default — raising
53
+ `Interpreter.MAXIMUM_ELEMENT_SIZE` above 4 had no effect. Now threaded
54
+ through, so the knob actually does what its name implies.
55
+
56
+ ### Tests
57
+
58
+ - Added `test/script/genesis_limits.js` (6 tests) covering defaults,
59
+ the lift, rejection of >4-byte arithmetic and >201 opcodes under
60
+ defaults, and acceptance of both after `useGenesisLimits()`. Full
61
+ suite: **4178 passing, 0 failing**.
62
+
63
+ ### Docs
64
+
65
+ - README §"Evaluating covenants locally" — one-paragraph mention of
66
+ the new API in the covenant/smart-contract section.
67
+ - JSDoc on `useGenesisLimits` calls out the process-wide-mutation
68
+ semantics and recommends bounded ceilings for untrusted input.
69
+ - CDN/install refs bumped `@4.0.1` → `@4.1.0` across README + 6 docs
70
+ files.
71
+
72
+ ### Semver
73
+
74
+ Minor bump — purely additive: a new public method and a fixed-but-was-
75
+ dead constant. No existing API or default behavior changes.
76
+
8
77
  ## [4.0.1] - 2026-05-31
9
78
 
10
79
  ### Deprecated
package/README.md CHANGED
@@ -2,7 +2,7 @@
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
- [![Version](https://img.shields.io/badge/version-4.0.1-blue.svg)](https://www.npmjs.com/package/@smartledger/bsv)
5
+ [![Version](https://img.shields.io/badge/version-4.1.0-blue.svg)](https://www.npmjs.com/package/@smartledger/bsv)
6
6
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
7
7
  [![BSV](https://img.shields.io/badge/BSV-Compatible-orange.svg)](https://bitcoinsv.com/)
8
8
  [![Modular](https://img.shields.io/badge/Loading-Modular-purple.svg)](#loading-options)
@@ -25,8 +25,8 @@ The most comprehensive and flexible Bitcoin SV library available. **In v3.4.x**:
25
25
  ### **Quick Start - Issue Your First Verifiable Credential**
26
26
 
27
27
  ```bash
28
- # Install SmartLedger BSV v4.0.1
29
- npm install @smartledger/bsv@4.0.1
28
+ # Install SmartLedger BSV v4.1.0
29
+ npm install @smartledger/bsv@4.1.0
30
30
 
31
31
  # Initialize DID:web issuer (generates ES256 keys)
32
32
  npx smartledger-bsv didweb init --domain example.com --alg ES256
@@ -135,42 +135,42 @@ console.log('Status:', status) // 'revoked'
135
135
  ### **Core Modules**
136
136
  | Module | Size | Use Case | CDN |
137
137
  |--------|------|----------|-----|
138
- | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@4.0.1/bsv.min.js` |
139
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@4.0.1/bsv.bundle.js` |
138
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@4.1.0/bsv.min.js` |
139
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@4.1.0/bsv.bundle.js` |
140
140
 
141
141
  ### **🆕 W3C Verifiable Credentials (v3.4.x)**
142
142
  | Module | Size | Use Case | CDN |
143
143
  |--------|------|----------|-----|
144
- | **🟢 bsv-didweb.min.js** | 419KB | **DID:web generation** | `unpkg.com/@smartledger/bsv@4.0.1/bsv-didweb.min.js` |
145
- | **🟢 bsv-vcjwt.min.js** | 419KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@4.0.1/bsv-vcjwt.min.js` |
146
- | **🟢 bsv-statuslist.min.js** | 487KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@4.0.1/bsv-statuslist.min.js` |
147
- | **🟢 bsv-anchor.min.js** | 418KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@4.0.1/bsv-anchor.min.js` |
144
+ | **🟢 bsv-didweb.min.js** | 419KB | **DID:web generation** | `unpkg.com/@smartledger/bsv@4.1.0/bsv-didweb.min.js` |
145
+ | **🟢 bsv-vcjwt.min.js** | 419KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@4.1.0/bsv-vcjwt.min.js` |
146
+ | **🟢 bsv-statuslist.min.js** | 487KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@4.1.0/bsv-statuslist.min.js` |
147
+ | **🟢 bsv-anchor.min.js** | 418KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@4.1.0/bsv-anchor.min.js` |
148
148
 
149
149
  ### **Smart Contract & Development**
150
150
  | Module | Size | Use Case | CDN |
151
151
  |--------|------|----------|-----|
152
- | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@4.0.1/bsv-smartcontract.min.js` |
153
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@4.0.1/bsv-covenant.min.js` |
154
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@4.0.1/bsv-script-helper.min.js` |
155
- | **bsv-security.min.js** | 26KB | Security enhancements | `unpkg.com/@smartledger/bsv@4.0.1/bsv-security.min.js` |
152
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@4.1.0/bsv-smartcontract.min.js` |
153
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@4.1.0/bsv-covenant.min.js` |
154
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@4.1.0/bsv-script-helper.min.js` |
155
+ | **bsv-security.min.js** | 26KB | Security enhancements | `unpkg.com/@smartledger/bsv@4.1.0/bsv-security.min.js` |
156
156
 
157
157
  ### **Legal & Compliance**
158
158
  | Module | Size | Use Case | CDN |
159
159
  |--------|------|----------|-----|
160
- | **bsv-ltp.min.js** | 1184KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@4.0.1/bsv-ltp.min.js` |
161
- | **bsv-gdaf.min.js** | 1184KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@4.0.1/bsv-gdaf.min.js` |
160
+ | **bsv-ltp.min.js** | 1184KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@4.1.0/bsv-ltp.min.js` |
161
+ | **bsv-gdaf.min.js** | 1184KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@4.1.0/bsv-gdaf.min.js` |
162
162
 
163
163
  ### **Advanced Cryptography**
164
164
  | Module | Size | Use Case | CDN |
165
165
  |--------|------|----------|-----|
166
- | **bsv-shamir.min.js** | 432KB | Threshold Cryptography | `unpkg.com/@smartledger/bsv@4.0.1/bsv-shamir.min.js` |
166
+ | **bsv-shamir.min.js** | 432KB | Threshold Cryptography | `unpkg.com/@smartledger/bsv@4.1.0/bsv-shamir.min.js` |
167
167
 
168
168
  ### **Utilities**
169
169
  | Module | Size | Use Case | CDN |
170
170
  |--------|------|----------|-----|
171
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@4.0.1/bsv-ecies.min.js` |
172
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@4.0.1/bsv-message.min.js` |
173
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@4.0.1/bsv-mnemonic.min.js` |
171
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@4.1.0/bsv-ecies.min.js` |
172
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@4.1.0/bsv-message.min.js` |
173
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@4.1.0/bsv-mnemonic.min.js` |
174
174
 
175
175
  ## ⚡ **2-Minute Quick Start**
176
176
 
@@ -181,7 +181,7 @@ Get started with Bitcoin SV development in under 2 minutes:
181
181
  npm install @smartledger/bsv
182
182
 
183
183
  # Or include in HTML
184
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv.min.js"></script>
184
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv.min.js"></script>
185
185
  ```
186
186
 
187
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.
@@ -276,8 +276,8 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
276
276
 
277
277
  ### 🔧 **Basic Development** (~963KB total)
278
278
  ```html
279
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv.min.js"></script>
280
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv-script-helper.min.js"></script>
279
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv.min.js"></script>
280
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv-script-helper.min.js"></script>
281
281
  <script>
282
282
  const privateKey = new bsv.PrivateKey();
283
283
  const utxos = new bsv.SmartContract.UTXOGenerator().createRealUTXOs(2, 100000);
@@ -286,9 +286,9 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
286
286
 
287
287
  ### 🔒 **Smart Contract Development** (~2.7MB total — each bundle re-embeds core BSV)
288
288
  ```html
289
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv.min.js"></script>
290
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv-covenant.min.js"></script>
291
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv-smartcontract.min.js"></script>
289
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv.min.js"></script>
290
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv-covenant.min.js"></script>
291
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv-smartcontract.min.js"></script>
292
292
  <script>
293
293
  const covenant = bsv.SmartContract.createCovenantBuilder()
294
294
  .extractField('amount').push(50000).greaterThanOrEqual().verify().build();
@@ -298,9 +298,9 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
298
298
 
299
299
  ### 🆕 **Legal & Identity Development** (~3.2MB total — each bundle re-embeds core BSV)
300
300
  ```html
301
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv.min.js"></script>
302
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv-ltp.min.js"></script>
303
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv-gdaf.min.js"></script>
301
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv.min.js"></script>
302
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv-ltp.min.js"></script>
303
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv-gdaf.min.js"></script>
304
304
  <script>
305
305
  // Legal Token Protocol
306
306
  const propertyToken = bsv.createPropertyToken({
@@ -314,9 +314,9 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
314
314
 
315
315
  ### 🆕 **Security & Cryptography** (~1.4MB total)
316
316
  ```html
317
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv.min.js"></script>
318
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv-security.min.js"></script>
319
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv-shamir.min.js"></script>
317
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv.min.js"></script>
318
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv-security.min.js"></script>
319
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv-shamir.min.js"></script>
320
320
  <script>
321
321
  // Threshold Cryptography
322
322
  const shares = bsv.splitSecret('my_secret_key', 5, 3); // 5 shares, 3 needed
@@ -328,7 +328,7 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
328
328
 
329
329
  ### 🎯 **Everything Bundle** (937KB)
330
330
  ```html
331
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv.bundle.js"></script>
331
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv.bundle.js"></script>
332
332
  <script>
333
333
  // Everything available immediately
334
334
  const shares = bsv.splitSecret('secret', 5, 3); // Shamir Secret Sharing
@@ -408,8 +408,8 @@ const contractTx = covenant.createCovenantTransaction({
408
408
 
409
409
  #### 1. **Minimal Setup** - Core + Script Helper (~963KB)
410
410
  ```html
411
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv.min.js"></script>
412
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv-script-helper.min.js"></script>
411
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv.min.js"></script>
412
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv-script-helper.min.js"></script>
413
413
  <script>
414
414
  const tx = new bsv.Transaction();
415
415
  const sig = bsvScriptHelper.createSignature(tx, privateKey, 0, script, satoshis);
@@ -418,9 +418,9 @@ const contractTx = covenant.createCovenantTransaction({
418
418
 
419
419
  #### 2. **DeFi Development** - Core + Covenants + Debug (~2.7MB — each bundle re-embeds core BSV)
420
420
  ```html
421
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv.min.js"></script>
422
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv-covenant.min.js"></script>
423
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv-smartcontract.min.js"></script>
421
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv.min.js"></script>
422
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv-covenant.min.js"></script>
423
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv-smartcontract.min.js"></script>
424
424
  <script>
425
425
  const covenant = new bsvCovenant.CovenantInterface();
426
426
  const debugInfo = SmartContract.interpretScript(script);
@@ -430,8 +430,8 @@ const contractTx = covenant.createCovenantTransaction({
430
430
 
431
431
  #### 3. **Security First** - Core + Enhanced Security (~963KB)
432
432
  ```html
433
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv.min.js"></script>
434
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv-security.min.js"></script>
433
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv.min.js"></script>
434
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv-security.min.js"></script>
435
435
  <script>
436
436
  const verified = bsvSecurity.SmartVerify.verify(signature, hash, publicKey);
437
437
  const enhanced = bsvSecurity.EllipticFixed.createSignature(privateKey, hash);
@@ -440,7 +440,7 @@ const contractTx = covenant.createCovenantTransaction({
440
440
 
441
441
  #### 4. **Everything Bundle** - One File Solution (937KB)
442
442
  ```html
443
- <script src="https://unpkg.com/@smartledger/bsv@4.0.1/bsv.bundle.js"></script>
443
+ <script src="https://unpkg.com/@smartledger/bsv@4.1.0/bsv.bundle.js"></script>
444
444
  <script>
445
445
  // Everything available under bsv namespace
446
446
  const keys = bsv.SmartLedgerBundle.generateKeys();
@@ -651,6 +651,37 @@ const pels = covenant.createAdvancedCovenant('perpetual', {
651
651
  });
652
652
  ```
653
653
 
654
+ ### Evaluating covenants locally — `Interpreter.useGenesisLimits()` (v4.1.0+)
655
+
656
+ The bundled `Script.Interpreter` defaults to **pre-Genesis** BSV consensus
657
+ caps — 520-byte stack elements, 4-byte script numbers, 201 opcodes per
658
+ script — which BSV removed at the Genesis upgrade (Feb 2020). Those caps
659
+ make it impossible to evaluate this library's own flagship features:
660
+ OP_PUSH_TX covenants push a ~585-byte preimage, do 32-byte modular
661
+ arithmetic, and run a few hundred opcodes.
662
+
663
+ Opt into post-Genesis rules with a single call at app startup:
664
+
665
+ ```javascript
666
+ const bsv = require('@smartledger/bsv');
667
+
668
+ // Default: bound the limits to a safe ceiling (covers every covenant
669
+ // pattern seen in production, blocks oversized-push memory DoS).
670
+ bsv.Script.Interpreter.useGenesisLimits(64 * 1024);
671
+
672
+ // Or, for fully unbounded (~2 GB) — only safe for trusted scripts:
673
+ // bsv.Script.Interpreter.useGenesisLimits();
674
+
675
+ // Now OP_PUSH_TX covenants verify locally:
676
+ const interp = new bsv.Script.Interpreter();
677
+ const ok = interp.verify(unlockScript, lockScript, tx, 0, flags, satoshisBN);
678
+ ```
679
+
680
+ This is a **process-wide** setting — once called, every subsequent
681
+ `new Interpreter()` runs with lifted caps. Defaults are unchanged out of
682
+ the box; if you don't call `useGenesisLimits()`, behavior is identical
683
+ to pre-v4.1.0.
684
+
654
685
  ## 🛠️ Custom Scripts
655
686
 
656
687
  ### Multi-signature Scripts