@smartledger/bsv 9.19.0 → 9.20.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,348 lines
37
+ ### Tier 1 — 12,437 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,252 | BRC-220 signing and verification. Publicly reachable and relied on downstream. |
44
+ | `lib/notaryhash/` | 2,341 | 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,403 lines across 131 files:
153
+ Totals reconcile against `lib/`, which is 40,562 lines across 131 files:
154
154
 
155
155
  ```
156
- tier 1 12,348
156
+ tier 1 12,437
157
157
  tier 2 1,607
158
- excluded 26,448
158
+ excluded 26,518
159
159
  ------
160
- total 40,403
160
+ total 40,562
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,348 lines. Sighash construction and signing; ECDSA, nonce
231
+ Tier 1 — 12,437 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.19.0/bsv-shamir.min.js`
58
+ - **CDN**: `unpkg.com/@smartledger/bsv@9.20.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.19.0/bsv-gdaf.min.js`
64
+ - **CDN**: `unpkg.com/@smartledger/bsv@9.20.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.19.0/bsv-ltp.min.js`
70
+ - **CDN**: `unpkg.com/@smartledger/bsv@9.20.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.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` |
84
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.20.0/bsv.min.js` |
85
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.20.0/bsv.bundle.js` |
86
+ | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@9.20.0/bsv-smartcontract.min.js` |
87
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.20.0/bsv-covenant.min.js` |
88
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.20.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.20.0/bsv-security.min.js` |
90
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@9.20.0/bsv-ecies.min.js` |
91
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@9.20.0/bsv-message.min.js` |
92
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@9.20.0/bsv-mnemonic.min.js` |
93
+ | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@9.20.0/bsv-shamir.min.js` |
94
+ | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@9.20.0/bsv-gdaf.min.js` |
95
+ | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@9.20.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.19.0/bsv.min.js"></script>
104
- <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv-script-helper.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv.min.js"></script>
104
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.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.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>
109
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv.min.js"></script>
110
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv-covenant.min.js"></script>
111
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.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.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>
116
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv.min.js"></script>
117
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv-ltp.min.js"></script>
118
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.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.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>
135
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv-security.min.js"></script>
137
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.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.19.0/bsv.bundle.js"></script>
149
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.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.19.0/bsv.min.js"></script>
725
+ <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@9.20.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,348 lines. Sighash construction and signing; ECDSA, nonce
18
+ Tier 1 — 12,437 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
@@ -30,7 +30,7 @@ Explicitly out of scope: elliptic-curve and hash primitives, which are supplied
30
30
  by the Noble libraries and already audited; opcode EXECUTION in the script
31
31
  interpreter, which passes 1,483 of 1,483 of the reference node's own consensus
32
32
  vectors with zero false accepts and zero false rejects; and the remaining
33
- 26,448-line application layer (credentials, tokens, ordinals), which we would
33
+ 26,518-line application layer (credentials, tokens, ordinals), which we would
34
34
  treat as a separate engagement.
35
35
 
36
36
  Note the shape of that first exclusion, because it is what we want priced. The
@@ -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,348 lines. Sighash construction and signing; ECDSA, nonce
18
+ Tier 1 — 12,437 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
@@ -30,7 +30,7 @@ Explicitly out of scope: elliptic-curve and hash primitives, which are supplied
30
30
  by the Noble libraries and already audited; opcode EXECUTION in the script
31
31
  interpreter, which passes 1,483 of 1,483 of the reference node's own consensus
32
32
  vectors with zero false accepts and zero false rejects; and the remaining
33
- 26,448-line application layer (credentials, tokens, ordinals), which we would
33
+ 26,518-line application layer (credentials, tokens, ordinals), which we would
34
34
  treat as a separate engagement.
35
35
 
36
36
  Note the shape of that first exclusion, because it is what we want priced. The
@@ -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,348 lines. Sighash construction and signing; ECDSA, nonce
18
+ Tier 1 — 12,437 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
@@ -30,7 +30,7 @@ Explicitly out of scope: elliptic-curve and hash primitives, which are supplied
30
30
  by the Noble libraries and already audited; opcode EXECUTION in the script
