@smartledger/bsv 9.13.0 → 9.15.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
@@ -7,6 +7,131 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [9.15.0] - 2026-09-29
11
+
12
+ ### Security — `LOW_S` masked every STRICTENC signature check, on this library's own default flags
13
+
14
+ `checkSignatureEncoding` chained its three checks with `else if`. The node has three
15
+ independent `if`s. `SCRIPT_VERIFY_LOW_S` is set by both `mainnetFlags()` and
16
+ `currentConsensusFlags()`, so on the default path the LOW_S branch returned and the whole
17
+ STRICTENC block below it never ran. Three signatures the node refuses by name were accepted:
18
+
19
+ | signature | node | this library, before 9.15.0 |
20
+ |---|---|---|
21
+ | undefined hash type | `SIG_HASHTYPE` | **accepted** |
22
+ | no FORKID bit, where FORKID is required | `MUST_USE_FORKID` | **accepted** |
23
+ | Chronicle digest requested outside Chronicle | `ILLEGAL_CHRONICLE` | **accepted** |
24
+
25
+ This is the direction that costs money: a transaction the network rejects was reported valid.
26
+ The third case undoes the guard added for Chronicle — a signature whose type byte sets `0x20`
27
+ is read as asking for the original digest, and refusing it outright is what lets
28
+ `sighash()` route on the bit alone. Anyone verifying third-party transactions with
29
+ `mainnetFlags()` should treat 9.15.0 as a required upgrade.
30
+
31
+ The bug is inherited from the upstream `bsv`/`bitcore-lib` lineage, not introduced here, and
32
+ the node's own 1,483-row corpus cannot see it: not one row pairs `LOW_S` with a hash-type
33
+ expectation. It was found by transcribing `VerifyScript` against the C++ line by line rather
34
+ than reading the one line under repair.
35
+
36
+ ### Fixed — Chronicle's malleability relaxations were not applied
37
+
38
+ Chronicle lets a transaction opt into malleability by using a **version above 1**. The node
39
+ then stops applying the rules that exist only to stop a signed transaction being rewritten in
40
+ flight — `EnforceNonMalleability(flags, checker.Version())`, at seven sites
41
+ (`interpreter.cpp` 285, 433, 801, 1493, 1643, 1666 and 2441). This library
42
+ applied all seven regardless, so it **refused transactions the network accepts**, on its own
43
+ default flags, for any transaction with `version > 1`:
44
+
45
+ `LOW_S`, `MINIMALDATA`, `MINIMALIF`, `NULLFAIL` (both `CHECKSIG` and `CHECKMULTISIG`),
46
+ `NULLDUMMY`, `SIGPUSHONLY` and `CLEANSTACK`.
47
+
48
+ The gate reads `SCRIPT_CHRONICLE` — the era of the block being built — not
49
+ `SCRIPT_UTXO_AFTER_CHRONICLE`, the era of the output being spent; Chronicle activated at block
50
+ 943,816, so it is set for anything validated against today's chain. Every version at or below 1
51
+ is unaffected, and so is every flag set without Chronicle. Exposed as
52
+ `Interpreter#enforceNonMalleability()`, beside `isAfterGenesis()` and `isAfterChronicle()`.
53
+
54
+ The corpus cannot see this either: all 1,483 of its rows carry transaction version 1.
55
+
56
+ ### Fixed — `SIGPUSHONLY` is a rule of an era, not of the flag alone
57
+
58
+ The node applies it post-Genesis, and under Chronicle only to a non-malleable version:
59
+
60
+ ```cpp
61
+ if((IsGenesis(flags) && !IsChronicle(flags)) ||
62
+ (IsChronicle(flags) && !IsMalleableTxnVersion(checker.Version())))
63
+ ```
64
+
65
+ It also never *sets* the flag outside that window — `InputScriptVerifyFlags` adds it only once
66
+ the block era is post-Genesis. Before Genesis a non-push scriptSig was refused only where P2SH
67
+ demanded it, which this library still does.
68
+
69
+ ### Fixed — `CLEANSTACK` required `P2SH` only before Genesis, and the harness was short a rule
70
+
71
+ The node requires the `P2SH` flag alongside `CLEANSTACK` in **every** era, including after
72
+ Genesis removed P2SH. This library carried a post-Genesis carve-out of its own, because the
73
+ corpus appeared to demand one. It does not — the node's harness adds the flag before calling
74
+ `VerifyScript`:
75
+
76
+ ```cpp
77
+ if(flags & SCRIPT_VERIFY_CLEANSTACK) flags |= SCRIPT_VERIFY_P2SH; // DoTest
78
+ ```
79
+
80
+ so the row naming `CLEANSTACK` alone never reaches that branch. `tools/sv-vector-harness.js`
81
+ was missing the adjustment, which ran that row under a flag set `VerifyScript` refuses
82
+ outright: it failed for the wrong reason and stopped testing clean stacks at all. A vector
83
+ file states the flags a row names, not the ones its runner adds.
84
+
85
+ ### Changed — the one behaviour that tightens
86
+
87
+ Everything else here either refuses something the network refuses or accepts something it
88
+ accepts. This is the exception, stated plainly so nobody meets it by surprise: a flag word
89
+ carrying `CLEANSTACK` **without** `P2SH` used to verify after Genesis, and now returns false
90
+ with `SCRIPT_ERR_INVALID_FLAGS`, which is what the node does in every era.
91
+
92
+ It is not reachable through any flag set this library produces — `mainnetFlags()` and
93
+ `currentConsensusFlags()` both include `P2SH` — so only a hand-assembled flag word is
94
+ affected, and the fix is to add `SCRIPT_VERIFY_P2SH`, which is what the node's own test
95
+ harness does. It ships in a minor rather than waiting for the major because the alternative
96
+ is disagreeing with the node about which flag sets are valid; STABILITY.md § Consensus
97
+ tracking is the clause that allows it.
98
+
99
+ ### Fixed — `CLEANSTACK` without `P2SH` threw an internal error
100
+
101
+ Those flags come from a caller, so the node names the problem
102
+ (`SCRIPT_ERR_INVALID_FLAGS`) rather than asserting. Throwing turned a verdict into a crash for
103
+ anyone verifying with `CLEANSTACK` alone. A flag set claiming a post-Chronicle UTXO that is not
104
+ post-Genesis is now refused the same way, as the node's `valid_flags` does, instead of being
105
+ evaluated from half an era.
106
+
107
+ ## [9.14.0] - 2026-09-29
108
+
109
+ ### Added — `minDifficulty`, because a work floor in hashes invites a unit error that fails open
110
+
111
+ `minWork` counts **hashes**. Difficulty is the unit a floor is actually quoted in: a real BSV
112
+ header is "difficulty 2.6e10", not "1.1e20 hashes". The two are 4,295,032,833 apart, so reading
113
+ one as the other sets a floor **4.3 billion times too low** — and it fails *open*, because the
114
+ call keeps succeeding and nothing says the floor stopped meaning anything.
115
+
116
+ That is not hypothetical. While comparing this library's cap with the BRC-220 reference
117
+ implementation's floor, its `minDifficulty: 5e9` was read here as 5e9 *hashes* and reported as
118
+ "difficulty 1.16, a twentieth of a billionth of a real header". The true figure is 5e9 ×
119
+ 4,295,032,833 ≈ **2.1e19** hashes, about a fifth of block 954784's 1.098e20 — a sound floor,
120
+ misread by a factor of 4.3e9 in the direction that looks alarming rather than safe. The
121
+ reference's API had the better name first.
122
+
123
+ So `SPV.verifyTxInclusion` and `NotaryHash.verify` now take `minDifficulty` beside `minWork`:
124
+
125
+ ```js
126
+ NotaryHash.verify(cert, { header, minDifficulty: '2.5e10' }) // difficulty, as quoted
127
+ NotaryHash.verify(cert, { header, minWork: '1e20' }) // hashes, as counted
128
+ ```
129
+
130
+ Exactly one of the two: passing both throws rather than leaving the caller to guess which
131
+ applied. The conversion is exact — a fractional or exponent-form difficulty is expanded by
132
+ moving the decimal point, never through a float — and `minDifficulty` also satisfies the 9.13.0
133
+ notice, so a caller stating a policy in difficulty is not warned.
134
+
10
135
  ## [9.13.0] - 2026-09-29
