@smartledger/bsv 9.8.0 → 9.9.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,100 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [9.9.0] - 2026-09-11
11
+
12
+ **NotaryHash interoperates with the BRC-220 reference implementation, without breaking
13
+ anything in 9.x.** Verification reads both certificate formats. `Certificate.build()`
14
+ writes the reference format given `format: 'reference'`; without it, it still writes
15
+ exactly what 9.8.0 wrote and warns once, as STABILITY.md requires. Against v9.8.0 the
16
+ public API gains 13 names and changes or removes none.
17
+
18
+ ### Fixed — NotaryHash verifies the certificates the BRC-220 reference implementation issues
19
+
20
+ 8.3.0 through 9.8.0 could not verify a single certificate the BRC-220 reference
21
+ implementation issued: `NotaryHash.verify` rejected every one with `unsupported version:
22
+ 1.0`, and the reference could not read this library's either. The cryptography agreed
23
+ throughout — `proofHash`, the signature digest, the RFC 6962 tree and the on-chain record
24
+ are byte-identical — and only the JSON differed. BRC-220 lists a certificate's required
25
+ fields but not their values, and 8.3.0 filled that gap from this implementation alone.
26
+ Every test passed, because every test built its certificates here.
27
+
28
+ | field | 8.3.0–9.8.0 format | reference format |
29
+ | --- | --- | --- |
30
+ | `version` | `1` | `"1.0"` |
31
+ | `mode` | `0` / `1` / `2` | `"full"` / `"hybrid"` |
32
+ | a batch | `mode: 2` | `anchor.type: "batch"`; the mode stays full or hybrid |
33
+ | `encoding` | `"raw"` / `"der"` — the signature's byte form | `"hex"` / `"base64"` — how `publicKey` and `signature` are written |
34
+ | `anchor` | `{ txid, blockHeight }` | `{ type, network, txid, vout, blockHeight, blockTime }` |
35
+ | `merkle.path` | bare hashes | `{ hash, side }`, leaf upward |
36
+
37
+ Verification now reads both formats — `verify()` reports `legacy: true` for the old one —
38
+ and accepts what the reference accepts, each of which 9.8.0 refused:
39
+
40
+ - **High-S ECDSA signatures.** The reference accepts them deliberately. It is safe:
41
+ `proofHash` covers the exact signature bytes, so the malleated form of a signature is a
42
+ *different* certificate, never a forgery of this one — a test asserts exactly that.
43
+ - **DER signatures**, told apart from 64-byte `r ‖ s` by the bytes, and **65-byte
44
+ uncompressed public keys**.
45
+ - **Base64 fields**, including the URL-safe alphabet and missing padding, as the
46
+ reference's `Buffer.from` reads them. Characters outside the alphabet are refused, where
47
+ `Buffer.from` would skip them and decode a corrupted field to different bytes.
48
+ - **A merkle proof on a direct anchor** is checked when present, as the reference checks
49
+ it: accepted if it folds to its stated root, refused if not.
50
+
51
+ One check is added: the supplied header must be the block `spv.blockHash` names. A header
52
+ the proof folds to that is some other block left the certificate's own statement of where
53
+ it was mined unchecked. The reference checks the same. A certificate that passed 9.8.0
54
+ fails it only if its `spv.blockHash` names a different block from the header supplied.
55
+
56
+ ### Deprecated — the default format of `NotaryHash.Certificate.build()`
57
+
58
+ `build()` takes a `format`. `'reference'` (`NotaryHash.Certificate.FORMAT.REFERENCE`)
59
+ writes the reference format; `'legacy'` writes the 8.3.0–9.8.0 one. Omitting it writes the
60
+ legacy format — byte for byte what 9.8.0 wrote, pinned by test against certificates the
61
+ 9.8.0 code itself built — and warns once. **The default becomes `'reference'` in 10.0.0.**
62
+
63
+ ```js
64
+ NotaryHash.Certificate.build({ ...params, format: 'reference' })
65
+ // { version: '1.0', mode: 'full', encoding: 'hex', anchor: { type: 'direct', … }, … }
66
+ ```
67
+
68
+ Per STABILITY.md this is a minor, so what `build()` returns does not change in 9.x, and
69
+ code reading `cert.mode === NotaryHash.MODE.FULL` keeps working. It is the shape of the
70
+ LTP claim canonicalization in 9.2.0, for a similar reason: the default is deterministic and
71
+ agrees with itself, and is not interoperable. The cost here is immediate rather than
72
+ latent — no other BRC-220 verifier can check a default-built certificate — so pass
73
+ `format: 'reference'` for anything issued to someone else. An unrecognised `format` throws
74
+ rather than falling back.
75
+
76
+ `Certificate.VERSION` is still `1`, what the default writes; `Certificate.REFERENCE_VERSION`
77
+ is `'1.0'`. `Certificate.ENCODING` gains `HEX` and `BASE64` beside `RAW` and `DER`.
78
+
79
+ ### Added
80
+
81
+ - `test/notaryhash/reference_certs.js`, over ten certificates produced by the reference
82
+ implementation's own code — full and hybrid, hex and base64, a DER signature, a high-S
83
+ signature, an uncompressed key, and a five-leaf batch. Each verifies here, and each is
84
+ rebuilt byte for byte by `Certificate.build({ format: 'reference' })`. The reference's
85
+ batch is the same tree as the BRC-220 batch vector: same root, same paths.
86
+ - `test/data/notaryhash-9.8.0-certs.json`: certificates built by the 9.8.0 code, which the
87
+ 9.x default must reproduce exactly.
88
+ - `Certificate.FORMAT`, `REFERENCE_VERSION`, `MODE`, `ANCHOR_TYPE`, `DEFAULT_NETWORK`,
89
+ `isLegacy`, `normalize`, `decodeBytes` and `toProofInput`; `Merkle.auditPath`,
90
+ `pathSides`, `rootFromPath` and `verifyAuditPath` for the sided path form.
91
+ - `bsv.d.ts` declares `NotaryHash` in full, with `build()` overloaded on `format`. It was
92
+ 48 of 56 names undeclared, so it could not be used from TypeScript at all; the
93
+ declaration gate now holds it at zero.
94
+
95
+ ### Docs
96
+
97
+ - `docs/BRC220_ENCODING_AMENDMENT.md` is **withdrawn**. It proposed `"raw"`/`"der"` and
98
+ mandatory low-S; the reference contradicts it on every point. It was never filed.
99
+ - `docs/BRC220_BATCH_LEAF_AMENDMENT.md` was confirmed against the reference and filed as
100
+ [bsv-blockchain/BRCs#246](https://github.com/bsv-blockchain/BRCs/pull/246).
101
+ - `test/data/brc220-batch-vector.json` records `encoding: "hex"` and sided paths. The root,
102
+ the rejected-reading root, and every `proofHash` and signature are unchanged.
103
+
10
104
  ## [9.8.0] - 2026-09-08
11
105
 
12
106
  **No runtime change.** `git diff v9.7.0..HEAD -- lib/` is empty. Four bundles do differ,
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.8.0-blue.svg)](https://www.npmjs.com/package/@smartledger/bsv)
5
+ [![Version](https://img.shields.io/badge/version-9.9.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** | 1046KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.8.0/bsv.min.js` |
159
- | **bsv.bundle.js** | 1046KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.8.0/bsv.bundle.js` |
158
+ | **bsv.min.js** | 1056KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.9.0/bsv.min.js` |
159
+ | **bsv.bundle.js** | 1056KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.9.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.8.0/bsv-didweb.min.js` |
165
- | **🟢 bsv-vcjwt.min.js** | 166KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@9.8.0/bsv-vcjwt.min.js` |
166
- | **🟢 bsv-statuslist.min.js** | 256KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@9.8.0/bsv-statuslist.min.js` |
167
- | **🟢 bsv-anchor.min.js** | 164KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@9.8.0/bsv-anchor.min.js` |
164
+ | **🟢 bsv-didweb.min.js** | 166KB | **DID:web generation** | `unpkg.com/@smartledger/bsv@9.9.0/bsv-didweb.min.js` |
165
+ | **🟢 bsv-vcjwt.min.js** | 166KB | **VC-JWT issue/verify** | `unpkg.com/@smartledger/bsv@9.9.0/bsv-vcjwt.min.js` |
166
+ | **🟢 bsv-statuslist.min.js** | 256KB | **StatusList2021 revocation** | `unpkg.com/@smartledger/bsv@9.9.0/bsv-statuslist.min.js` |
167
+ | **🟢 bsv-anchor.min.js** | 164KB | **BSV anchoring (hash-only)** | `unpkg.com/@smartledger/bsv@9.9.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.8.0/bsv-smartcontract.min.js` |
173
- | **bsv-covenant.min.js** | 35KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.8.0/bsv-covenant.min.js` |
174
- | **bsv-script-helper.min.js** | 33KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.8.0/bsv-script-helper.min.js` |
175
- | **bsv-security.min.js** | 32KB | Security enhancements | `unpkg.com/@smartledger/bsv@9.8.0/bsv-security.min.js` |
172
+ | **bsv-smartcontract.min.js** | 141KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@9.9.0/bsv-smartcontract.min.js` |
173
+ | **bsv-covenant.min.js** | 35KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.9.0/bsv-covenant.min.js` |
174
+ | **bsv-script-helper.min.js** | 33KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.9.0/bsv-script-helper.min.js` |
175
+ | **bsv-security.min.js** | 32KB | Security enhancements | `unpkg.com/@smartledger/bsv@9.9.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** | 540KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@9.8.0/bsv-ltp.min.js` |
181
- | **bsv-gdaf.min.js** | 1046KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@9.8.0/bsv-gdaf.min.js` |
180
+ | **bsv-ltp.min.js** | 540KB | Legal Token Protocol | `unpkg.com/@smartledger/bsv@9.9.0/bsv-ltp.min.js` |
181
+ | **bsv-gdaf.min.js** | 1056KB | Digital Identity & Attestation | `unpkg.com/@smartledger/bsv@9.9.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.8.0/bsv-shamir.min.js` |
186
+ | **bsv-shamir.min.js** | 177KB | Threshold Cryptography | `unpkg.com/@smartledger/bsv@9.9.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.8.0/bsv-ecies.min.js` |
192
- | **bsv-message.min.js** | 34KB | Message signing | `unpkg.com/@smartledger/bsv@9.8.0/bsv-message.min.js` |
193
- | **bsv-mnemonic.min.js** | 320KB | HD wallets | `unpkg.com/@smartledger/bsv@9.8.0/bsv-mnemonic.min.js` |
191
+ | **bsv-ecies.min.js** | 137KB | Encryption | `unpkg.com/@smartledger/bsv@9.9.0/bsv-ecies.min.js` |
192
+ | **bsv-message.min.js** | 34KB | Message signing | `unpkg.com/@smartledger/bsv@9.9.0/bsv-message.min.js` |
193
+ | **bsv-mnemonic.min.js** | 320KB | HD wallets | `unpkg.com/@smartledger/bsv@9.9.0/bsv-mnemonic.min.js` |
194
194
  ```html
195
- <script src="https://unpkg.com/@smartledger/bsv@9.8.0/bsv.min.js"></script>
195
+ <script src="https://unpkg.com/@smartledger/bsv@9.9.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.8.0**
243
+ **SmartLedger-BSV v9.9.0**