@smartledger/bsv 8.3.0 → 8.3.1

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.
@@ -0,0 +1,119 @@
1
+ # Proposed BRC-220 amendment: define the batch Merkle leaf
2
+
3
+ §On-chain record specifies *which* Merkle tree batch mode uses, but never says what goes
4
+ in a leaf. This proposes the definition, with the reasoning that led to it.
5
+
6
+ Prepared 2026-08-17 while implementing BRC-220 in `@smartledger/bsv`. The second gap of
7
+ this kind, after `encoding` — see [BRC220_ENCODING_AMENDMENT.md](BRC220_ENCODING_AMENDMENT.md).
8
+
9
+ ---
10
+
11
+ ## What the spec currently says
12
+
13
+ §On-chain record, batch (`kind = 2`):
14
+
15
+ > One transaction anchors many proofs under an RFC 6962 Merkle root, domain-separated
16
+ > (`leaf = SHA256(0x00 ‖ d)`, `node = SHA256(0x01 ‖ l ‖ r)`, split at the largest power of
17
+ > two `< n`, last leaf never duplicated).
18
+
19
+ That parenthetical identifies the **tree construction**: domain separation, the split
20
+ rule, and the no-duplication rule that separate RFC 6962 from Bitcoin's tree. `d`, `l` and
21
+ `r` are RFC 6962's own generic symbols — §2.1 of that RFC writes
22
+ `MTH({d(0)}) = SHA-256(0x00 || d(0))` — so the sentence is naming the tree, not defining
23
+ its contents.
24
+
25
+ **`d` is never bound to a value.** The word `canonicalBytes` occurs once in the entire
26
+ document, in the `proofHash` definition in §Canonical proof bytes; it does not appear in
27
+ the batch text. Neither does `proofHash`.
28
+
29
+ So this is an ambiguity, not a disagreement between spec and implementation. Two
30
+ good-faith implementers reading the same sentence can and did reach different answers:
31
+
32
+ | reading | leaf hash |
33
+ | --- | --- |
34
+ | `d` = the canonical proof bytes | `SHA-256(0x00 ‖ canonicalBytes)` |
35
+ | `d` = the proof's identifier | `SHA-256(0x00 ‖ proofHash)` = `SHA-256(0x00 ‖ SHA-256(canonicalBytes))` |
36
+
37
+ Both are second-preimage resistant, and the domain separation that gives RFC 6962 that
38
+ property is unaffected by which one is chosen. **They are equal in strength and produce
39
+ different roots.** A certificate built under one reading fails inclusion under the other,
40
+ with no error that points at the cause — the fold simply does not reach the root.
41
+
42
+ The published test vectors do not settle it: they cover a certificate-with-SPV-envelope
43
+ golden vector, `txidFromRawTx` against the Bitcoin genesis coinbase, and the SPV Merkle
44
+ fold against block 170. **None of them is a batch-mode vector**, so there is nothing to
45
+ conform to by example.
46
+
47
+ ---
48
+
49
+ ## Proposed text
50
+
51
+ Insert into **§On-chain record**, replacing the batch bullet's parenthetical.
52
+
53
+ > - **batch** (`kind = 2`): `"NOTARYHASH" | u8(1) | u8(2) | merkleRoot(32) | u32be(leafCount)`.
54
+ > One transaction anchors many proofs under an RFC 6962 Merkle root.
55
+ >
56
+ > The leaf datum `d` for a proof is its **`proofHash`** — the 32 bytes defined in
57
+ > §Canonical proof bytes — so a leaf is `SHA-256(0x00 ‖ proofHash)` and an internal node
58
+ > is `SHA-256(0x01 ‖ l ‖ r)`. Leaves are ordered as the batch was assembled, and
59
+ > `leafIndex` in the certificate's `merkle` object is that position. The tree splits at
60
+ > the largest power of two `< n` and the last leaf is never duplicated, per RFC 6962
61
+ > §2.1.
62
+ >
63
+ > Note that `d` is the **hash**, not the canonical bytes: a leaf is therefore
64
+ > `SHA-256(0x00 ‖ SHA-256(canonicalBytes))`. The two readings are equally sound
65
+ > cryptographically but produce different roots, so this is stated explicitly rather
66
+ > than left to RFC 6962's generic `d`.
67
+
68
+ ---
69
+
70
+ ## Why `proofHash` rather than the canonical bytes
71
+
72
+ Both are sound. The choice is on other grounds.
73
+
74
+ **A verifier already holds it.** `proofHash` is a required certificate field. A verifier
75
+ checking batch inclusion reads it directly and folds. Under the other reading it must
76
+ first reconstruct `canonicalBytes` — re-serialising `publicKey`, `signature`,
77
+ `createdAtUnix` and the rest with the exact length-prefix framing — before it can begin.
78
+ That is the whole `proofHash` computation, performed again, as a precondition for a check
79
+ that is supposed to be independent of it. The spec advertises a "dependency-light
80
+ standalone verifier"; this keeps the batch path genuinely light.
81
+
82
+ **It is what a batch anchors.** §On-chain record says a batch transaction "anchors many
83
+ proofs". `proofHash` *is* the proof's identity — it is the integrity root, the value the
84
+ full and hybrid records place on-chain, and the value §Verification checks a certificate
85
+ against. Batching identifiers rather than re-serialised bodies keeps batch mode
86
+ consistent with the other two modes rather than introducing a second notion of what
87
+ represents a proof.
88
+
89
+ **It matches the mode it exists alongside.** Hybrid mode already establishes that BRC-220
90
+ puts hashes on-chain where blobs would be large. Fixed 32-byte leaves keep batch memory
91
+ and proof sizes independent of signature scheme — which matters precisely for the
92
+ post-quantum algorithms §Motivation names, where `canonicalBytes` runs to kilobytes per
93
+ proof.
94
+
95
+ **The extra hash costs nothing.** One SHA-256 over 32 bytes per leaf, against a
96
+ re-serialisation per leaf under the alternative.
97
+
98
+ ---
99
+
100
+ ## Compatibility
101
+
102
+ `@smartledger/bsv` implements the `proofHash` reading as of 8.3.0, and from this change
103
+ states it in `lib/notaryhash/index.js` and enforces it in
104
+ `test/notaryhash/batch_leaf.js` — including a test that a tree built over `canonicalBytes`
105
+ is rejected, so the choice is checked rather than merely intended.
106
+
107
+ No deployed batch certificates are known to use the other reading. If any exist, they were
108
+ built against an ambiguous sentence and would need reissuing; batch mode is the least-used
109
+ of the three and this is the moment to fix it, before that stops being true.
110
+
111
+ ---
112
+
113
+ ## Recommended alongside
114
+
115
+ Publish a **batch-mode golden vector** with the other test vectors: a small tree — four
116
+ proofs, say — with the four `proofHash` values, the resulting root, and the inclusion path
117
+ for one leaf. One such vector removes this entire class of ambiguity for every future
118
+ implementer, in a way that no amount of prose reliably does. Its absence is why this
119
+ document is necessary.
@@ -173,6 +173,15 @@ summarising rather than anything in the document.
173
173
  - **The service is a role, not a requirement.** §What a certificate proves: "any party
