@smartledger/bsv 9.18.0 → 9.19.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.
@@ -34,14 +34,14 @@ module sounds. That is a deliberate revision: an earlier version of this documen
34
34
  scoped Tier 1 as "the cryptographic core" and would have excluded four of the six real
35
35
  defects this codebase has produced. See §2.1.
36
36
 
37
- ### Tier 1 — 12,269 lines
37
+ ### Tier 1 — 12,348 lines
38
38
 
39
39
  | Module | Lines | Why it matters |
40
40
  | --- | ---: | --- |
41
41
  | `lib/transaction/` | 2,786 | Sighash construction and signing — both BIP-143 and the Original Transaction Digest Algorithm. |
42
42
  | `lib/script/interpreter.js` | 2,962 | **Scoped to the flag and era surface, not opcode execution.** Consensus-flag selection and defaults, era derivation (Genesis/Chronicle), the limits derived from them, and the semantics of the exported `verify()`. Opcode execution is excluded — see §2.2. |
43
43
  | `lib/crypto/` | 2,519 | ECDSA, nonce derivation, signature encoding, the script-number type. **Scope this for an architectural judgement as well as for bugs** — see §2.3. |
44
- | `lib/notaryhash/` | 2,173 | BRC-220 signing and verification. Publicly reachable and relied on downstream. |
44
+ | `lib/notaryhash/` | 2,252 | BRC-220 signing and verification. Publicly reachable and relied on downstream. |
45
45
  | `lib/privatekey.js`, `lib/publickey.js` | 843 | Key construction, serialisation, WIF. Recent defects here produced a *different* key without error. |
46
46
  | `lib/smart_contract/` (targeted) | 472 | `locks.js` and the covenant-facing entrypoints in `index.js`: CLTV and HTLC locking semantics, flag plumbing, and any wrapper claiming mainnet-equivalent verification. Not the whole 6,908-line module. |
47
47
  | `lib/covenant/` | 409 | The verification harness. Its flag word is what made covenants verify under 2019 rules while claiming to mirror mainnet. |
@@ -150,14 +150,14 @@ this repository.
150
150
  | `lib/address.js`, `lib/networks.js`, `lib/opcode.js`, `lib/hdprivatekey.js`, `lib/hdpublickey.js` (2,391 lines) | Cut to pay for §2.1 | Formatting, network constants and BIP-32 derivation. No defect has originated here, and `networks.js` in particular defines addressing constants — pubkey hashes, xpub prefixes, ports, DNS seeds — and contains **no consensus-flag logic at all**. |
151
151
  | The rest of the application layer — `lib/gdaf/`, `lib/ltp/`, `lib/ordinals/`, `lib/block/`, `lib/didweb/`, `lib/vcjwt/`, `lib/statuslist/`, most of `lib/smart_contract/`, plus assorted top-level files | Excluded | ~26,000 lines. Worth a separate engagement; including it here would blur the question in §1. Note the parts of it with a demonstrated defect history have been pulled *into* Tier 1 rather than left here — see §2.1. |
152
152
 
153
- Totals reconcile against `lib/`, which is 40,324 lines across 131 files:
153
+ Totals reconcile against `lib/`, which is 40,403 lines across 131 files:
154
154
 
155
155
  ```
156
- tier 1 12,269
156
+ tier 1 12,348
157
157
  tier 2 1,607
158
158
  excluded 26,448
159
159
  ------
160
- total 40,324
160
+ total 40,403
161
161
  ```
162
162
 
163
163
  Measured 2026-08-29 at `a954c27`. These figures drift as the library changes — an
@@ -228,7 +228,7 @@ seeking a quote for an independent security review.
228
228
 
229
229
  Scope, and we would like these priced separately:
230
230
 
231
- Tier 1 — 12,269 lines. Sighash construction and signing; ECDSA, nonce
231
+ Tier 1 — 12,348 lines. Sighash construction and signing; ECDSA, nonce
232
232
  derivation and signature encoding; the consensus-flag and era-derivation
