@smartledger/bsv 9.22.0 → 9.23.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,101 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [9.23.0] - 2026-10-07
11
+
12
+ ### Fixed — the GDAF class could not generate or verify a membership proof at all
13
+
14
+ `bsv.GDAF` exposes what `index.js` calls "Direct Access Methods (for easier developer experience)":
15
+ thin wrappers that forward to the `ZKProver` module. **Four of them forwarded the wrong arguments**,
16
+ so the documented class-level API was inert.
17
+
18
+ | call through `new bsv.GDAF()` | before | now |
19
+ |---|---|---|
20
+ | `generateMembershipProof(set, value)` | threw `Set must be array` | returns a proof |
21
+ | `verifyMembershipProof(proof, opening, set)` | `false` for every proof | verifies |
22
+ | `verifyRangeProof(proof, min, max, opening)` | `false` for every proof | verifies |
23
+ | `verifyAgeProof(proof, requiredAge, opening)` | an issuer DID arrived as the opening | verifies |
24
+
25
+ Two separate drifts, both between a wrapper and the module it delegates to:
26
+
27
+ - `generateMembershipProof` has taken `(set, value, salt)` in the module **since v5.4.0**, while the
28
+ wrapper passed `(value, validSet, nonce)` — the first two arguments swapped. The set arrived as the
29
+ value, so `checkArgument(Array.isArray(set))` threw and **no proof could be generated through the
30
+ class at any version since 5.4.0**.
31
+ - `verifyMembershipProof` and `verifyRangeProof` gained the verifier-supplied set and the opening in
32
+ **9.20.0**, when the forgeable verifiers were fixed. The wrappers were not updated, so the module
33
+ received `set`/`opening` as `undefined` and its own guard — *"without a verifier-supplied set and an
34
+ opening there is nothing to check the prover's array against"* — answered `false` for **every**
35
+ proof, genuine or forged.
36
+
37
+ **Nothing was accepted that should have been refused.** All four failed closed: three returned
38
+ `false` and one threw. The 9.20.0 and 9.22.0 security fixes are unaffected, and the original
39
+ forgery is still refused through both paths. The defect was that the class API verified nothing
40
+ rather than that it verified wrongly.
41
+
42
+ **Why no test caught it:** every proof test called the module directly
43
+ (`require('lib/gdaf/zk-prover')`), never the class wrapper, so the wrappers had no coverage at all.
44
+ The new `test/gdaf/wrapper_signatures.js` closes that two ways — five tests exercise the class path
45
+ end to end, and a **general guard compares every delegating wrapper to its target by parameter
46
+ name**, so the next signature change on either side fails the suite instead of silently disabling a
47
+ verifier.
48
+
49
+ Found while answering a consumer session's question about which version to pin.
50
+
51
+ ### Changed — the class-path signatures now mirror the module
52
+
53
+ `bsv.d.ts` documented the broken shapes and is corrected. The affected declarations are
54
+ `generateMembershipProof(set, value, salt?)`, `verifyMembershipProof(proof, opening, set)`,
55
+ `verifyRangeProof(proof, min, max, opening)` and `verifyAgeProof(proof, requiredAge, opening)`.
56
+ `api-surface.json` records the two arity changes.
57
+
58
+ This is a minor release because those public signatures change, but no working call can break: the
59
+ old shapes threw or returned `false` unconditionally, so nothing could have depended on a correct
60
+ result from them.
61
+
62
+ ## [9.22.1] - 2026-10-06
63
+
64
+ ### Changed — signing many inputs is no longer quadratic in the number of inputs
65
+
66
+ No behavioural change. **Verified byte-identical**: the same nine transactions signed before and
67
+ after produce the same bytes and the same txid, including the `SIGHASH_SINGLE` and `SIGHASH_NONE`
68
+ cases that take different preimage branches.
69
+
70
+ The FORKID preimage's `hashPrevouts`, `hashSequence` and `hashOutputs` were recomputed on every
71
+ sighash, and each costs a pass over all inputs or all outputs. They are **identical for every input
72
+ of a transaction**, so signing *n* inputs ran three O(n) digests *n* times:
73
+
74
+ | inputs | 9.22.0 | 9.22.1 |
75
+ |---|---|---|
76
+ | 100 | 0.9 s | 0.5 s |
77
+ | 1,000 | 10.7 s | 8.9 s |
78
+ | 3,000 | 70.1 s | 39.7 s |
79
+ | 5,000 | **194.2 s** | **~100 s** |
80
+
81
+ `Transaction#sign` now opens a cache for the duration of one call and removes it in a `finally`, so
82
+ nothing survives the call and **there is no invalidation to get wrong**. The alternative — memoizing
83
+ on the transaction and clearing at each of the 11 sites that mutate inputs or outputs — was rejected
84
+ for exactly that reason: a missed site yields a *wrong signature*, which is a different class of
85
+ failure from a stale fee.
86
+
87
+ The window covers the apply loop as well as signature collection, because `applySignature` →
88
+ `addSignature` **re-verifies** each signature before applying it, which recomputes the preimage —
89
+ measured larger than collection at 5,000 inputs (68.7 s against 50.3 s). Widening it is safe
90
+ because the apply loop only changes each input's *script*, and none of the three digests depends on
91
+ a script: `hashPrevouts` covers outpoints, `hashSequence` covers sequence numbers, `hashOutputs`
92
+ covers outputs.
93
+
94
+ `SIGHASH_SINGLE` is deliberately **not** cached: it hashes the one output at the input's index, so
95
+ it differs per input, and a shared value would sign every input over the same output. A test asserts
96
+ that `SIGHASH_SINGLE` still produces a distinct script per input.
97
+
98
+ **It is still superlinear** — per-input cost goes from 4.84 ms at 100 inputs to 20.50 ms at 5,000 —
99
+ so something else in the per-input path remains O(n). The signature re-verification on apply is the
100
+ largest remaining term. This release halves the cost; it does not make signing linear, and a
101
+ consolidation sweep over tens of thousands of coins will still feel it.
102
+
103
+ Found while answering a consumer that batches a daily settlement of up to 5,000 inputs.
104
+
10
105
  ## [9.22.0] - 2026-10-06