174
174
  holding a valid (hash, signature, publicKey) triple may re-anchor it; the attestation
175
175
  remains valid". A self-notarizing caller producing its own certificate is conformant.
176
+ - **The batch Merkle leaf is NOT settled by the spec — it is a choice this
177
+ implementation made.** §On-chain record writes `leaf = SHA256(0x00 ‖ d)`, but that is
178
+ RFC 6962's own generic notation for the construction and `d` is never bound to a value.
179
+ `canonicalBytes` appears once in the whole document, in the `proofHash` definition, and
180
+ nowhere in the batch text. We read `d` as `proofHash`; reading it as `canonicalBytes` is
181
+ equally sound and produces a different root, so the two do not interoperate. Recorded as
182
+ an ambiguity rather than a settled question, with proposed spec text in
183
+ [BRC220_BATCH_LEAF_AMENDMENT.md](BRC220_BATCH_LEAF_AMENDMENT.md) and enforcement in
184
+ `test/notaryhash/batch_leaf.js`. This is the second gap of the kind, after `encoding`.
176
185
  - **`createdAt` is advisory for trust but load-bearing for the hash.** §Verification calls
177
186
  it "an advisory client field only" — meaning proof-of-existence time comes from the
178
187
  block, not from this field. It is still inside the canonical bytes as `createdAtUnix`,