31
31
  interpreter, which passes 1,483 of 1,483 of the reference node's own consensus
32
32
  vectors with zero false accepts and zero false rejects; and the remaining
33
- 26,448-line application layer (credentials, tokens, ordinals), which we would
33
+ 26,518-line application layer (credentials, tokens, ordinals), which we would
34
34
  treat as a separate engagement.
35
35
 
36
36
  Note the shape of that first exclusion, because it is what we want priced. The
@@ -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.19.0/bsv.min.js"></script>
51
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.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.19.0/bsv.bundle.js"></script>
61
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.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.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>
74
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv.min.js"></script>
75
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv-covenant.min.js"></script>
76
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.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.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>
85
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv.min.js"></script>
86
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv-ltp.min.js"></script>
87
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.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.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>
101
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv.min.js"></script>
102
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv-security.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.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.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` |
117
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.20.0/bsv.min.js` |
118
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.20.0/bsv.bundle.js` |
119
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@9.20.0/bsv-smartcontract.min.js` |
120
+ | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@9.20.0/bsv-ltp.min.js` |
121
+ | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@9.20.0/bsv-gdaf.min.js` |
122
+ | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@9.20.0/bsv-shamir.min.js` |
123
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@9.20.0/bsv-security.min.js` |
124
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@9.20.0/bsv-mnemonic.min.js` |
125
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@9.20.0/bsv-ecies.min.js` |
126
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.20.0/bsv-covenant.min.js` |
127
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.20.0/bsv-script-helper.min.js` |
128
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@9.20.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.19.0/bsv.min.js"></script>
17
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv.min.js"></script>
18
18
 
19
19
  <!-- Everything included (937KB) -->
20
- <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv.bundle.js"></script>
20
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.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.19.0/bsv.min.js"></script>
130
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv.min.js"></script>
131
131
 
132
132
  <!-- Smart contracts (937KB) -->
133
- <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv-smartcontract.min.js"></script>
133
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv-smartcontract.min.js"></script>
134
134
 
135
135
  <!-- Legal tokens (1.16MB) -->
136
- <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv-ltp.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv-ltp.min.js"></script>
137
137
 
138
138
  <!-- Digital identity (1.16MB) -->
139
- <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv-gdaf.min.js"></script>
139
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv-gdaf.min.js"></script>
140
140
 
141
141
  <!-- Everything (937KB) -->
142
- <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv.bundle.js"></script>
142
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.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.19.0/bsv.min.js"></script>
162
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv.min.js"></script>
163
163
 
164
164
  <!-- Add smart contracts when ready -->
165
- <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv-smartcontract.min.js"></script>
165
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv-smartcontract.min.js"></script>
166
166
 
167
167
  <!-- Add advanced features as needed -->
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>
168
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv-ltp.min.js"></script>
169
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv-gdaf.min.js"></script>
170
170
 
171
171
  <!-- Everything in one file -->