233
233
  surface of the script interpreter; BRC-220 signing and verification;
234
234
  key construction and serialisation; the covenant verification harness and
@@ -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@9.18.0/bsv-shamir.min.js`
58
+ - **CDN**: `unpkg.com/@smartledger/bsv@9.19.0/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@9.18.0/bsv-gdaf.min.js`
64
+ - **CDN**: `unpkg.com/@smartledger/bsv@9.19.0/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@9.18.0/bsv-ltp.min.js`
70
+ - **CDN**: `unpkg.com/@smartledger/bsv@9.19.0/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@9.18.0/bsv.min.js` |
85
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.18.0/bsv.bundle.js` |
86
- | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@9.18.0/bsv-smartcontract.min.js` |
87
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.18.0/bsv-covenant.min.js` |
88
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.18.0/bsv-script-helper.min.js` |
89
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@9.18.0/bsv-security.min.js` |
90
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@9.18.0/bsv-ecies.min.js` |
91
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@9.18.0/bsv-message.min.js` |
92
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@9.18.0/bsv-mnemonic.min.js` |
93
- | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@9.18.0/bsv-shamir.min.js` |
94
- | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@9.18.0/bsv-gdaf.min.js` |
95
- | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@9.18.0/bsv-ltp.min.js` |
84
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.19.0/bsv.min.js` |
85
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.19.0/bsv.bundle.js` |
86
+ | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@9.19.0/bsv-smartcontract.min.js` |
87
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.19.0/bsv-covenant.min.js` |
88
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.19.0/bsv-script-helper.min.js` |
89
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@9.19.0/bsv-security.min.js` |
90
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@9.19.0/bsv-ecies.min.js` |
91
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@9.19.0/bsv-message.min.js` |
92
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@9.19.0/bsv-mnemonic.min.js` |
93
+ | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@9.19.0/bsv-shamir.min.js` |
94
+ | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@9.19.0/bsv-gdaf.min.js` |
95
+ | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@9.19.0/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@9.18.0/bsv.min.js"></script>
104
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-script-helper.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv.min.js"></script>
104
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/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@9.18.0/bsv.min.js"></script>
110
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-covenant.min.js"></script>
111
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-smartcontract.min.js"></script>
109
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv.min.js"></script>
110
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv-covenant.min.js"></script>
111
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/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@9.18.0/bsv.min.js"></script>
117
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-ltp.min.js"></script>
118
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-gdaf.min.js"></script>
116
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv.min.js"></script>
117
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv-ltp.min.js"></script>
118
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/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@9.18.0/bsv.min.js"></script>
136
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-security.min.js"></script>
137
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-shamir.min.js"></script>
135
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv-security.min.js"></script>
137
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/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@9.18.0/bsv.bundle.js"></script>
149
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/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@9.18.0/bsv.min.js"></script>
725
+ <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@9.19.0/bsv.min.js"></script>
726
726
  </head>
727
727
  <body>
728
728
  <script>
@@ -15,7 +15,7 @@ seeking a quote for an independent security review of its cryptographic core.
15
15
 
16
16
  Scope, and we would like these priced separately:
17
17
 
18
- Tier 1 — 12,269 lines. Sighash construction and signing; ECDSA, nonce
18
+ Tier 1 — 12,348 lines. Sighash construction and signing; ECDSA, nonce
19
19
  derivation and signature encoding; the consensus-flag and era surface of the
20
20
  script interpreter; BRC-220 signing; the covenant verification harness; RFC
21
21
  8785 canonicalization; and the covenant-facing entrypoints of the smart
@@ -15,7 +15,7 @@ seeking a quote for an independent security review of its cryptographic core.
15
15
 
16
16
  Scope, and we would like these priced separately:
17
17
 
18
- Tier 1 — 12,269 lines. Sighash construction and signing; ECDSA, nonce
18
+ Tier 1 — 12,348 lines. Sighash construction and signing; ECDSA, nonce
19
19
  derivation and signature encoding; the consensus-flag and era surface of the
20
20
  script interpreter; BRC-220 signing; the covenant verification harness; RFC
21
21
  8785 canonicalization; and the covenant-facing entrypoints of the smart
@@ -15,7 +15,7 @@ seeking a quote for an independent security review of its cryptographic core.
15
15
 
16
16
  Scope, and we would like these priced separately:
17
17
 
18
- Tier 1 — 12,269 lines. Sighash construction and signing; ECDSA, nonce
18
+ Tier 1 — 12,348 lines. Sighash construction and signing; ECDSA, nonce
19
19
  derivation and signature encoding; the consensus-flag and era surface of the
20
20
  script interpreter; BRC-220 signing; the covenant verification harness; RFC
21
21
  8785 canonicalization; and the covenant-facing entrypoints of the smart
@@ -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@9.18.0/bsv.min.js"></script>
51
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/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@9.18.0/bsv.bundle.js"></script>
61
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/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@9.18.0/bsv.min.js"></script>
75
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-covenant.min.js"></script>
76
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-smartcontract.min.js"></script>
74
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv.min.js"></script>
75
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv-covenant.min.js"></script>
76
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/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@9.18.0/bsv.min.js"></script>
86
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-ltp.min.js"></script>
87
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-gdaf.min.js"></script>
85
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv.min.js"></script>
86
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv-ltp.min.js"></script>
87
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/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@9.18.0/bsv.min.js"></script>
102
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-security.min.js"></script>
103
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-shamir.min.js"></script>
101
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv.min.js"></script>
102
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv-security.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/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@9.18.0/bsv.min.js` |
118
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.18.0/bsv.bundle.js` |
119
- | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@9.18.0/bsv-smartcontract.min.js` |
120
- | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@9.18.0/bsv-ltp.min.js` |
121
- | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@9.18.0/bsv-gdaf.min.js` |
122
- | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@9.18.0/bsv-shamir.min.js` |
123
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@9.18.0/bsv-security.min.js` |
124
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@9.18.0/bsv-mnemonic.min.js` |
125
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@9.18.0/bsv-ecies.min.js` |
126
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.18.0/bsv-covenant.min.js` |
127
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.18.0/bsv-script-helper.min.js` |
128
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@9.18.0/bsv-message.min.js` |
117
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.19.0/bsv.min.js` |
118
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.19.0/bsv.bundle.js` |
119
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@9.19.0/bsv-smartcontract.min.js` |
120
+ | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@9.19.0/bsv-ltp.min.js` |
121
+ | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@9.19.0/bsv-gdaf.min.js` |
122
+ | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@9.19.0/bsv-shamir.min.js` |
123
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@9.19.0/bsv-security.min.js` |
124
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@9.19.0/bsv-mnemonic.min.js` |
125
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@9.19.0/bsv-ecies.min.js` |
126
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.19.0/bsv-covenant.min.js` |
127
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.19.0/bsv-script-helper.min.js` |
128
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@9.19.0/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@9.18.0/bsv.min.js"></script>
17
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv.min.js"></script>
18
18
 
