@smartledger/bsv 9.11.1 → 9.12.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 +83 -0
- package/README.md +19 -19
- package/bsv-gdaf.min.js +50 -50
- package/bsv-ltp.min.js +1 -1
- package/bsv-smartcontract.min.js +1 -1
- package/bsv.bundle.js +50 -50
- package/bsv.d.ts +35 -2
- package/bsv.min.js +50 -50
- package/docs/AUDIT_SCOPE.md +7 -7
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/audit-rfq/cure53.txt +2 -2
- package/docs/audit-rfq/ncc-group.txt +2 -2
- package/docs/audit-rfq/trail-of-bits.txt +2 -2
- 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/gdaf/smartledger-anchor.js +4 -1
- package/lib/notaryhash/index.js +64 -12
- package/lib/script/script.js +14 -2
- package/lib/spv/headerchain.js +31 -10
- package/lib/spv/index.js +1 -0
- package/lib/spv/merkleproof.js +168 -16
- package/package.json +1 -1
- package/version.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,89 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [9.12.0] - 2026-09-29
|
|
11
|
+
|
|
12
|
+
**A block header is no longer believed about the difficulty it declares.** A forged header cost
|
|
13
|
+
one attempt to mine and passed SPV verification, proof of work enabled. The declared target is
|
|
14
|
+
now capped, and `powLimit`, `minWork` and `blockHashAtHeight` are new options. Regtest headers
|
|
15
|
+
need `powLimit: 0x207fffff`; mainnet and testnet are unaffected.
|
|
16
|
+
|
|
17
|
+
### Fixed — a forged block header passed SPV verification, because it declared its own difficulty
|
|
18
|
+
|
|
19
|
+
`BlockHeader.validProofOfWork()` answers one question: does the hash meet the target written in
|
|
20
|
+
this header's own `bits`? Nothing capped that target, so a header could declare any difficulty it
|
|
21
|
+
liked and then meet it. Measured against 9.11.2:
|
|
22
|
+
|
|
23
|
+
| declared `bits` | nonces needed to mine it | `NotaryHash.verify(cert, { header })` |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
| `0x1d00ffff` (mainnet, difficulty 1) | over 2,000,000, not found | correctly refused |
|
|
26
|
+
| `0x2000ffff` | 120 | **`valid: true`** |
|
|
27
|
+
| `0x2100ffff` | **1** | **`valid: true`** |
|
|
28
|
+
|
|
29
|
+
Proof of work was *enabled* in those rows. `SPV.verifyHeaderChain` accepted a whole chain of such
|
|
30
|
+
headers, which its own comment warned about. It matters wherever a header reaches the verifier
|
|
31
|
+
from the same place as the thing it is meant to check independently — an offline certificate and
|
|
32
|
+
header bundle, or a provider that serves both.
|
|
33
|
+
|
|
34
|
+
**The declared target is now capped.** `SPV.verifyTxInclusion`, `SPV.verifyHeaderChain`,
|
|
35
|
+
`NotaryHash.verify`/`verifyAnchorSPV` and the GDAF anchor take `powLimit`, the easiest target a
|
|
36
|
+
header may declare, defaulting to `SPV.POW_LIMIT_BITS` (`0x1d00ffff`, difficulty 1 — the
|
|
37
|
+
proof-of-work limit of mainnet and testnet). `minWork` demands more than the cap if you want a
|
|
38
|
+
difficulty floor. `bits` values no header may use — negative, zero, or overflowing — are refused
|
|
39
|
+
outright: `targetFromBits` transcribes Bitcoin's `SetCompact` and `CheckProofOfWork`, none of
|
|
40
|
+
whose rules `getTargetDifficulty` implements (it also shifts the wrong way for a size below 4,
|
|
41
|
+
which is why it is not used here).
|
|
42
|
+
|
|
43
|
+
**Two smaller holes closed with it.** A header is now taken as exactly 80 bytes and re-parsed, so
|
|
44
|
+
every checked field comes from one snapshot and an object merely stating a `merkleRoot` is refused
|
|
45
|
+
by name instead of failing with `header.validProofOfWork is not a function`. And
|
|
46
|
+
`NotaryHash.verify` takes `blockHashAtHeight`: no amount of proof of work detects an orphan,
|
|
47
|
+
because a block that lost a race carries real work, so a caller with its own chain view says which
|
|
48
|
+
block that height holds.
|
|
49
|
+
|
|
50
|
+
**What this rejects that 9.11.2 accepted:** forged headers, and honest regtest headers, which
|
|
51
|
+
declare `0x207fffff` — pass `powLimit: 0x207fffff` for those, as `test/gdaf/anchor_spv.js` now
|
|
52
|
+
does. `requirePow: false` still switches off every work check together. Mainnet and testnet
|
|
53
|
+
headers are unaffected; the genesis block verifies under the default.
|
|
54
|
+
|
|
55
|
+
Retargeting is still not validated, and this is still not a substitute for a chain source: a fork
|
|
56
|
+
whose headers each clear the limit remains possible, which is what `trustedHash` and
|
|
57
|
+
`blockHashAtHeight` are for.
|
|
58
|
+
|
|
59
|
+
Found while mirroring a hardening of the BRC-220 reference implementation, whose difficulty floor
|
|
60
|
+
prompted the check.
|
|
61
|
+
|
|
62
|
+
## [9.11.2] - 2026-09-17
|
|
63
|
+
|
|
64
|
+
**A patch: an empty push is no longer lost when a script is written as ASM or as a string.** No API change.
|
|
65
|
+
|
|
66
|
+
### Fixed — an empty push written with OP_PUSHDATA survives being written as text
|
|
67
|
+
|
|
68
|
+
An empty push encoded with `OP_PUSHDATA1`, `OP_PUSHDATA2` or `OP_PUSHDATA4` (`4c00`, `4d0000`,
|
|
69
|
+
`4e00000000`) was written badly by both text forms:
|
|
70
|
+
|
|
71
|
+
| script `514c0051` | 9.11.1 | now |
|
|
72
|
+
| --- | --- | --- |
|
|
73
|
+
| `toASM()` | `OP_1 OP_1`: the push is gone, so it reads back as `5151`, one stack element fewer | `OP_1 0 OP_1`, read back as `510051` |
|
|
74
|
+
| `toString()` | `OP_1 OP_PUSHDATA1 OP_1`, which `fromString` cannot read | `OP_1 OP_PUSHDATA1 0 0x OP_1`, read back as `514c0051` |
|
|
75
|
+
|
|
76
|
+
ASM writes every push in its minimal form, and the minimal empty push is `OP_0`, so the ASM
|
|
77
|
+
now does what the script does. `toString` keeps the exact encoding.
|
|
78
|
+
|
|
79
|
+
The same fault hid the empty push built by `Script#add(Buffer.alloc(0))`, and so by
|
|
80
|
+
`Script.buildDataOut('')` and `buildSafeDataOut('')`. The chunk serializes to `0x00`, but both
|
|
81
|
+
text forms wrote nothing for it: `buildDataOut('')` is `6a00` and its `toString()` was
|
|
82
|
+
`OP_RETURN`, which reads back as `6a`. It is now `OP_RETURN OP_0` (ASM `OP_RETURN 0`), the text
|
|
83
|
+
`Script.fromHex('6a00')` already produced. Four tests had pinned the invisible form; they now
|
|
84
|
+
assert the text reads back as the script.
|
|
85
|
+
|
|
86
|
+
No reader changes: `fromString` already read `OP_PUSHDATA1 0 0x`. Of 4,000 generated scripts
|
|
87
|
+
mixing both shapes with ordinary pushes and opcodes, the 909 whose text changed all contain an
|
|
88
|
+
empty push, and every one of their new texts reads back exactly; every text 9.11.1 wrote is read
|
|
89
|
+
the same way (8,000 texts).
|
|
90
|
+
|
|
91
|
+
Reported by the scriptmin work (codenlighten/scriptmin#4).
|
|
92
|
+
|
|
10
93
|
## [9.11.1] - 2026-09-17
|
|
11
94
|
|
|
12
95
|
**A patch: a script written as ASM or as a string reads back as the same script.** No API change.
|
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** |
|
|
159
|
-
| **bsv.bundle.js** |
|
|
158
|
+
| **bsv.min.js** | 1060KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.12.0/bsv.min.js` |
|
|
159
|
+
| **bsv.bundle.js** | 1060KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.12.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.12.0/bsv-didweb.min.js` |
|
|
165
|
+
| **🟢 bsv-vcjwt.min.js** | 166KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@9.12.0/bsv-vcjwt.min.js` |
|
|
166
|
+
| **🟢 bsv-statuslist.min.js** | 256KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@9.12.0/bsv-statuslist.min.js` |
|
|
167
|
+
| **🟢 bsv-anchor.min.js** | 164KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@9.12.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.12.0/bsv-smartcontract.min.js` |
|
|
173
|
+
| **bsv-covenant.min.js** | 35KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.12.0/bsv-covenant.min.js` |
|
|
174
|
+
| **bsv-script-helper.min.js** | 33KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.12.0/bsv-script-helper.min.js` |
|
|
175
|
+
| **bsv-security.min.js** | 32KB | Security enhancements | `unpkg.com/@smartledger/bsv@9.12.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.
|
|
181
|
-
| **bsv-gdaf.min.js** |
|
|
180
|
+
| **bsv-ltp.min.js** | 541KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@9.12.0/bsv-ltp.min.js` |
|
|
181
|
+
| **bsv-gdaf.min.js** | 1060KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@9.12.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.12.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.12.0/bsv-ecies.min.js` |
|
|
192
|
+
| **bsv-message.min.js** | 34KB | Message signing | `unpkg.com/@smartledger/bsv@9.12.0/bsv-message.min.js` |
|
|
193
|
+
| **bsv-mnemonic.min.js** | 320KB | HD wallets | `unpkg.com/@smartledger/bsv@9.12.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.12.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.12.0**
|