@smartledger/bsv 4.5.0 → 5.0.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,108 @@ 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
+ ## [5.0.0] - 2026-06-13
9
+
10
+ ### BREAKING — Shamir Secret Sharing now uses a vetted GF(2⁸) engine
11
+
12
+ `crypto.Shamir` previously used a hand-rolled finite-field implementation over a
13
+ 31-bit prime, with no authentication of shares. It is now backed by
14
+ `secrets.js-grempe` (a vetted GF(2⁸) implementation), with two safety additions:
15
+ a per-split nonce (`splitId`) so shares from different splits can't be silently
16
+ mixed, and an integrity `checksum` so a tampered/mismatched share set is rejected
17
+ at combine time instead of returning garbage.
18
+
19
+ - **New share format (v2).** `split()` returns objects shaped
20
+ `{ v, id, threshold, shares, length, splitId, share, checksum }` instead of the
21
+ old `{ id, threshold, shares, length, bytes:[{x,y}] }`.
22
+ - **Old shares remain recoverable.** `combine()` and `verifyShare()` detect and
23
+ accept legacy (≤ 4.x) shares for recovery; you do not need the old version to
24
+ reconstruct previously-split secrets.
25
+ - Randomness is sourced from the library's own `crypto.Random` (Node CSPRNG /
26
+ `window.crypto`) via `secrets.setRNG`, and `secrets` is loaded lazily so simply
27
+ importing the library never triggers its init.
28
+ - New coverage in `test/crypto/shamir.js` (round-trips, threshold subsets,
29
+ leading-zero/Buffer secrets, tamper detection, split isolation, legacy
30
+ recovery).
31
+
32
+ Browser bundles that bundle the full library no longer mock node `crypto` as
33
+ empty (`bsv.min.js`, `bsv.bundle.js`, `bsv-security.min.js`); webpack's default
34
+ `crypto` polyfill is used so Shamir can obtain a CSPRNG. This increases the size
35
+ of the full bundles (e.g. `bsv.min.js` ~951 KB → ~1.2 MB); the dedicated
36
+ non-Shamir module bundles are unaffected.
37
+
38
+ ### BREAKING — VC-JWT signatures are now JOSE-compliant (IEEE P1363)
39
+
40
+ Up to and including 4.6.0, `VcJwt.issueVcJwt` signed with Node's default
41
+ ECDSA output, which is **DER-encoded**. The JOSE specs (RFC 7515/7518, and
42
+ RFC 8812 for ES256K) require ECDSA JWS signatures to be the raw `r||s`
43
+ concatenation (**IEEE P1363**). As a result, tokens issued by older versions
44
+ **did not verify in any standards-compliant library** (`jose`, `jsonwebtoken`,
45
+ etc.), and this library could not verify standard tokens from other issuers.
46
+ This also affected `StatusList`, which issues its lists via `VcJwt`.
47
+
48
+ - **`VcJwt.issueVcJwt`** now emits P1363 signatures and is verifiable by `jose`.
49
+ - **`VcJwt.verifyVcJwt`** now decodes P1363 signatures.
50
+ - **Migration:** tokens issued by ≤ 4.6.0 carry DER signatures and will fail
51
+ verification by default. Pass `{ allowLegacyDER: true }` to `verifyVcJwt` to
52
+ accept them while you re-issue. New tokens require no flag.
53
+ - Round-trip interoperability with `jose` (both directions, ES256 + ES256K) is
54
+ now covered by `test/vcjwt/interop.js`.
55
+
56
+ ### Security
57
+
58
+ - **VC-JWT algorithm pinning.** `verifyVcJwt` now rejects any token whose
59
+ `alg` is not in the allowed set (default `['ES256','ES256K']`, overridable via
60
+ `opts.allowedAlgs`) **before** verifying — closing the classic JWT algorithm
61
+ substitution hole. It also binds the resolved key's curve to the algorithm
62
+ (an ES256K signature can no longer be checked against a P-256 key), and
63
+ `issueVcJwt` refuses to sign when the key curve and `alg` disagree.
64
+ - **`crypto/elliptic-fixed` low-S now preserves `recoveryParam`.** The previous
65
+ manual `s → n-s` flip did not update the recovery id, so public-key recovery
66
+ returned the wrong key for ~50% of signatures. Canonicalization now uses
67
+ elliptic's own `{ canonical: true }`, which keeps `recoveryParam` consistent.
68
+ - **ECIES MAC check is now constant-time** (portable comparison; no early-out
69
+ on the first differing byte).
70
+
71
+ ### Fixed
72
+
73
+ - **Removed the self-referential dependency.** `package.json` listed
74
+ `@smartledger/bsv` as one of its own `dependencies`, causing npm to install a
75
+ nested older copy of the package and triggering the "More than one instance of
76
+ bsv" guard. Removed.
77
+
78
+ ### Changed
79
+
80
+ - Deduplicated `package.json` keywords (86 → 79).
81
+ - `bsv.SmartUTXO` removal pushed from v5.0.0 to v6.0.0 (still soft-deprecated).
82
+
83
+ ## [4.6.0] - 2026-06-09
84
+
85
+ ### Fixed — covenants are now mainnet-relayable (MINIMALDATA)
86
+
87
+ OP_PUSH_TX covenants up to 4.5.0 were consensus-valid but **non-standard**: their
88
+ locking scripts contained non-minimal data pushes, so every mainnet miner
89
+ rejected the spend with `non-mandatory-script-verify-flag (Data push larger than
90
+ necessary)` = `SCRIPT_ERR_MINIMALDATA`. Found by actually broadcasting to BSV
91
+ mainnet (WhatsOnChain/Taal **and** GorillaPool ARC both rejected it).
92
+
93
+ The non-minimal pushes were: a bare `0x00` sign byte, a bare `0x02` pubkey
94
+ prefix, and small integers (3/4/8) pushed as data. Fixes:
95
+
96
+ - **`PushTx.pushTxCore`**: drop the `0x00` sign-extension — the grind now requires
97
+ `z[0]` (first byte of HASH256(preimage)) to be `0x01..0x7f`, so the hash is
98
+ already a positive, minimally-encoded number. Use `OP_2` for the pubkey prefix.
99
+ - **`CovenantHelpers.scriptNum`**: emit `OP_0`/`OP_1..OP_16`/`OP_1NEGATE` for
100
+ `0..16`/`-1` instead of a data push (fixes PELS, token, and the DSL's
101
+ `lockUntil`).
102
+ - **`CovenantHelpers.flags`**: now includes `SCRIPT_VERIFY_MINIMALDATA`, so local
103
+ `verifyScript`/`trace` mirror real mainnet relay policy and catch non-relayable
104
+ covenants before broadcast.
105
+
106
+ A value covenant built with this release was **deployed and spent on BSV
107
+ mainnet** (txids `f9f25dbd…` deploy, `ea438096…` spend). Full suite 4206 passing,
108
+ lint clean.
109
+
8
110
  ## [4.5.0] - 2026-06-09