19
19
  <!-- Everything included (937KB) -->
20
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv.bundle.js"></script>
20
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/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@9.18.0/bsv.min.js"></script>
130
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv.min.js"></script>
131
131
 
132
132
  <!-- Smart contracts (937KB) -->
133
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-smartcontract.min.js"></script>
133
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv-smartcontract.min.js"></script>
134
134
 
135
135
  <!-- Legal tokens (1.16MB) -->
136
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-ltp.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv-ltp.min.js"></script>
137
137
 
138
138
  <!-- Digital identity (1.16MB) -->
139
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-gdaf.min.js"></script>
139
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv-gdaf.min.js"></script>
140
140
 
141
141
  <!-- Everything (937KB) -->
142
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv.bundle.js"></script>
142
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/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@9.18.0/bsv.min.js"></script>
162
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv.min.js"></script>
163
163
 
164
164
  <!-- Add smart contracts when ready -->
165
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-smartcontract.min.js"></script>
165
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv-smartcontract.min.js"></script>
166
166
 
167
167
  <!-- Add advanced features as needed -->
168
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-ltp.min.js"></script>
169
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv-gdaf.min.js"></script>
168
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv-ltp.min.js"></script>
169
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv-gdaf.min.js"></script>
170
170
 
171
171
  <!-- Everything in one file -->
