smartledger-bsv 4.2.0 → 4.4.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,87 @@ 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.4.0] - 2026-06-07
9
+
10
+ ### Added — BSV string opcodes OP_SUBSTR / OP_LEFT / OP_RIGHT
11
+
12
+ - **Implemented the re-enabled BSV (Chronicle) string opcodes in the script
13
+ interpreter.** They were declared in the opcode map (`0xb3`/`0xb4`/`0xb5`) but
14
+ unimplemented — executing one returned `BAD_OPCODE`. Now they evaluate with the
15
+ original Satoshi semantics:
16
+ - `OP_LEFT (in n -- out)` — the first `n` bytes.
17
+ - `OP_RIGHT (in n -- out)` — the last `n` bytes (`OP_RIGHT 0` ⇒ empty, not the
18
+ whole string).
19
+ - `OP_SUBSTR (in begin size -- out)` — `in[begin : begin+size]`.
20
+ Out-of-range lengths clamp to the string length; negative arguments fail with
21
+ `SCRIPT_ERR_INVALID_NUMBER_RANGE`. New test: `test/script/string_ops.js`.
22
+
23
+ ### Changed
24
+
25
+ - **Covenant field-extraction now uses these opcodes**, shrinking the scripts
26
+ further: perpetual covenant 429→**421 B**, ownership token 493→**482 B**, value
27
+ covenant 428→**424 B** (vs. the verbose `OP_SIZE/OP_SUB/OP_SPLIT/OP_NIP` form).
28
+
29
+ Full mocha suite 4190 → 4199 passing, 0 failing. Lint clean.
30
+
31
+ ## [4.3.0] - 2026-06-07
32
+
33
+ ### Changed — mainnet hardening of OP_PUSH_TX covenants
34
+
35
+ - **Canonical low-S signatures.** The OP_PUSH_TX grind now requires `s <= n/2`,
36
+ so the in-script signature is canonical (low-S) and non-malleable, and the
37
+ covenant verify path enforces `SCRIPT_VERIFY_LOW_S`. This makes the produced
38
+ spends standard for mainnet relay/mining. Cost: zero extra script bytes — the
39
+ constraint is satisfied by the spender's grind, not by added opcodes.
40
+ (`SmartContract.PushTx.sFromPreimage`, `CovenantHelpers.flags`.)
41
+ - **Smaller scripts (−22 bytes per covenant).** `pushTxCore` now shares a single
42
+ `Gx` push between the DER signature's r-value and the `02||Gx` public key
43
+ (parked on the alt-stack) instead of embedding the 32-byte constant twice.
44
+ Authenticator 404→382 B, value covenant 450→428 B, perpetual 451→429 B,
45
+ ownership token 515→493 B.
46
+
47
+ ### Notes
48
+
49
+ - The remaining ~382-byte floor is intrinsic to OP_PUSH_TX on BSV: ~248 B is the
50
+ two mandatory 32-byte endianness reversals (big-endian hash ↔ little-endian
51
+ script arithmetic ↔ big-endian DER), the rest is fixed secp256k1 constants and
52
+ the DER template. There is no single-opcode byte reverse on BSV —
53
+ `OP_REVERSEBYTES` is a Bitcoin Cash opcode, not part of the BSV opcode set, so
54
+ the `OP_SPLIT`/`OP_SWAP`/`OP_CAT` reversal gadget is the correct approach.
55
+ - New test: `test/smart_contract/covenants.js` proves the grind yields low-S
56
+ signatures enforced under `SCRIPT_VERIFY_LOW_S`. Full suite 4189 → 4190.
57
+
58
+ ## [4.2.1] - 2026-06-07
59
+
60
+ ### Docs
61
+
62
+ - **Substantial README rewrite for the v4.x line.** The README still
63
+ headlined v3.4.x (4 minors and a major stale), showed the *old*
64
+ `lib/covenant-interface` API in the covenant examples instead of the
65
+ v4.2.0 `bsv.SmartContract.PushTx`/`PELS`/`Token`/`Locks`/`verifyScript`
66
+ surface, had a wrong CDN-Bundles size table (off by up to 7× on
67
+ `bsv-mnemonic`), duplicate "Complete Documentation" sections, a
68
+ "planned 3.5.0" security note that was overtaken by 4.0.0, and a
69
+ footer stamp claiming "v3.3.4 • 9 Loading Options". Replaced the
70
+ headline with the v4.2.0 covenant section, rewrote PUSHTX/PELS
71
+ examples to use the new API, added Ownership Tokens + end-to-end
72
+ verification snippets, merged the two Documentation sections (7
73
+ broken file paths fixed, 4 dead links removed), replaced the
74
+ inaccurate CDN sub-table with a pointer to the canonical
75
+ loading-options table, updated Security to point at the v4.0.0 GDAF
76
+ fix, and stamped the footer at v4.2.1.
77
+
78
+ ### Semver
79
+
80
+ Patch — README only. No source changes; no `lib/`, `bin/`, `bsv.d.ts`,
81
+ or test diffs. Out-of-band republish: `@smartledger/bsv@4.2.0` was
82
+ published from a separate session with the OLD README, then
83
+ unpublished after the rewrite. npm's anti-republish policy refuses to
84
+ reuse the 4.2.0 version number; 4.2.1 is the canonical version with
85
+ the corrected README content. `smartledger-bsv@4.2.0` (unscoped) was
86
+ published with the new README; for parity, the unscoped is also
87
+ republished at 4.2.1.
88
+
8
89
  ## [4.2.0] - 2026-06-07