11
136
 
12
137
  ### Deprecated — verifying an anchor with a header and no trust policy
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Bitcoin SV library with an interpreter-verified script engine.
4
4
 
5
- [![Version](https://img.shields.io/badge/version-9.13.0-blue.svg)](https://www.npmjs.com/package/@smartledger/bsv)
5
+ [![Version](https://img.shields.io/badge/version-9.15.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
  [![Stability](https://img.shields.io/badge/9.x%20stable%20until-2027--09--01-brightgreen.svg)](STABILITY.md)
8
8
 
@@ -155,44 +155,44 @@ const bsv = require('@smartledger/bsv') // 128 modules
155
155
  ### **Core Modules**
156
156
  | Module | Size | Use Case | CDN |
157
157
  |--------|------|----------|-----|
158
- | **bsv.min.js** | 1061KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.13.0/bsv.min.js` |
159
- | **bsv.bundle.js** | 1061KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.13.0/bsv.bundle.js` |
158
+ | **bsv.min.js** | 1062KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.15.0/bsv.min.js` |
159
+ | **bsv.bundle.js** | 1062KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.15.0/bsv.bundle.js` |
160
160
 
161
161
  ### **W3C Verifiable Credentials**
162
162
  | Module | Size | Use Case | CDN |
163
163
  |--------|------|----------|-----|
164
- | **🟢 bsv-didweb.min.js** | 166KB | **DID:web generation** | `unpkg.com/@smartledger/bsv@9.13.0/bsv-didweb.min.js` |
165
- | **🟢 bsv-vcjwt.min.js** | 166KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@9.13.0/bsv-vcjwt.min.js` |
166
- | **🟢 bsv-statuslist.min.js** | 256KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@9.13.0/bsv-statuslist.min.js` |
167
- | **🟢 bsv-anchor.min.js** | 164KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@9.13.0/bsv-anchor.min.js` |
164
+ | **🟢 bsv-didweb.min.js** | 166KB | **DID:web generation** | `unpkg.com/@smartledger/bsv@9.15.0/bsv-didweb.min.js` |
165
+ | **🟢 bsv-vcjwt.min.js** | 166KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@9.15.0/bsv-vcjwt.min.js` |
166
+ | **🟢 bsv-statuslist.min.js** | 256KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@9.15.0/bsv-statuslist.min.js` |
167
+ | **🟢 bsv-anchor.min.js** | 164KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@9.15.0/bsv-anchor.min.js` |
168
168
 
169
169
  ### **Smart Contract & Development**
170
170
  | Module | Size | Use Case | CDN |
171
171
  |--------|------|----------|-----|
172
- | **bsv-smartcontract.min.js** | 141KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@9.13.0/bsv-smartcontract.min.js` |
173
- | **bsv-covenant.min.js** | 35KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.13.0/bsv-covenant.min.js` |
174
- | **bsv-script-helper.min.js** | 33KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.13.0/bsv-script-helper.min.js` |
175
- | **bsv-security.min.js** | 32KB | Security enhancements | `unpkg.com/@smartledger/bsv@9.13.0/bsv-security.min.js` |
172
+ | **bsv-smartcontract.min.js** | 141KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@9.15.0/bsv-smartcontract.min.js` |
173
+ | **bsv-covenant.min.js** | 35KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.15.0/bsv-covenant.min.js` |
174
+ | **bsv-script-helper.min.js** | 33KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.15.0/bsv-script-helper.min.js` |
175
+ | **bsv-security.min.js** | 32KB | Security enhancements | `unpkg.com/@smartledger/bsv@9.15.0/bsv-security.min.js` |
176
176
 
177
177
  ### **Legal & Compliance**
178
178
  | Module | Size | Use Case | CDN |
179
179
  |--------|------|----------|-----|
180
- | **bsv-ltp.min.js** | 541KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@9.13.0/bsv-ltp.min.js` |
181
- | **bsv-gdaf.min.js** | 1061KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@9.13.0/bsv-gdaf.min.js` |
180
+ | **bsv-ltp.min.js** | 542KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@9.15.0/bsv-ltp.min.js` |
181
+ | **bsv-gdaf.min.js** | 1062KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@9.15.0/bsv-gdaf.min.js` |
182
182
 
183
183
  ### **Advanced Cryptography**
184
184
  | Module | Size | Use Case | CDN |
185
185
  |--------|------|----------|-----|
186
- | **bsv-shamir.min.js** | 177KB | Threshold Cryptography | `unpkg.com/@smartledger/bsv@9.13.0/bsv-shamir.min.js` |
186
+ | **bsv-shamir.min.js** | 177KB | Threshold Cryptography | `unpkg.com/@smartledger/bsv@9.15.0/bsv-shamir.min.js` |
187
187
 
188
188
  ### **Utilities**
189
189
  | Module | Size | Use Case | CDN |
190
190
  |--------|------|----------|-----|
191
- | **bsv-ecies.min.js** | 137KB | Encryption | `unpkg.com/@smartledger/bsv@9.13.0/bsv-ecies.min.js` |
192
- | **bsv-message.min.js** | 34KB | Message signing | `unpkg.com/@smartledger/bsv@9.13.0/bsv-message.min.js` |
193
- | **bsv-mnemonic.min.js** | 320KB | HD wallets | `unpkg.com/@smartledger/bsv@9.13.0/bsv-mnemonic.min.js` |
191
+ | **bsv-ecies.min.js** | 137KB | Encryption | `unpkg.com/@smartledger/bsv@9.15.0/bsv-ecies.min.js` |
192
+ | **bsv-message.min.js** | 34KB | Message signing | `unpkg.com/@smartledger/bsv@9.15.0/bsv-message.min.js` |
193
+ | **bsv-mnemonic.min.js** | 320KB | HD wallets | `unpkg.com/@smartledger/bsv@9.15.0/bsv-mnemonic.min.js` |
194
194
  ```html
195
- <script src="https://unpkg.com/@smartledger/bsv@9.13.0/bsv.min.js"></script>
195
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv.min.js"></script>
196
196
  <script>
197
197
  const key = bsv.PrivateKey.fromRandom()
198
198
  </script>
@@ -240,4 +240,4 @@ MIT
240
240
 
241
241
  ---
242
242
 
243
- **SmartLedger-BSV v9.13.0**
243
+ **SmartLedger-BSV v9.15.0**