172
- <script src="https://unpkg.com/@smartledger/bsv@9.18.0/bsv.bundle.js"></script>
172
+ <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv.bundle.js"></script>
173
173
  ```
174
174
 
175
175
  ## 🔍 **Testing Your Migration**
@@ -192,12 +192,44 @@ function sidedPath (path, leafIndex, leafCount) {
192
192
  return n && typeof n === 'object' && !Buffer.isBuffer(n) && 'side' in n
193
193
  })
194
194
  if (sided || path.length === 0) {
195
- return path.map(function (n, i) {
195
+ var carried = path.map(function (n, i) {
196
196
  if (n.side !== 'left' && n.side !== 'right') {
197
197
  throw new Error('merkle.path[' + i + '].side must be "left" or "right"')
198
198
  }
199
199
  return { hash: hashHex(n.hash, 'merkle.path[' + i + '].hash'), side: n.side }
200
200
  })
201
+
202
+ // `leafIndex` must agree with the sides the path carries.
203
+ //
204
+ // A sided path is folded by its own sides, so until this check `leafIndex` was read and
205
+ // never used: it could be changed to any other value in range and the proof still
206
+ // verified. That makes it an UNVALIDATED assertion sitting beside validated ones, and a
207
+ // reader shown "leaf 3 of 25" has no way to tell which of those fields is load-bearing.
208
+ // `leafCount` is pinned by the on-chain `u32be` that `recordMatchesCertificate` compares;
209
+ // `leafIndex` is on chain nowhere, so this is the only place it can be checked.
210
+ //
211
+ // The position is already determined: RFC 6962 derives the side sequence from the index
212
+ // and the tree size, so recomputing it and comparing costs one pass and no hashing.
213
+ // Reported by the ordinals mint that anchors BRC-220 proofs, whose tamper test caught it
214
+ // when it moved from the legacy format — where the sides ARE derived from leafIndex, so
215
+ // flipping it correctly failed.
216
+ if (Number.isInteger(leafIndex) && Number.isInteger(leafCount) &&
217
+ leafCount > 0 && leafIndex >= 0 && leafIndex < leafCount) {
218
+ var implied = Merkle.pathSides(leafIndex, leafCount)
219
+ if (implied.length !== carried.length) {
220
+ throw new Error('merkle.leafIndex ' + leafIndex + ' in a tree of ' + leafCount +
221
+ ' leaves needs ' + implied.length + ' path nodes; the path has ' + carried.length)
222
+ }
223
+ for (var si = 0; si < implied.length; si++) {
224
+ if (implied[si] !== carried[si].side) {
225
+ throw new Error('merkle.leafIndex ' + leafIndex + ' disagrees with the path: node ' +
226
+ si + ' is marked "' + carried[si].side + '" but leaf ' + leafIndex + ' of ' +
227
+ leafCount + ' requires "' + implied[si] + '"')
228
+ }
229
+ }
230
+ }
231
+
232
+ return carried
201
233
  }
202
234
  var sides = Merkle.pathSides(leafIndex, leafCount)
203
235
  if (sides.length !== path.length) {
@@ -408,6 +408,53 @@ function merkleFolds (c, failure) {
408
408
  var leafData = Certificate.decodeBytes(c.proofHash, 'hex', 'proofHash')
409
409
  var root = Certificate.decodeBytes(m.root, 'hex', 'merkle.root')
410
410
 
411
+ // `leafIndex` must agree with the sides the path carries, and this is the only place it
412
+ // can be checked.
413
+ //
414
+ // A sided path folds by its OWN sides, and `Certificate.normalize` returns a
415
+ // non-legacy certificate untouched — so for a reference certificate `leafIndex` was read
416
+ // and never used. It could be changed to any other value in range and the proof still
417
+ // verified. A legacy certificate was fine, because normalising it DERIVES the sides from
418
+ // `leafIndex`, so a wrong index produced a wrong fold and failed.
419
+ //
420
+ // That left `leafIndex` an unvalidated assertion sitting beside validated ones, and a
421
+ // reader shown "leaf 3 of 25" cannot tell which of those fields is load-bearing.
422
+ // `leafCount` is pinned by the on-chain `u32be` that `recordMatchesCertificate` compares;
423
+ // `leafIndex` appears on chain nowhere.
424
+ //
425
+ // No hashing is needed: RFC 6962 determines the side sequence from the index and the tree
426
+ // size, so the position the path implies is recomputed and compared in one pass.
427
+ //
428
+ // Reported by the ordinals mint anchoring BRC-220 proofs, whose tamper test caught it on
429
+ // moving from the legacy format to the reference one.
430
+ if (Number.isInteger(m.leafIndex) && Number.isInteger(m.leafCount) &&
431
+ m.leafCount > 0 && m.leafIndex >= 0 && m.leafIndex < m.leafCount) {
432
+ var implied = Merkle.pathSides(m.leafIndex, m.leafCount)
433
+ var carried = (m.path || []).map(function (n) {
434
+ return n && typeof n === 'object' && !Buffer.isBuffer(n) ? n.side : undefined
435
+ })
436
+ if (implied.length !== carried.length) {
437
+ return {
438
+ valid: false,
439
+ errors: ['merkle.leafIndex ' + m.leafIndex + ' in a tree of ' + m.leafCount +
440
+ ' leaves needs ' + implied.length + ' path nodes; the path has ' + carried.length]
441
+ }
442
+ }
443
+ for (var si = 0; si < implied.length; si++) {
444
+ // A bare-hash path carries no sides; those are derived from leafIndex when the
445
+ // certificate is normalised, so they agree by construction and there is nothing to
446
+ // cross-check.
447
+ if (carried[si] !== undefined && carried[si] !== implied[si]) {
448
+ return {
449
+ valid: false,
450
+ errors: ['merkle.leafIndex ' + m.leafIndex + ' disagrees with the path: node ' +
451
+ si + ' is marked "' + carried[si] + '" but leaf ' + m.leafIndex + ' of ' +
452
+ m.leafCount + ' requires "' + implied[si] + '"']
453
+ }
454
+ }
455
+ }
456
+ }
457
+
411
458
  // Folded by side, as the reference folds it. The sides are what the certificate
412
459
  // carries; a legacy bare-hash path had them derived from leafIndex and leafCount when
413
460
  // it was normalised.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartledger/bsv",
3
- "version": "9.18.0",
3
+ "version": "9.19.0",
4
4
  "description": "Bitcoin SV library with an interpreter-verified script engine: OP_PUSH_TX covenants, BIP-143 preimage tooling, and consensus flags that match what miners actually enforce. Also ships DID:web / W3C VC-JWT credentials and the Legal Token Protocol.",
5
5
  "author": "SmartLedger Technology <hello@smartledger.technology> (https://smartledger.technology)",
6
6
  "homepage": "https://github.com/codenlighten/smartledger-bsv#readme",
package/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  'use strict'
2
2
  // GENERATED by scripts/sync-version.js on `npm version` — do not edit.
3
- module.exports = '9.18.0'
3
+ module.exports = '9.19.0'