@@ -55,19 +55,19 @@ Three advanced modules totaling **~2.7MB** of functionality:
55
55
  - **Purpose**: Threshold cryptography for secure secret distribution
56
56
  - **Use Cases**: Backup keys, multi-party security, key recovery
57
57
  - **Features**: Split secrets into N shares, require M to reconstruct
58
- - **CDN**: `unpkg.com/@smartledger/bsv@8.3.0/bsv-shamir.min.js`
58
+ - **CDN**: `unpkg.com/@smartledger/bsv@8.3.1/bsv-shamir.min.js`
59
59
 
60
60
  #### **🌐 Global Digital Attestation Framework - GDAF (1184KB)**
61
61
  - **Purpose**: W3C Verifiable Credentials and decentralized identity
62
62
  - **Use Cases**: Identity verification, attestations, zero-knowledge proofs
63
63
  - **Features**: DID creation, credential issuance, selective disclosure
64
- - **CDN**: `unpkg.com/@smartledger/bsv@8.3.0/bsv-gdaf.min.js`
64
+ - **CDN**: `unpkg.com/@smartledger/bsv@8.3.1/bsv-gdaf.min.js`
65
65
 
66
66
  #### **⚖️ Legal Token Protocol - LTP (1184KB)**
67
67
  - **Purpose**: Legal compliance framework for tokenized assets
68
68
  - **Use Cases**: Property rights, obligations, compliant tokenization
69
69
  - **Features**: Legal primitives, compliance checking, attestation anchoring
70
- - **CDN**: `unpkg.com/@smartledger/bsv@8.3.0/bsv-ltp.min.js`
70
+ - **CDN**: `unpkg.com/@smartledger/bsv@8.3.1/bsv-ltp.min.js`
71
71
 
72
72
  ### **2. Incorrect File Sizes in Documentation**
73
73
 
@@ -81,18 +81,18 @@ Three advanced modules totaling **~2.7MB** of functionality:
81
81
 
82
82
  | Module | Size | Use Case | CDN Link |
83
83
  |--------|------|----------|----------|
84
- | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@8.3.0/bsv.min.js` |
85
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@8.3.0/bsv.bundle.js` |
86
- | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@8.3.0/bsv-smartcontract.min.js` |
87
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@8.3.0/bsv-covenant.min.js` |
88
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@8.3.0/bsv-script-helper.min.js` |
89
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@8.3.0/bsv-security.min.js` |
90
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@8.3.0/bsv-ecies.min.js` |
91
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@8.3.0/bsv-message.min.js` |
92
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@8.3.0/bsv-mnemonic.min.js` |
93
- | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@8.3.0/bsv-shamir.min.js` |
94
- | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@8.3.0/bsv-gdaf.min.js` |
95
- | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@8.3.0/bsv-ltp.min.js` |
84
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@8.3.1/bsv.min.js` |
85
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@8.3.1/bsv.bundle.js` |
86
+ | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@8.3.1/bsv-smartcontract.min.js` |
87
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@8.3.1/bsv-covenant.min.js` |
88
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@8.3.1/bsv-script-helper.min.js` |
89
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@8.3.1/bsv-security.min.js` |
90
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@8.3.1/bsv-ecies.min.js` |
91
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@8.3.1/bsv-message.min.js` |
92
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@8.3.1/bsv-mnemonic.min.js` |
93
+ | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@8.3.1/bsv-shamir.min.js` |
94
+ | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@8.3.1/bsv-gdaf.min.js` |
95
+ | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@8.3.1/bsv-ltp.min.js` |
96
96
 