9
90
 
10
91
  ### Added
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.2.0-blue.svg)](https://www.npmjs.com/package/@smartledger/bsv)
5
+ [![Version](https://img.shields.io/badge/version-4.2.1-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)
@@ -71,8 +71,8 @@ const ok = SC.verifyScript(unlockScript, lockingScript, tx, inputIndex, satoshis
71
71
  ### **Quick Start - Issue Your First Verifiable Credential**
72
72
 
73
73
  ```bash
74
- # Install SmartLedger BSV v4.2.0
75
- npm install @smartledger/bsv@4.2.0
74
+ # Install SmartLedger BSV v4.2.1
75
+ npm install @smartledger/bsv@4.2.1
76
76
 
77
77
  # Initialize DID:web issuer (generates ES256 keys)
78
78
  npx smartledger-bsv didweb init --domain example.com --alg ES256
@@ -181,42 +181,42 @@ console.log('Status:', status) // 'revoked'
181
181
  ### **Core Modules**
182
182
  | Module | Size | Use Case | CDN |
183
183
  |--------|------|----------|-----|
184
- | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@4.2.0/bsv.min.js` |
185
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@4.2.0/bsv.bundle.js` |
184
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js` |
185
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@4.2.1/bsv.bundle.js` |
186
186
 
187
187
  ### **W3C Verifiable Credentials**
188
188
  | Module | Size | Use Case | CDN |
189
189
  |--------|------|----------|-----|
190
- | **🟢 bsv-didweb.min.js** | 419KB | **DID:web generation** | `unpkg.com/@smartledger/bsv@4.2.0/bsv-didweb.min.js` |
191
- | **🟢 bsv-vcjwt.min.js** | 419KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@4.2.0/bsv-vcjwt.min.js` |
192
- | **🟢 bsv-statuslist.min.js** | 487KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@4.2.0/bsv-statuslist.min.js` |
193
- | **🟢 bsv-anchor.min.js** | 418KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@4.2.0/bsv-anchor.min.js` |
190
+ | **🟢 bsv-didweb.min.js** | 419KB | **DID:web generation** | `unpkg.com/@smartledger/bsv@4.2.1/bsv-didweb.min.js` |
191
+ | **🟢 bsv-vcjwt.min.js** | 419KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@4.2.1/bsv-vcjwt.min.js` |
192
+ | **🟢 bsv-statuslist.min.js** | 487KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@4.2.1/bsv-statuslist.min.js` |
193
+ | **🟢 bsv-anchor.min.js** | 418KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@4.2.1/bsv-anchor.min.js` |
194
194
 
195
195
  ### **Smart Contract & Development**
196
196
  | Module | Size | Use Case | CDN |
197
197
  |--------|------|----------|-----|
198
- | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@4.2.0/bsv-smartcontract.min.js` |
199
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@4.2.0/bsv-covenant.min.js` |
200
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@4.2.0/bsv-script-helper.min.js` |
201
- | **bsv-security.min.js** | 26KB | Security enhancements | `unpkg.com/@smartledger/bsv@4.2.0/bsv-security.min.js` |
198
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@4.2.1/bsv-smartcontract.min.js` |
199
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@4.2.1/bsv-covenant.min.js` |
200
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@4.2.1/bsv-script-helper.min.js` |
201
+ | **bsv-security.min.js** | 26KB | Security enhancements | `unpkg.com/@smartledger/bsv@4.2.1/bsv-security.min.js` |
202
202
 
203
203
  ### **Legal & Compliance**
204
204
  | Module | Size | Use Case | CDN |
205
205
  |--------|------|----------|-----|
206
- | **bsv-ltp.min.js** | 1184KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@4.2.0/bsv-ltp.min.js` |
207
- | **bsv-gdaf.min.js** | 1184KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@4.2.0/bsv-gdaf.min.js` |
206
+ | **bsv-ltp.min.js** | 1184KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@4.2.1/bsv-ltp.min.js` |
207
+ | **bsv-gdaf.min.js** | 1184KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@4.2.1/bsv-gdaf.min.js` |
208
208
 
209
209
  ### **Advanced Cryptography**
210
210
  | Module | Size | Use Case | CDN |
211
211
  |--------|------|----------|-----|
212
- | **bsv-shamir.min.js** | 432KB | Threshold Cryptography | `unpkg.com/@smartledger/bsv@4.2.0/bsv-shamir.min.js` |
212
+ | **bsv-shamir.min.js** | 432KB | Threshold Cryptography | `unpkg.com/@smartledger/bsv@4.2.1/bsv-shamir.min.js` |
213
213
 
214
214
  ### **Utilities**
215
215
  | Module | Size | Use Case | CDN |
216
216
  |--------|------|----------|-----|
217
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@4.2.0/bsv-ecies.min.js` |
218
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@4.2.0/bsv-message.min.js` |
219
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@4.2.0/bsv-mnemonic.min.js` |
217
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@4.2.1/bsv-ecies.min.js` |
218
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@4.2.1/bsv-message.min.js` |
219
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@4.2.1/bsv-mnemonic.min.js` |
220
220
 
221
221
  ## ⚡ **2-Minute Quick Start**
222
222
 
@@ -227,7 +227,7 @@ Get started with Bitcoin SV development in under 2 minutes:
227
227
  npm install @smartledger/bsv
228
228
 
229
229
  # Or include in HTML
230
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv.min.js"></script>
230
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
231
231
  ```
232
232
 
233
233
  > **🔧 v4.x:** First-class interpreter-verified covenants (4.2.0), post-Genesis
@@ -325,8 +325,8 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
325
325
 
326
326
  ### 🔧 **Basic Development** (~963KB total)
327
327
  ```html
328
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv.min.js"></script>
329
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-script-helper.min.js"></script>
328
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
329
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-script-helper.min.js"></script>
330
330
  <script>
331
331
  const privateKey = new bsv.PrivateKey();
332
332
  const utxos = new bsv.SmartContract.UTXOGenerator().createRealUTXOs(2, 100000);
@@ -335,9 +335,9 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
335
335
 
336
336
  ### 🔒 **Smart Contract Development** (~2.7MB total — each bundle re-embeds core BSV)
337
337
  ```html
338
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv.min.js"></script>
339
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-covenant.min.js"></script>
340
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-smartcontract.min.js"></script>
338
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
339
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-covenant.min.js"></script>
340
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-smartcontract.min.js"></script>
341
341
  <script>
342
342
  const covenant = bsv.SmartContract.createCovenantBuilder()
343
343
  .extractField('amount').push(50000).greaterThanOrEqual().verify().build();
@@ -347,9 +347,9 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
347
347
 
348
348
  ### 🆕 **Legal & Identity Development** (~3.2MB total — each bundle re-embeds core BSV)
349
349
  ```html
350
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv.min.js"></script>
351
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-ltp.min.js"></script>
352
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-gdaf.min.js"></script>
350
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
351
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-ltp.min.js"></script>
352
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-gdaf.min.js"></script>
353
353
  <script>
354
354
  // Legal Token Protocol
355
355
  const propertyToken = bsv.createPropertyToken({
@@ -363,9 +363,9 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
363
363
 
364
364
  ### 🆕 **Security & Cryptography** (~1.4MB total)
365
365
  ```html
366
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv.min.js"></script>
367
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-security.min.js"></script>
368
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-shamir.min.js"></script>
366
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
367
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-security.min.js"></script>
368
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-shamir.min.js"></script>
369
369
  <script>
370
370
  // Threshold Cryptography
371
371
  const shares = bsv.splitSecret('my_secret_key', 5, 3); // 5 shares, 3 needed
@@ -377,7 +377,7 @@ const covenant = bsv.SmartContract.createCovenantBuilder()
377
377
 
378
378
  ### 🎯 **Everything Bundle** (937KB)
379
379
  ```html
380
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv.bundle.js"></script>
380
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.bundle.js"></script>
381
381
  <script>
382
382
  // Everything available immediately
383
383
  const shares = bsv.splitSecret('secret', 5, 3); // Shamir Secret Sharing
@@ -457,8 +457,8 @@ const contractTx = covenant.createCovenantTransaction({
457
457
 
458
458
  #### 1. **Minimal Setup** - Core + Script Helper (~963KB)
459
459
  ```html
460
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv.min.js"></script>
461
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-script-helper.min.js"></script>
460
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
461
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-script-helper.min.js"></script>
462
462
  <script>
463
463
  const tx = new bsv.Transaction();
464
464
  const sig = bsvScriptHelper.createSignature(tx, privateKey, 0, script, satoshis);
@@ -467,9 +467,9 @@ const contractTx = covenant.createCovenantTransaction({
467
467
 
468
468
  #### 2. **DeFi Development** - Core + Covenants + Debug (~2.7MB — each bundle re-embeds core BSV)
469
469
  ```html
470
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv.min.js"></script>
471
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-covenant.min.js"></script>
472
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-smartcontract.min.js"></script>
470
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
471
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-covenant.min.js"></script>
472
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-smartcontract.min.js"></script>
473
473
  <script>
474
474
  const covenant = new bsvCovenant.CovenantInterface();
475
475
  const debugInfo = SmartContract.interpretScript(script);
@@ -479,8 +479,8 @@ const contractTx = covenant.createCovenantTransaction({
479
479
 
480
480
  #### 3. **Security First** - Core + Enhanced Security (~963KB)
481
481
  ```html
482
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv.min.js"></script>
483
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-security.min.js"></script>
482
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
483
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-security.min.js"></script>
484
484
  <script>
485
485
  const verified = bsvSecurity.SmartVerify.verify(signature, hash, publicKey);
486
486
  const enhanced = bsvSecurity.EllipticFixed.createSignature(privateKey, hash);
@@ -489,7 +489,7 @@ const contractTx = covenant.createCovenantTransaction({
489
489
 
490
490
  #### 4. **Everything Bundle** - One File Solution (937KB)
491
491
  ```html
492
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv.bundle.js"></script>
492
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.bundle.js"></script>
493
493
  <script>
494
494
  // Everything available under bsv namespace
495
495
  const keys = bsv.SmartLedgerBundle.generateKeys();
@@ -789,7 +789,7 @@ const timelockScript = helper.createTimelockScript(
789
789
 
790
790
  See the **[16 Loading Options](#-16-loading-options---choose-your-approach)**
791
791
  table near the top for the full list of bundles with current sizes and
792
- canonical `unpkg.com/@smartledger/bsv@4.2.0/...` URLs.
792
+ canonical `unpkg.com/@smartledger/bsv@4.2.1/...` URLs.
793
793
 
794
794
  ## 🔐 Security
795
795
 
@@ -930,6 +930,6 @@ For security vulnerabilities, follow the disclosure process in
930
930
 
931
931
  ---
932
932
 
933
- **SmartLedger-BSV v4.2.0** — *Complete Bitcoin SV Development Framework*
933
+ **SmartLedger-BSV v4.2.1** — *Complete Bitcoin SV Development Framework*
934
934
 
935
935
  Built with ❤️ for the Bitcoin SV ecosystem • 16 Loading Options • Interpreter-Verified Covenants