172
- <script src="https://unpkg.com/@smartledger/bsv@9.19.0/bsv.bundle.js"></script>
172
+ <script src="https://unpkg.com/@smartledger/bsv@9.20.0/bsv.bundle.js"></script>
173
173
  ```
174
174
 
175
175
  ## 🔍 **Testing Your Migration**
@@ -572,29 +572,99 @@ ZKProver.generateMembershipProof = function(set, value, salt) {
572
572
  proofPurpose: 'membershipVerification',
573
573
  setCommitments: commitments,
574
574
  valueCommitment: valueCommitment,
575
- isMember: true
575
+ isMember: true,
576
+ // The salt is returned so the holder can build the opening the verifier now requires.
577
+ // It is NOT secret from the verifier: one salt covers every member, so a verifier given
578
+ // the salt and the set can recompute every commitment — which is exactly what
579
+ // verification does. See the note on verifyMembershipProof.
580
+ salt: salt
576
581
  }
577
582
  }
578
583
 
579
584
  /**
580
- * Verify membership proof
581
- * @param {Object} proof - Membership proof
582
- * @returns {Boolean} True if proof is valid
585
+ * Verify membership proof.
586
+ *
587
+ * The same defect as verifyAgeProof and verifyRangeProof had, and the same fix. This used
588
+ * to take the proof alone and return
589
+ *
590
+ * proof.setCommitments.includes(proof.valueCommitment) && proof.isMember
591
+ *
592
+ * where EVERY value in that expression came from the prover. Nothing bound the commitments
593
+ * to a set the verifier knew, nothing opened the value commitment, and `isMember` was the
594
+ * prover's own claim. So this returned true:
595
+ *
596
+ * verifyMembershipProof({ type: 'MembershipProof',
597
+ * setCommitments: ['x'], valueCommitment: 'x', isMember: true })
598
+ *
599
+ * A forged proof needed no key, no salt and no set. Reported against 9.19.0 by a consumer
600
+ * who had reviewed the GDAF proofs in July and re-tested them.
601
+ *
602
+ * The verifier must now supply the set it believes in, and the holder must supply an
603
+ * opening. Both commitments are recomputed and membership is decided against the VERIFIER's
604
+ * set, not the prover's array.
605
+ *
606
+ * This is not zero-knowledge and cannot be, consistent with the header note on this module.
607
+ * One salt covers every member, so a verifier holding the set and the salt can recompute
608
+ * every commitment — the set is not hidden from the verifier, and a low-entropy set is not
609
+ * hidden from anyone who sees the proof. The honest claim is "this value is in a set the
610
+ * verifier already holds", which is a membership CHECK, not a privacy-preserving proof. A
611
+ * caller who needs the value or the set hidden needs a different primitive; a reference
612
+ * construction is per-attribute fresh salts under an issuer-signed RFC 6962 root.
613
+ *
614
+ * @param {Object} proof - Membership proof from generateMembershipProof
615
+ * @param {Object} opening - { value, salt } as returned alongside the proof
616
+ * @param {Array} set - the set the VERIFIER believes in, supplied by the verifier
617
+ * @returns {Boolean} True if the opening commits to a member of the verifier's set
583
618
  */
584
- ZKProver.verifyMembershipProof = function(proof) {
619
+ ZKProver.verifyMembershipProof = function(proof, opening, set) {
585
620
  try {
586
621
  $.checkArgument(proof && typeof proof === 'object', 'Invalid proof')
587
-
622
+
588
623
  if (proof.type !== 'MembershipProof') {
589
624
  return false
590
625
  }
591
-
626
+
592
627
  if (!Array.isArray(proof.setCommitments)) {
593
628
  return false
594
629
  }
595
-
596
- // Verify that the value commitment appears in the set commitments
597
- return proof.setCommitments.includes(proof.valueCommitment) && proof.isMember
630
+
631
+ // Without a verifier-supplied set and an opening there is nothing to check the prover's
632
+ // array against, so there is no honest answer but false.
633
+ if (!Array.isArray(set) || set.length === 0) {
634
+ return false
635
+ }
636
+ if (!opening || typeof opening !== 'object' || typeof opening.salt !== 'string') {
637
+ return false
638
+ }
639
+ if (!('value' in opening)) {
640
+ return false
641
+ }
642
+
643
+ var commit = function (member) {
644
+ return Hash.sha256(
645
+ Buffer.from(JSON.stringify(member) + ':' + opening.salt, 'utf8')
646
+ ).toString('hex')
647
+ }
648
+
649
+ // The prover's array must be exactly the commitments the verifier's set implies, in
650
+ // order. Comparing as a set would let a prover append a commitment of its own.
651
+ var expected = set.map(commit)
652
+ if (expected.length !== proof.setCommitments.length) {
653
+ return false
654
+ }
655
+ for (var i = 0; i < expected.length; i++) {
656
+ if (expected[i] !== proof.setCommitments[i]) {
657
+ return false
658
+ }
659
+ }
660
+
661
+ // The opening must commit to the value the proof names.
662
+ if (commit(opening.value) !== proof.valueCommitment) {
663
+ return false
664
+ }
665
+
666
+ // Decided against the verifier's set, and `proof.isMember` is not consulted.
667
+ return expected.indexOf(proof.valueCommitment) !== -1
598
668
 
599
669
  } catch (error) {
600
670
  return false
@@ -637,6 +637,37 @@ Certificate.validateShape = function (certificate) {
637
637
  if (c[field] === undefined) problems.push('missing required field: ' + field)
638
638
  })
639
639
 
640
+ // `createdAt` must be the canonical rendering of its second.
641
+ //
642
+ // The proofHash commits to `createdAtUnix`, which is the time truncated to a second, so
643
+ // `...04.000Z`, `...04.527Z` and `...04Z` all produce the SAME commitment. The sub-second
644
+ // component is therefore not covered by the proof: it is an editable field that reads as
645
+ // part of a verified record. Three different strings claiming three different instants
646
+ // verified identically.
647
+ //
648
+ // Requiring the canonical form removes the ambiguity rather than papering over it, and it
649
+ // costs real issuers nothing — the two live certificates checked against this rule, a
650
+ // mainnet batch anchor and a production drop record, both already emit `.000Z`.
651
+ //
652
+ // Applied to the REFERENCE format only. Certificates written by 8.3.0-9.8.0 carry a
653
+ // millisecond component — `test/data/notaryhash-9.8.0-certs.json` pins one that this
654
+ // library deliberately still reads — and those exist in the wild. Legacy certificates are
655
+ // read, never written, so rejecting them now would break holders of records that were
656
+ // valid when issued; the rule binds the format we actually emit.
657
+ if (typeof c.createdAt === 'string' && !Certificate.isLegacy(certificate)) {
658
+ var canonical = null
659
+ var parsed = new Date(c.createdAt)
660
+ if (!isNaN(parsed.getTime())) {
661
+ canonical = new Date(Math.floor(parsed.getTime() / 1000) * 1000).toISOString()
662
+ }
663
+ if (canonical === null) {
664
+ problems.push('createdAt is not a date: ' + c.createdAt)
665
+ } else if (c.createdAt !== canonical) {
666
+ problems.push('createdAt must be the canonical rendering of its second: expected ' +
667
+ canonical + ', got ' + c.createdAt)
668
+ }
669
+ }
670
+
640
671
  if (c.protocol !== undefined && c.protocol !== Certificate.PROTOCOL) {
641
672
  problems.push('protocol must be "' + Certificate.PROTOCOL + '"')
642
673
  }
@@ -129,9 +129,25 @@ NotaryHash.txidFromRawTx = function (rawTx) {
129
129
  * @param {Buffer|String} rawTx
130
130
  * @returns {Object|null} the parsed record, or null if there is none
131
131
  */
132
- NotaryHash.recordFromRawTx = function (rawTx) {
132
+ NotaryHash.recordFromRawTx = function (rawTx, vout) {
133
133
  try {
134
134
  var tx = new Transaction(Buffer.isBuffer(rawTx) ? rawTx.toString('hex') : rawTx)
135
+
136
+ // With a vout, read THAT output and no other.
137
+ //
138
+ // Scanning every output means the certificate's `anchor.vout` is decorative: it can name
139
+ // any index, or one past the end, and the record is still found somewhere else in the
140
+ // transaction. `anchor.vout` is covered by no signature, so that made it an editable
141
+ // field that looked authoritative. A caller verifying an anchor must read the output the
142
+ // certificate points at.
143
+ if (vout !== undefined && vout !== null) {
144
+ if (!Number.isInteger(vout) || vout < 0 || vout >= tx.outputs.length) {
145
+ return null
146
+ }
147
+ var at = tx.outputs[vout].script
148
+ return NotaryScript.isNotaryHash(at) ? NotaryScript.parse(at) : null
149
+ }
150
+
135
151
  for (var i = 0; i < tx.outputs.length; i++) {
136
152
  var script = tx.outputs[i].script
137
153
  if (NotaryScript.isNotaryHash(script)) {
@@ -252,9 +268,9 @@ NotaryHash.verifyAnchorSPV = function (certificate, opts) {
252
268
  errors.push('rawTx does not hash to anchor.txid')
253
269
  }
254
270
 
255
- var record = NotaryHash.recordFromRawTx(spv.rawTx)
271
+ var record = NotaryHash.recordFromRawTx(spv.rawTx, c.anchor && c.anchor.vout)
256
272
  if (!record) {
257
- errors.push('no NotaryHash record found in rawTx')
273
+ errors.push('no NotaryHash record at anchor.vout in rawTx')
258
274
  } else if (!NotaryHash.recordMatchesCertificate(record, c)) {
259
275
  errors.push('on-chain record does not match the certificate')
260
276
  }
@@ -349,6 +365,48 @@ NotaryHash.verifyAnchorSPV = function (certificate, opts) {
349
365
  }
350
366
  }
351
367
 
368
+ // The anchor's own labels must agree with what was actually proved.
369
+ //
370
+ // `anchor.blockTime` and `anchor.blockHeight` are covered by no signature and were
371
+ // checked by nothing, so an edited certificate verified while reporting a different time
372
+ // or height than the header and proof establish. A reader shown "anchored at
373
+ // 2026-06-23T10:06:04Z in block 954784" has no reason to doubt either number.
374
+ //
375
+ // A null is not a claim: a certificate issued before confirmation legitimately carries
376
+ // nulls, and only a stated value is checked.
377
+ var headerBuf = Buffer.isBuffer(opts.header)
378
+ ? opts.header
379
+ : Buffer.from(String(opts.header).replace(/^0x/, ''), 'hex')
380
+ if (headerBuf.length === 80 && c.anchor) {
381
+ if (c.anchor.blockTime !== undefined && c.anchor.blockTime !== null) {
382
+ var headerTime = headerBuf.readUInt32LE(68)
383
+ if (Number(c.anchor.blockTime) !== headerTime) {
384
+ errors.push('anchor.blockTime ' + c.anchor.blockTime +
385
+ ' is not the time in the block header (' + headerTime + ')')
386
+ }
387
+ }
388
+ if (c.anchor.blockHeight !== undefined && c.anchor.blockHeight !== null &&
389
+ spv.blockHeight !== undefined && spv.blockHeight !== null &&
390
+ Number(c.anchor.blockHeight) !== Number(spv.blockHeight)) {
391
+ errors.push('anchor.blockHeight ' + c.anchor.blockHeight +
392
+ ' does not equal spv.blockHeight ' + spv.blockHeight)
393
+ }
394
+ }
395
+
396
+ // A TSC index must be representable by the path it comes with: a path of n nodes
397
+ // addresses at most 2^n leaves, so a larger index describes a tree the path cannot
398
+ // belong to. Unchecked, the index was another unsigned field that verified while naming
399
+ // an impossible position.
400
+ var mp = spv.merkleProof
401
+ if (mp && Array.isArray(mp.nodes) && mp.index !== undefined && mp.index !== null) {
402
+ var capacity = Math.pow(2, mp.nodes.length)
403
+ if (!Number.isInteger(Number(mp.index)) || Number(mp.index) < 0 ||
404
+ Number(mp.index) >= capacity) {
405
+ errors.push('spv.merkleProof.index ' + mp.index + ' does not fit a path of ' +
406
+ mp.nodes.length + ' nodes, which addresses at most ' + capacity + ' leaves')
407
+ }
408
+ }
409
+
352
410
  return { valid: errors.length === 0, errors: errors }
353
411
  } catch (e) {
354
412
  return { valid: false, errors: ['anchor verification error: ' + e.message] }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartledger/bsv",
3
- "version": "9.19.0",
3
+ "version": "9.20.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.19.0'
3
+ module.exports = '9.20.0'