97
97
  ## 🎯 **Updated Usage Examples**
98
98
 
@@ -100,22 +100,22 @@ Three advanced modules totaling **~2.7MB** of functionality:
100
100
 
101
101
  #### **1. Basic Development (~963KB)**
102
102
  ```html
103
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv.min.js"></script>
104
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-script-helper.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv.min.js"></script>
104
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-script-helper.min.js"></script>
105
105
  ```
106
106
 
107
107
  #### **2. Smart Contract Development (~2.7MB — each bundle re-embeds core BSV)**
108
108
  ```html
109
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv.min.js"></script>
110
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-covenant.min.js"></script>
111
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-smartcontract.min.js"></script>
109
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv.min.js"></script>
110
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-covenant.min.js"></script>
111
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-smartcontract.min.js"></script>
112
112
  ```
113
113
 
114
114
  #### **3. 🆕 Legal & Compliance Development (~3.2MB — each bundle re-embeds core BSV)**
115
115
  ```html
116
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv.min.js"></script>
117
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-ltp.min.js"></script>
118
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-gdaf.min.js"></script>
116
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv.min.js"></script>
117
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-ltp.min.js"></script>
118
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-gdaf.min.js"></script>
119
119
  <script>
120
120
  // Legal Token Protocol
121
121
  const legalToken = bsv.createLegalToken({
@@ -132,9 +132,9 @@ Three advanced modules totaling **~2.7MB** of functionality:
132
132
 
133
133
  #### **4. 🆕 Security & Cryptography (~1.4MB)**
134
134
  ```html
135
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv.min.js"></script>
136
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-security.min.js"></script>
137
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-shamir.min.js"></script>
135
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-security.min.js"></script>
137
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-shamir.min.js"></script>
138
138
  <script>
139
139
  // Shamir Secret Sharing
140
140
  const shares = bsv.splitSecret('my_secret_key', 5, 3); // 5 shares, 3 needed
@@ -146,7 +146,7 @@ Three advanced modules totaling **~2.7MB** of functionality:
146
146
 
147
147
  #### **5. Everything Bundle (937KB)**
148
148
  ```html
149
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv.bundle.js"></script>
149
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv.bundle.js"></script>
150
150
  <script>
151
151
  // Everything available immediately
152
152
  const shares = bsv.splitSecret('secret', 5, 3);
@@ -722,7 +722,7 @@ interface UTXO {
722
722
  <html>
723
723
  <head>
724
724
  <title>UTXO Manager Demo</title>
725
- <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@8.3.0/bsv.min.js"></script>
725
+ <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@8.3.1/bsv.min.js"></script>
726
726
  </head>
727
727
  <body>
728
728
  <script>
@@ -48,7 +48,7 @@ const tx: Transaction = new Transaction();
48
48
  #### **Core Library Only (937KB)**
49
49
  For basic Bitcoin SV operations:
50
50
  ```html
51
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv.min.js"></script>
51
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv.min.js"></script>
52
52
  <script>
53
53
  const privateKey = new bsv.PrivateKey();
54
54
  const address = privateKey.toAddress();
@@ -58,7 +58,7 @@ For basic Bitcoin SV operations:
58
58
  #### **Complete Bundle (937KB)**
59
59
  Everything in one file:
60
60
  ```html
61
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv.bundle.js"></script>
61
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv.bundle.js"></script>
62
62
  <script>
63
63
  // All features available immediately
64
64
  const shares = bsv.splitSecret('secret', 5, 3);
@@ -71,9 +71,9 @@ Everything in one file:
71
71
 
72
72
  #### **Smart Contract Development (~2.7MB total — each bundle is self-contained and re-embeds core BSV)**
73
73
  ```html
74
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv.min.js"></script>
75
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-covenant.min.js"></script>
76
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-smartcontract.min.js"></script>
74
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv.min.js"></script>
75
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-covenant.min.js"></script>
76
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-smartcontract.min.js"></script>
77
77
  <script>