11
106
 
12
107
  ### Security — the membership commitment was over a non-injective encoding
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.22.0-blue.svg)](https://www.npmjs.com/package/@smartledger/bsv)
5
+ [![Version](https://img.shields.io/badge/version-9.23.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** | 1069KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.22.0/bsv.min.js` |
159
- | **bsv.bundle.js** | 1069KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.22.0/bsv.bundle.js` |
158
+ | **bsv.min.js** | 1070KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.23.0/bsv.min.js` |
159
+ | **bsv.bundle.js** | 1070KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.23.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.22.0/bsv-didweb.min.js` |
165
- | **🟢 bsv-vcjwt.min.js** | 166KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@9.22.0/bsv-vcjwt.min.js` |
166
- | **🟢 bsv-statuslist.min.js** | 256KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@9.22.0/bsv-statuslist.min.js` |
167
- | **🟢 bsv-anchor.min.js** | 164KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@9.22.0/bsv-anchor.min.js` |
164
+ | **🟢 bsv-didweb.min.js** | 166KB | **DID:web generation** | `unpkg.com/@smartledger/bsv@9.23.0/bsv-didweb.min.js` |
165
+ | **🟢 bsv-vcjwt.min.js** | 166KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@9.23.0/bsv-vcjwt.min.js` |
166
+ | **🟢 bsv-statuslist.min.js** | 256KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@9.23.0/bsv-statuslist.min.js` |
167
+ | **🟢 bsv-anchor.min.js** | 164KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@9.23.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.22.0/bsv-smartcontract.min.js` |
173
- | **bsv-covenant.min.js** | 35KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.22.0/bsv-covenant.min.js` |
174
- | **bsv-script-helper.min.js** | 33KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.22.0/bsv-script-helper.min.js` |
175
- | **bsv-security.min.js** | 32KB | Security enhancements | `unpkg.com/@smartledger/bsv@9.22.0/bsv-security.min.js` |
172
+ | **bsv-smartcontract.min.js** | 141KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@9.23.0/bsv-smartcontract.min.js` |
173
+ | **bsv-covenant.min.js** | 35KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.23.0/bsv-covenant.min.js` |
174
+ | **bsv-script-helper.min.js** | 33KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.23.0/bsv-script-helper.min.js` |
175
+ | **bsv-security.min.js** | 32KB | Security enhancements | `unpkg.com/@smartledger/bsv@9.23.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** | 544KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@9.22.0/bsv-ltp.min.js` |
181
- | **bsv-gdaf.min.js** | 1069KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@9.22.0/bsv-gdaf.min.js` |
180
+ | **bsv-ltp.min.js** | 544KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@9.23.0/bsv-ltp.min.js` |
181
+ | **bsv-gdaf.min.js** | 1070KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@9.23.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.22.0/bsv-shamir.min.js` |
186
+ | **bsv-shamir.min.js** | 177KB | Threshold Cryptography | `unpkg.com/@smartledger/bsv@9.23.0/bsv-shamir.min.js` |
187
187
 
188
188
  ### **Utilities**
189
189
  | Module | Size | Use Case | CDN |
190
190
  |--------|------|----------|-----|
191
- | **bsv-ecies.min.js** | 139KB | Encryption | `unpkg.com/@smartledger/bsv@9.22.0/bsv-ecies.min.js` |
192
- | **bsv-message.min.js** | 34KB | Message signing | `unpkg.com/@smartledger/bsv@9.22.0/bsv-message.min.js` |
193
- | **bsv-mnemonic.min.js** | 320KB | HD wallets | `unpkg.com/@smartledger/bsv@9.22.0/bsv-mnemonic.min.js` |
191
+ | **bsv-ecies.min.js** | 139KB | Encryption | `unpkg.com/@smartledger/bsv@9.23.0/bsv-ecies.min.js` |
192
+ | **bsv-message.min.js** | 34KB | Message signing | `unpkg.com/@smartledger/bsv@9.23.0/bsv-message.min.js` |
193
+ | **bsv-mnemonic.min.js** | 320KB | HD wallets | `unpkg.com/@smartledger/bsv@9.23.0/bsv-mnemonic.min.js` |
194
194
  ```html
195
- <script src="https://unpkg.com/@smartledger/bsv@9.22.0/bsv.min.js"></script>
195
+ <script src="https://unpkg.com/@smartledger/bsv@9.23.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.22.0**
243
+ **SmartLedger-BSV v9.23.0**