9
111
 
10
112
  ### Added — declarative covenant DSL + stack debugger
package/README.md CHANGED
@@ -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.1/bsv.min.js` |
185
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@4.2.1/bsv.bundle.js` |
184
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@5.0.0/bsv.min.js` |
185
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@5.0.0/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.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` |
190
+ | **🟢 bsv-didweb.min.js** | 419KB | **DID:web generation** | `unpkg.com/@smartledger/bsv@5.0.0/bsv-didweb.min.js` |
191
+ | **🟢 bsv-vcjwt.min.js** | 419KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@5.0.0/bsv-vcjwt.min.js` |
192
+ | **🟢 bsv-statuslist.min.js** | 487KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@5.0.0/bsv-statuslist.min.js` |
193
+ | **🟢 bsv-anchor.min.js** | 418KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@5.0.0/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.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` |
198
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@5.0.0/bsv-smartcontract.min.js` |
199
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@5.0.0/bsv-covenant.min.js` |
200
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@5.0.0/bsv-script-helper.min.js` |
201
+ | **bsv-security.min.js** | 26KB | Security enhancements | `unpkg.com/@smartledger/bsv@5.0.0/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.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` |
206
+ | **bsv-ltp.min.js** | 1184KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@5.0.0/bsv-ltp.min.js` |
207
+ | **bsv-gdaf.min.js** | 1184KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@5.0.0/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.1/bsv-shamir.min.js` |
212
+ | **bsv-shamir.min.js** | 432KB | Threshold Cryptography | `unpkg.com/@smartledger/bsv@5.0.0/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.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` |
217
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@5.0.0/bsv-ecies.min.js` |
218
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@5.0.0/bsv-message.min.js` |
219
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@5.0.0/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.1/bsv.min.js"></script>
230
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/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.1/bsv.min.js"></script>
329
- <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-script-helper.min.js"></script>
328
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/bsv.min.js"></script>
329
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/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.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>
338
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/bsv.min.js"></script>
339
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/bsv-covenant.min.js"></script>
340
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/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.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>
350
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/bsv.min.js"></script>
351
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/bsv-ltp.min.js"></script>
352
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/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.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>
366
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/bsv.min.js"></script>
367
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/bsv-security.min.js"></script>
368
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/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.1/bsv.bundle.js"></script>
380
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/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.1/bsv.min.js"></script>
461
- <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-script-helper.min.js"></script>
460
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/bsv.min.js"></script>
461
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/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.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>
470
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/bsv.min.js"></script>
471
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/bsv-covenant.min.js"></script>
472
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/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.1/bsv.min.js"></script>
483
- <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-security.min.js"></script>
482
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/bsv.min.js"></script>
483
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/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.1/bsv.bundle.js"></script>
492
+ <script src="https://unpkg.com/@smartledger/bsv@5.0.0/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.1/...` URLs.
792
+ canonical `unpkg.com/@smartledger/bsv@5.0.0/...` URLs.
793
793
 
794
794
  ## 🔐 Security
795
795