78
78
  const covenant = bsv.SmartContract.createCovenantBuilder()
79
79
  .extractField('amount').push(50000).greaterThanOrEqual().build();
@@ -82,9 +82,9 @@ Everything in one file:
82
82
 
83
83
  #### **Legal & Identity Development (~3.2MB total — each bundle is self-contained and re-embeds core BSV)**
84
84
  ```html
85
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv.min.js"></script>
86
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-ltp.min.js"></script>
87
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-gdaf.min.js"></script>
85
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv.min.js"></script>
86
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-ltp.min.js"></script>
87
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-gdaf.min.js"></script>
88
88
  <script>
89
89
  // Legal Token Protocol
90
90
  const propertyToken = bsv.createPropertyToken({
@@ -98,9 +98,9 @@ Everything in one file:
98
98
 
99
99
  #### **Security & Cryptography (~1.4MB total — each bundle is self-contained and re-embeds core BSV)**
100
100
  ```html
101
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv.min.js"></script>
102
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-security.min.js"></script>
103
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-shamir.min.js"></script>
101
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv.min.js"></script>
102
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-security.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-shamir.min.js"></script>
104
104
  <script>
105
105
  // Threshold Cryptography
106
106
  const shares = bsv.splitSecret('my_secret_key', 5, 3);
@@ -114,18 +114,18 @@ Everything in one file:
114
114
 
115
115
  | Module | Size | Purpose | CDN Link |
116
116
  |--------|------|---------|----------|
117
- | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@8.3.0/bsv.min.js` |
118
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@8.3.0/bsv.bundle.js` |
119
- | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@8.3.0/bsv-smartcontract.min.js` |
120
- | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@8.3.0/bsv-ltp.min.js` |
121
- | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@8.3.0/bsv-gdaf.min.js` |
122
- | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@8.3.0/bsv-shamir.min.js` |
123
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@8.3.0/bsv-security.min.js` |
124
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@8.3.0/bsv-mnemonic.min.js` |
125
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@8.3.0/bsv-ecies.min.js` |
126
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@8.3.0/bsv-covenant.min.js` |
127
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@8.3.0/bsv-script-helper.min.js` |
128
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@8.3.0/bsv-message.min.js` |
117
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@8.3.1/bsv.min.js` |
118
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@8.3.1/bsv.bundle.js` |
119
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@8.3.1/bsv-smartcontract.min.js` |
120
+ | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@8.3.1/bsv-ltp.min.js` |
121
+ | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@8.3.1/bsv-gdaf.min.js` |
122
+ | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@8.3.1/bsv-shamir.min.js` |
123
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@8.3.1/bsv-security.min.js` |
124
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@8.3.1/bsv-mnemonic.min.js` |
125
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@8.3.1/bsv-ecies.min.js` |
126
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@8.3.1/bsv-covenant.min.js` |
127
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@8.3.1/bsv-script-helper.min.js` |
128
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@8.3.1/bsv-message.min.js` |
129
129
 
130
130
  ## ⚙️ **Development Environment Setup**
131
131
 
@@ -14,10 +14,10 @@ npm install @smartledger/bsv
14
14
  ### Browser CDN (Instant)
15
15
  ```html
16
16
  <!-- Core library (937KB) -->
17
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv.min.js"></script>
17
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv.min.js"></script>
18
18
 
19
19
  <!-- Everything included (937KB) -->
20
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv.bundle.js"></script>
20
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv.bundle.js"></script>
21
21
  ```
22
22
 
23
23
  ## 💰 **Your First Transaction (60 seconds)**
@@ -127,19 +127,19 @@ SmartLedger-BSV offers 12 different loading options - use only what you need:
127
127
 
