@smartledger/bsv 9.14.0 → 9.16.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 +160 -0
- package/README.md +19 -19
- package/bsv-gdaf.min.js +29 -29
- package/bsv-ltp.min.js +22 -22
- package/bsv-smartcontract.min.js +1 -1
- package/bsv.bundle.js +29 -29
- package/bsv.d.ts +7 -0
- package/bsv.min.js +29 -29
- package/docs/AUDIT_SCOPE.md +6 -6
- package/docs/BRC220_BATCH_LEAF_AMENDMENT.md +16 -4
- package/docs/BRC220_CERTIFICATE_FIELDS_AMENDMENT.md +11 -4
- package/docs/BRC220_PLAN.md +5 -2
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/audit-rfq/cure53.txt +1 -1
- package/docs/audit-rfq/ncc-group.txt +1 -1
- package/docs/audit-rfq/trail-of-bits.txt +1 -1
- package/docs/getting-started/INSTALLATION.md +23 -23
- package/docs/getting-started/QUICK_START.md +7 -7
- package/docs/migration/FROM_BSV_1_5_6.md +5 -5
- package/lib/script/interpreter.js +131 -39
- package/package.json +9 -5
- package/tools/gen-blind-spot-vectors.js +422 -0
- package/tools/minimal_reproduction.js +1 -1
- package/tools/opcode_map.js +11 -4
- package/tools/simple_real_tx.js +1 -1
- package/tools/sv-vector-coverage.js +174 -0
- package/tools/sv-vector-harness.js +19 -4
- package/version.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,166 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [9.16.0] - 2026-10-01
|
|
11
|
+
|
|
12
|
+
### Security — `OP_CHECKMULTISIG`'s counts were decoded with the era's length, not four bytes
|
|
13
|
+
|
|
14
|
+
Both counts used `maxScriptNumLength()`, which is 750,000 bytes after Genesis and 32,000,000 after
|
|
15
|
+
Chronicle. The node hardcodes four and says why:
|
|
16
|
+
|
|
17
|
+
```cpp
|
|
18
|
+
// initialize to max size of CScriptNum::MAXIMUM_ELEMENT_SIZE (4 bytes)
|
|
19
|
+
// because only 4 byte integers are supported by OP_CHECKMULTISIG / OP_CHECKMULTISIGVERIFY
|
|
20
|
+
nKeysCountSigned = CScriptNum(stack.stacktop(-i).GetElement(), requireMinimal,
|
|
21
|
+
CScriptNum::MAXIMUM_ELEMENT_SIZE).getint();
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
These two are the **only** operand decodes in the interpreter that do not take the era's length.
|
|
25
|
+
Every other one does, which is precisely why passing it here looked correct. The consequence was a
|
|
26
|
+
**false accept**: a 5-byte key or signature count that the node refuses as `SCRIPTNUM_OVERFLOW` in
|
|
27
|
+
every era was accepted. Present in 9.15.0 and earlier.
|
|
28
|
+
|
|
29
|
+
### Fixed — the Magnetic opcodes needed a flag the node does not have
|
|
30
|
+
|
|
31
|
+
`OP_MUL`, `OP_LSHIFT`, `OP_RSHIFT` and `OP_INVERT` were refused unless
|
|
32
|
+
`SCRIPT_ENABLE_MAGNETIC_OPCODES` was set. `IsOpcodeDisabled` disables `OP_2MUL` and `OP_2DIV` and
|
|
33
|
+
nothing else, so those four execute in every era the node can validate. Measured against the
|
|
34
|
+
node's own corpus with the library-only opcode bits withheld: **77 rows refused as
|
|
35
|
+
`DISABLED_OPCODE`**, every one a false reject. Fail-closed, so nothing was wrongly accepted, but
|
|
36
|
+
they are spends the network accepts.
|
|
37
|
+
|
|
38
|
+
This landed after the 9.15.0 tag, so 9.15.0 shipped without it — and `@smartledger/bsv-core@1.0.2`
|
|
39
|
+
was briefly more correct than the published library. That is the reason this release exists now
|
|
40
|
+
rather than later.
|
|
41
|
+
|
|
42
|
+
Both flag constants remain exported and accepted; setting either is redundant.
|
|
43
|
+
|
|
44
|
+
### Fixed — a disabled opcode in an unexecuted branch
|
|
45
|
+
|
|
46
|
+
The era decides, not the branch. The node reads
|
|
47
|
+
`IsOpcodeDisabled(opcode, era) && (!utxo_after_genesis || fExec)`, so an unexecuted disabled opcode
|
|
48
|
+
is fatal before Genesis and harmless after it. The behaviour was already right in all four
|
|
49
|
+
combinations; a comment claimed it was fatal in every era, and no test pinned any of it. Both
|
|
50
|
+
fixed.
|
|
51
|
+
|
|
52
|
+
### Added — portable cross-implementation vectors, now 25
|
|
53
|
+
|
|
54
|
+
`test/data/blind-spot-vectors.json` carries raw-byte vectors for five defect classes the node's
|
|
55
|
+
own corpus cannot reach, with the node's flag names, its error-name table vendored beside them,
|
|
56
|
+
and a generator so the file is a build product rather than hand-maintained.
|
|
57
|
+
|
|
58
|
+
They are not decorative: they found a false accept in the official
|
|
59
|
+
[`bsv-blockchain/go-sdk`](https://github.com/bsv-blockchain/go-sdk/issues/373) and five unguarded
|
|
60
|
+
malleability sites in an independent Rust implementation. `@bsv/sdk` 2.8.11 agrees with all of
|
|
61
|
+
them. Four rows covering the Magnetic opcodes were added by a second session after it observed
|
|
62
|
+
that the original set could not have caught the gate above.
|
|
63
|
+
|
|
64
|
+
### Added — `npm run vectors:sv-coverage`, which reports what a corpus cannot test
|
|
65
|
+
|
|
66
|
+
A 1483/1483 score says we agree with the corpus; it says nothing about rules the corpus never
|
|
67
|
+
exercises, and the percentage cannot tell the two apart. The report names them on four axes:
|
|
68
|
+
verdicts no row asks for, masking flag pairs never set together, how often each flag appears at all
|
|
69
|
+
against whether mainnet requires it, and rules the row format cannot express. Run against the
|
|
70
|
+
node's vectors it names both defect classes released in 9.15.0 — so it would have pointed at them
|
|
71
|
+
before either was found.
|
|
72
|
+
|
|
73
|
+
## [9.15.0] - 2026-09-29
|
|
74
|
+
|
|
75
|
+
### Security — `LOW_S` masked every STRICTENC signature check, on this library's own default flags
|
|
76
|
+
|
|
77
|
+
`checkSignatureEncoding` chained its three checks with `else if`. The node has three
|
|
78
|
+
independent `if`s. `SCRIPT_VERIFY_LOW_S` is set by both `mainnetFlags()` and
|
|
79
|
+
`currentConsensusFlags()`, so on the default path the LOW_S branch returned and the whole
|
|
80
|
+
STRICTENC block below it never ran. Three signatures the node refuses by name were accepted:
|
|
81
|
+
|
|
82
|
+
| signature | node | this library, before 9.15.0 |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| undefined hash type | `SIG_HASHTYPE` | **accepted** |
|
|
85
|
+
| no FORKID bit, where FORKID is required | `MUST_USE_FORKID` | **accepted** |
|
|
86
|
+
| Chronicle digest requested outside Chronicle | `ILLEGAL_CHRONICLE` | **accepted** |
|
|
87
|
+
|
|
88
|
+
This is the direction that costs money: a transaction the network rejects was reported valid.
|
|
89
|
+
The third case undoes the guard added for Chronicle — a signature whose type byte sets `0x20`
|
|
90
|
+
is read as asking for the original digest, and refusing it outright is what lets
|
|
91
|
+
`sighash()` route on the bit alone. Anyone verifying third-party transactions with
|
|
92
|
+
`mainnetFlags()` should treat 9.15.0 as a required upgrade.
|
|
93
|
+
|
|
94
|
+
The bug is inherited from the upstream `bsv`/`bitcore-lib` lineage, not introduced here, and
|
|
95
|
+
the node's own 1,483-row corpus cannot see it: not one row pairs `LOW_S` with a hash-type
|
|
96
|
+
expectation. It was found by transcribing `VerifyScript` against the C++ line by line rather
|
|
97
|
+
than reading the one line under repair.
|
|
98
|
+
|
|
99
|
+
### Fixed — Chronicle's malleability relaxations were not applied
|
|
100
|
+
|
|
101
|
+
Chronicle lets a transaction opt into malleability by using a **version above 1**. The node
|
|
102
|
+
then stops applying the rules that exist only to stop a signed transaction being rewritten in
|
|
103
|
+
flight — `EnforceNonMalleability(flags, checker.Version())`, at seven sites
|
|
104
|
+
(`interpreter.cpp` 285, 433, 801, 1493, 1643, 1666 and 2441). This library
|
|
105
|
+
applied all seven regardless, so it **refused transactions the network accepts**, on its own
|
|
106
|
+
default flags, for any transaction with `version > 1`:
|
|
107
|
+
|
|
108
|
+
`LOW_S`, `MINIMALDATA`, `MINIMALIF`, `NULLFAIL` (both `CHECKSIG` and `CHECKMULTISIG`),
|
|
109
|
+
`NULLDUMMY`, `SIGPUSHONLY` and `CLEANSTACK`.
|
|
110
|
+
|
|
111
|
+
The gate reads `SCRIPT_CHRONICLE` — the era of the block being built — not
|
|
112
|
+
`SCRIPT_UTXO_AFTER_CHRONICLE`, the era of the output being spent; Chronicle activated at block
|
|
113
|
+
943,816, so it is set for anything validated against today's chain. Every version at or below 1
|
|
114
|
+
is unaffected, and so is every flag set without Chronicle. Exposed as
|
|
115
|
+
`Interpreter#enforceNonMalleability()`, beside `isAfterGenesis()` and `isAfterChronicle()`.
|
|
116
|
+
|
|
117
|
+
The corpus cannot see this either: all 1,483 of its rows carry transaction version 1.
|
|
118
|
+
|
|
119
|
+
### Fixed — `SIGPUSHONLY` is a rule of an era, not of the flag alone
|
|
120
|
+
|
|
121
|
+
The node applies it post-Genesis, and under Chronicle only to a non-malleable version:
|
|
122
|
+
|
|
123
|
+
```cpp
|
|
124
|
+
if((IsGenesis(flags) && !IsChronicle(flags)) ||
|
|
125
|
+
(IsChronicle(flags) && !IsMalleableTxnVersion(checker.Version())))
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
It also never *sets* the flag outside that window — `InputScriptVerifyFlags` adds it only once
|
|
129
|
+
the block era is post-Genesis. Before Genesis a non-push scriptSig was refused only where P2SH
|
|
130
|
+
demanded it, which this library still does.
|
|
131
|
+
|
|
132
|
+
### Fixed — `CLEANSTACK` required `P2SH` only before Genesis, and the harness was short a rule
|
|
133
|
+
|
|
134
|
+
The node requires the `P2SH` flag alongside `CLEANSTACK` in **every** era, including after
|
|
135
|
+
Genesis removed P2SH. This library carried a post-Genesis carve-out of its own, because the
|
|
136
|
+
corpus appeared to demand one. It does not — the node's harness adds the flag before calling
|
|
137
|
+
`VerifyScript`:
|
|
138
|
+
|
|
139
|
+
```cpp
|
|
140
|
+
if(flags & SCRIPT_VERIFY_CLEANSTACK) flags |= SCRIPT_VERIFY_P2SH; // DoTest
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
so the row naming `CLEANSTACK` alone never reaches that branch. `tools/sv-vector-harness.js`
|
|
144
|
+
was missing the adjustment, which ran that row under a flag set `VerifyScript` refuses
|
|
145
|
+
outright: it failed for the wrong reason and stopped testing clean stacks at all. A vector
|
|
146
|
+
file states the flags a row names, not the ones its runner adds.
|
|
147
|
+
|
|
148
|
+
### Changed — the one behaviour that tightens
|
|
149
|
+
|
|
150
|
+
Everything else here either refuses something the network refuses or accepts something it
|
|
151
|
+
accepts. This is the exception, stated plainly so nobody meets it by surprise: a flag word
|
|
152
|
+
carrying `CLEANSTACK` **without** `P2SH` used to verify after Genesis, and now returns false
|
|
153
|
+
with `SCRIPT_ERR_INVALID_FLAGS`, which is what the node does in every era.
|
|
154
|
+
|
|
155
|
+
It is not reachable through any flag set this library produces — `mainnetFlags()` and
|
|
156
|
+
`currentConsensusFlags()` both include `P2SH` — so only a hand-assembled flag word is
|
|
157
|
+
affected, and the fix is to add `SCRIPT_VERIFY_P2SH`, which is what the node's own test
|
|
158
|
+
harness does. It ships in a minor rather than waiting for the major because the alternative
|
|
159
|
+
is disagreeing with the node about which flag sets are valid; STABILITY.md § Consensus
|
|
160
|
+
tracking is the clause that allows it.
|
|
161
|
+
|
|
162
|
+
### Fixed — `CLEANSTACK` without `P2SH` threw an internal error
|
|
163
|
+
|
|
164
|
+
Those flags come from a caller, so the node names the problem
|
|
165
|
+
(`SCRIPT_ERR_INVALID_FLAGS`) rather than asserting. Throwing turned a verdict into a crash for
|
|
166
|
+
anyone verifying with `CLEANSTACK` alone. A flag set claiming a post-Chronicle UTXO that is not
|
|
167
|
+
post-Genesis is now refused the same way, as the node's `valid_flags` does, instead of being
|
|
168
|
+
evaluated from half an era.
|
|
169
|
+
|
|
10
170
|
## [9.14.0] - 2026-09-29
|
|
11
171
|
|
|
12
172
|
### Added — `minDifficulty`, because a work floor in hashes invites a unit error that fails open
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Bitcoin SV library with an interpreter-verified script engine.
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/@smartledger/bsv)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
[](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** | 1062KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.
|
|
159
|
-
| **bsv.bundle.js** | 1062KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.
|
|
158
|
+
| **bsv.min.js** | 1062KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.16.0/bsv.min.js` |
|
|
159
|
+
| **bsv.bundle.js** | 1062KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.16.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.
|
|
165
|
-
| **🟢 bsv-vcjwt.min.js** | 166KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@9.
|
|
166
|
-
| **🟢 bsv-statuslist.min.js** | 256KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@9.
|
|
167
|
-
| **🟢 bsv-anchor.min.js** | 164KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@9.
|
|
164
|
+
| **🟢 bsv-didweb.min.js** | 166KB | **DID:web generation** | `unpkg.com/@smartledger/bsv@9.16.0/bsv-didweb.min.js` |
|
|
165
|
+
| **🟢 bsv-vcjwt.min.js** | 166KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@9.16.0/bsv-vcjwt.min.js` |
|
|
166
|
+
| **🟢 bsv-statuslist.min.js** | 256KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@9.16.0/bsv-statuslist.min.js` |
|
|
167
|
+
| **🟢 bsv-anchor.min.js** | 164KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@9.16.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.
|
|
173
|
-
| **bsv-covenant.min.js** | 35KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.
|
|
174
|
-
| **bsv-script-helper.min.js** | 33KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.
|
|
175
|
-
| **bsv-security.min.js** | 32KB | Security enhancements | `unpkg.com/@smartledger/bsv@9.
|
|
172
|
+
| **bsv-smartcontract.min.js** | 141KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@9.16.0/bsv-smartcontract.min.js` |
|
|
173
|
+
| **bsv-covenant.min.js** | 35KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.16.0/bsv-covenant.min.js` |
|
|
174
|
+
| **bsv-script-helper.min.js** | 33KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.16.0/bsv-script-helper.min.js` |
|
|
175
|
+
| **bsv-security.min.js** | 32KB | Security enhancements | `unpkg.com/@smartledger/bsv@9.16.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** |
|
|
181
|
-
| **bsv-gdaf.min.js** | 1062KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@9.
|
|
180
|
+
| **bsv-ltp.min.js** | 542KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@9.16.0/bsv-ltp.min.js` |
|
|
181
|
+
| **bsv-gdaf.min.js** | 1062KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@9.16.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.
|
|
186
|
+
| **bsv-shamir.min.js** | 177KB | Threshold Cryptography | `unpkg.com/@smartledger/bsv@9.16.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.
|
|
192
|
-
| **bsv-message.min.js** | 34KB | Message signing | `unpkg.com/@smartledger/bsv@9.
|
|
193
|
-
| **bsv-mnemonic.min.js** | 320KB | HD wallets | `unpkg.com/@smartledger/bsv@9.
|
|
191
|
+
| **bsv-ecies.min.js** | 137KB | Encryption | `unpkg.com/@smartledger/bsv@9.16.0/bsv-ecies.min.js` |
|
|
192
|
+
| **bsv-message.min.js** | 34KB | Message signing | `unpkg.com/@smartledger/bsv@9.16.0/bsv-message.min.js` |
|
|
193
|
+
| **bsv-mnemonic.min.js** | 320KB | HD wallets | `unpkg.com/@smartledger/bsv@9.16.0/bsv-mnemonic.min.js` |
|
|
194
194
|
```html
|
|
195
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
195
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.16.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.
|
|
243
|
+
**SmartLedger-BSV v9.16.0**
|