128
128
  ```html
129
129
  <!-- Core BSV only (937KB) -->
130
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv.min.js"></script>
130
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv.min.js"></script>
131
131
 
132
132
  <!-- Smart contracts (937KB) -->
133
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-smartcontract.min.js"></script>
133
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-smartcontract.min.js"></script>
134
134
 
135
135
  <!-- Legal tokens (1.16MB) -->
136
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-ltp.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-ltp.min.js"></script>
137
137
 
138
138
  <!-- Digital identity (1.16MB) -->
139
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-gdaf.min.js"></script>
139
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-gdaf.min.js"></script>
140
140
 
141
141
  <!-- Everything (937KB) -->
142
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv.bundle.js"></script>
142
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv.bundle.js"></script>
143
143
  ```
144
144
 
145
145
  ## ⚡ **Key Advantages**
@@ -159,17 +159,17 @@ const recovered = bsv.reconstructSecret([shares[0], shares[2], shares[4]]);
159
159
  ### **New Modular Options**
160
160
  ```html
161
161
  <!-- Core compatibility (same size as bsv@1.5.6) -->
162
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv.min.js"></script>
162
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv.min.js"></script>
163
163
 
164
164
  <!-- Add smart contracts when ready -->
165
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-smartcontract.min.js"></script>
165
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-smartcontract.min.js"></script>
166
166
 
167
167
  <!-- Add advanced features as needed -->
168
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-ltp.min.js"></script>
169
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv-gdaf.min.js"></script>
168
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-ltp.min.js"></script>
169
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv-gdaf.min.js"></script>
170
170
 
171
171
  <!-- Everything in one file -->
172
- <script src="https://unpkg.com/@smartledger/bsv@8.3.0/bsv.bundle.js"></script>
172
+ <script src="https://unpkg.com/@smartledger/bsv@8.3.1/bsv.bundle.js"></script>
173
173
  ```
174
174
 
175
175
  ## 🔍 **Testing Your Migration**
@@ -241,6 +241,26 @@ NotaryHash.verifyBatchInclusion = function (certificate) {
241
241
  var m = certificate.merkle
242
242
  if (!m) return { valid: false, errors: ['batch certificate has no merkle proof'] }
243
243
 
244
+ // THE LEAF IS proofHash, NOT canonicalBytes.
245
+ //
246
+ // BRC-220 §On-chain record says the batch tree is RFC 6962 and writes
247
+ // `leaf = SHA256(0x00 ‖ d)` — but that is RFC 6962's own generic notation for the
248
+ // construction, and the spec never binds `d` to a value. `canonicalBytes` appears
249
+ // once in the whole document, in the proofHash definition, and nowhere in the batch
250
+ // text.
251
+ //
252
+ // So this is a choice the implementation had to make, and it is:
253
+ //
254
+ // leaf = SHA-256(0x00 ‖ proofHash) = SHA-256(0x00 ‖ SHA-256(canonicalBytes))
255
+ //
256
+ // The other reading — d = canonicalBytes — is equally sound cryptographically and
257
+ // produces a DIFFERENT root. A certificate built that way fails inclusion here with
258
+ // no error naming the cause: the fold simply does not reach the root. Anyone building
259
+ // batches with the exported NotaryHash.Merkle must use proofHash as the leaf datum.
260
+ //
261
+ // Reasoning and the proposed spec text: docs/BRC220_BATCH_LEAF_AMENDMENT.md.
262
+ // Enforced by test/notaryhash/batch_leaf.js, which checks that a canonicalBytes-leaf
263
+ // tree is rejected rather than trusting the comment.
244
264
  var leafData = Buffer.from(certificate.proofHash, 'hex')
245
265
  var path = (m.path || []).map(function (node) {
246
266
  return Buffer.isBuffer(node) ? node : Buffer.from(node, 'hex')
@@ -26,6 +26,14 @@ var $ = require('../util/preconditions')
26
26
  * root. Every non-power-of-two tree depends on getting this right.
27
27
  */
28
28
 
29
+ /**
30
+ * For BRC-220 batch mode the leaf datum `d` is a certificate's **proofHash**, so a leaf
31
+ * is `SHA-256(0x00 ‖ proofHash)`. The spec writes `leaf = SHA256(0x00 ‖ d)` using
32
+ * RFC 6962's generic notation and never binds `d`; passing `canonicalBytes` instead is
33
+ * equally sound and yields a different root, which NotaryHash.verifyBatchInclusion will
34
+ * reject. See docs/BRC220_BATCH_LEAF_AMENDMENT.md.
35
+ */
36
+
29
37
  var Merkle = {}
30
38
 
31
39
  /** Prefix bytes, per RFC 6962 §2.1. */
@@ -146,7 +146,23 @@ Suites.register('ECDSA-secp256k1', {
146
146
 
147
147
  var ecdsa = new ECDSA()
148
148
  ecdsa.hashbuf = payloadHash
149
- ecdsa.endian = 'little'
149
+ // NO endian override. `payloadHash` is the scalar, big-endian, exactly as the
150
+ // 32 bytes are given — which is what every other ECDSA implementation does and
151
+ // what BRC-220 means by "signs the payloadHash".
152
+ //
153
+ // 8.3.0 set `endian = 'little'` here, which made ECDSA reverse the digest before
154
+ // reducing it to the scalar. That is Bitcoin's message-signing convention, not
155
+ // this protocol's, and it is why lib/crypto/ecdsa.js offers the option at all.
156
+ //
157
+ // The effect was on the VERIFY side: a signature produced the way BRC-220
158
+ // specifies was rejected, and the only signatures accepted were ones made with
159
+ // bsv's own little-endian convention. Every test in this repo signed that way
160
+ // too, so the module and its tests were self-consistent and wrong together —
161
+ // the exact failure shape test/notaryhash/encoding.js warns about in its header.
162
+ //
163
+ // test/notaryhash/interop.js now pins this against @noble/curves, which shares
164
+ // no verification code with lib/crypto/ecdsa.js. A second implementation is the
165
+ // only thing that can catch a defect where the code and its tests agree.
150
166
  ecdsa.pubkey = pubkey
151
167
  ecdsa.sig = sig
152
168
  return ecdsa.verify() === true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartledger/bsv",
3
- "version": "8.3.0",
3
+ "version": "8.3.1",
4
4
  "description": "🚀 Complete Bitcoin SV development framework with legally-recognizable DID:web + W3C VC-JWT toolkit, Legal Token Protocol (LTP), Global Digital Attestation Framework (GDAF), StatusList2021 revocation, and 16 flexible loading options. Standards-based credentials with ES256/ES256K support, on-chain BSV anchoring, and comprehensive Bitcoin SV API. Perfect for legal tokens, verifiable credentials, DeFi, smart contracts, and secure Bitcoin applications.",
5
5
  "author": "SmartLedger Technology <hello@smartledger.technology> (https://smartledger.technology)",
6
6
  "homepage": "https://github.com/codenlighten/smartledger-bsv#readme",
@@ -65,6 +65,7 @@
65
65
  "vectors:sv-tx": "node tools/sv-tx-report.js",
66
66
  "vectors:sv-sighash": "node tools/sv-sighash-report.js",
67
67
  "conformance:generate": "node conformance/generate.js",
68
+ "check:readme": "node scripts/check-readme-accuracy.js",
68
69
  "lint:ratchet": "node scripts/lint-ratchet.js",
69
70
  "lint:ratchet:update": "node scripts/lint-ratchet.js --update",
70
71
  "test": "mocha",
@@ -97,7 +98,7 @@
97
98
  "test:browser": "echo 'Open tests/standalone-modules-test.html in browser for comprehensive testing'",
98
99
  "test:bundle": "echo 'Open tests/bundle-completeness-test.html in browser to verify bundle completeness'",
99
100
  "preimage:extract": "node examples/preimage/extract_preimage_bidirectional.js",
100
- "prepublishOnly": "npm run build-all",
101
+ "prepublishOnly": "npm run build-all && npm run check:readme",
101
102
  "sync-cdn": "node scripts/sync-cdn-urls.js",
102
103
  "version": "node scripts/sync-cdn-urls.js && node scripts/sync-version.js && node scripts/gen-esm-wrapper.js && git add README.md docs version.js index.mjs",
103
104
  "test:browser:ci": "node tests/browser-smoke-runner.js"