@smartledger/bsv 9.14.0 → 9.15.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,12 +34,12 @@ 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,089 lines
37
+ ### Tier 1 — 12,158 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
- | `lib/script/interpreter.js` | 2,851 | **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. |
42
+ | `lib/script/interpreter.js` | 2,920 | **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
44
  | `lib/notaryhash/` | 2,104 | 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. |
@@ -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,112 lines across 131 files:
153
+ Totals reconcile against `lib/`, which is 40,181 lines across 131 files:
154
154
 
155
155
  ```
156
- tier 1 12,089
156
+ tier 1 12,158
157
157
  tier 2 1,607
158
158
  excluded 26,416
159
159
  ------
160
- total 40,112
160
+ total 40,181
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,089 lines. Sighash construction and signing; ECDSA, nonce
231
+ Tier 1 — 12,158 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.14.0/bsv-shamir.min.js`
58
+ - **CDN**: `unpkg.com/@smartledger/bsv@9.15.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.14.0/bsv-gdaf.min.js`
64
+ - **CDN**: `unpkg.com/@smartledger/bsv@9.15.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.14.0/bsv-ltp.min.js`
70
+ - **CDN**: `unpkg.com/@smartledger/bsv@9.15.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.14.0/bsv.min.js` |
85
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.14.0/bsv.bundle.js` |
86
- | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@9.14.0/bsv-smartcontract.min.js` |
87
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.14.0/bsv-covenant.min.js` |
88
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.14.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.14.0/bsv-security.min.js` |
90
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@9.14.0/bsv-ecies.min.js` |
91
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@9.14.0/bsv-message.min.js` |
92
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@9.14.0/bsv-mnemonic.min.js` |
93
- | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@9.14.0/bsv-shamir.min.js` |
94
- | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@9.14.0/bsv-gdaf.min.js` |
95
- | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@9.14.0/bsv-ltp.min.js` |
84
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.15.0/bsv.min.js` |
85
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.15.0/bsv.bundle.js` |
86
+ | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@9.15.0/bsv-smartcontract.min.js` |
87
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.15.0/bsv-covenant.min.js` |
88
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.15.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.15.0/bsv-security.min.js` |
90
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@9.15.0/bsv-ecies.min.js` |
91
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@9.15.0/bsv-message.min.js` |
92
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@9.15.0/bsv-mnemonic.min.js` |
93
+ | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@9.15.0/bsv-shamir.min.js` |
94
+ | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@9.15.0/bsv-gdaf.min.js` |
95
+ | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@9.15.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.14.0/bsv.min.js"></script>
104
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-script-helper.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv.min.js"></script>
104
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.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.14.0/bsv.min.js"></script>
110
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-covenant.min.js"></script>
111
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-smartcontract.min.js"></script>
109
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv.min.js"></script>
110
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv-covenant.min.js"></script>
111
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.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.14.0/bsv.min.js"></script>
117
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-ltp.min.js"></script>
118
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-gdaf.min.js"></script>
116
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv.min.js"></script>
117
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv-ltp.min.js"></script>
118
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.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.14.0/bsv.min.js"></script>
136
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-security.min.js"></script>
137
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-shamir.min.js"></script>
135
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv-security.min.js"></script>
137
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.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.14.0/bsv.bundle.js"></script>
149
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.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.14.0/bsv.min.js"></script>
725
+ <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@9.15.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,089 lines. Sighash construction and signing; ECDSA, nonce
18
+ Tier 1 — 12,158 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,089 lines. Sighash construction and signing; ECDSA, nonce
18
+ Tier 1 — 12,158 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,089 lines. Sighash construction and signing; ECDSA, nonce
18
+ Tier 1 — 12,158 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.14.0/bsv.min.js"></script>
51
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.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.14.0/bsv.bundle.js"></script>
61
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.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.14.0/bsv.min.js"></script>
75
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-covenant.min.js"></script>
76
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-smartcontract.min.js"></script>
74
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv.min.js"></script>
75
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv-covenant.min.js"></script>
76
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.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.14.0/bsv.min.js"></script>
86
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-ltp.min.js"></script>
87
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-gdaf.min.js"></script>
85
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv.min.js"></script>
86
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv-ltp.min.js"></script>
87
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.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.14.0/bsv.min.js"></script>
102
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-security.min.js"></script>
103
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-shamir.min.js"></script>
101
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv.min.js"></script>
102
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv-security.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.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.14.0/bsv.min.js` |
118
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.14.0/bsv.bundle.js` |
119
- | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@9.14.0/bsv-smartcontract.min.js` |
120
- | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@9.14.0/bsv-ltp.min.js` |
121
- | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@9.14.0/bsv-gdaf.min.js` |
122
- | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@9.14.0/bsv-shamir.min.js` |
123
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@9.14.0/bsv-security.min.js` |
124
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@9.14.0/bsv-mnemonic.min.js` |
125
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@9.14.0/bsv-ecies.min.js` |
126
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.14.0/bsv-covenant.min.js` |
127
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.14.0/bsv-script-helper.min.js` |
128
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@9.14.0/bsv-message.min.js` |
117
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.15.0/bsv.min.js` |
118
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.15.0/bsv.bundle.js` |
119
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@9.15.0/bsv-smartcontract.min.js` |
120
+ | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@9.15.0/bsv-ltp.min.js` |
121
+ | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@9.15.0/bsv-gdaf.min.js` |
122
+ | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@9.15.0/bsv-shamir.min.js` |
123
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@9.15.0/bsv-security.min.js` |
124
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@9.15.0/bsv-mnemonic.min.js` |
125
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@9.15.0/bsv-ecies.min.js` |
126
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.15.0/bsv-covenant.min.js` |
127
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.15.0/bsv-script-helper.min.js` |
128
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@9.15.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.14.0/bsv.min.js"></script>
17
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv.min.js"></script>
18
18
 
19
19
  <!-- Everything included (937KB) -->
20
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv.bundle.js"></script>
20
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.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.14.0/bsv.min.js"></script>
130
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv.min.js"></script>
131
131
 
132
132
  <!-- Smart contracts (937KB) -->
133
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-smartcontract.min.js"></script>
133
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv-smartcontract.min.js"></script>
134
134
 
135
135
  <!-- Legal tokens (1.16MB) -->
136
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-ltp.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv-ltp.min.js"></script>
137
137
 
138
138
  <!-- Digital identity (1.16MB) -->
139
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-gdaf.min.js"></script>
139
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv-gdaf.min.js"></script>
140
140
 
141
141
  <!-- Everything (937KB) -->
142
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv.bundle.js"></script>
142
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.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.14.0/bsv.min.js"></script>
162
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv.min.js"></script>
163
163
 
164
164
  <!-- Add smart contracts when ready -->
165
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-smartcontract.min.js"></script>
165
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv-smartcontract.min.js"></script>
166
166
 
167
167
  <!-- Add advanced features as needed -->
168
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-ltp.min.js"></script>
169
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv-gdaf.min.js"></script>
168
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv-ltp.min.js"></script>
169
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv-gdaf.min.js"></script>
170
170
 
171
171
  <!-- Everything in one file -->
172
- <script src="https://unpkg.com/@smartledger/bsv@9.14.0/bsv.bundle.js"></script>
172
+ <script src="https://unpkg.com/@smartledger/bsv@9.15.0/bsv.bundle.js"></script>
173
173
  ```
174
174
 
175
175
  ## 🔍 **Testing Your Migration**
@@ -98,11 +98,34 @@ Interpreter.prototype._verifyCore = function (scriptSig, scriptPubkey, tx, nin,
98
98
  })
99
99
  var stackCopy
100
100
 
101
- if ((flags & Interpreter.SCRIPT_VERIFY_SIGPUSHONLY) !== 0 && !scriptSig.isPushOnly()) {
102
- this.errstr = 'SCRIPT_ERR_SIG_PUSHONLY'
101
+ // A UTXO cannot be post-Chronicle without being post-Genesis. The node refuses the
102
+ // combination outright (valid_flags, interpreter.cpp) rather than picking an era.
103
+ if ((flags & Interpreter.SCRIPT_UTXO_AFTER_CHRONICLE) !== 0 &&
104
+ (flags & Interpreter.SCRIPT_UTXO_AFTER_GENESIS) === 0) {
105
+ this.errstr = 'SCRIPT_ERR_INVALID_FLAGS'
103
106
  return false
104
107
  }
105
108
 
109
+ // SIGPUSHONLY is a rule of an era, not of the flag alone:
110
+ //
111
+ // if((IsGenesis(flags) && !IsChronicle(flags)) ||
112
+ // (IsChronicle(flags) && !IsMalleableTxnVersion(checker.Version())))
113
+ //
114
+ // Before Genesis this branch refused nothing — a non-push scriptSig was caught only where
115
+ // P2SH demanded it, below — and the node never sets the flag there anyway
116
+ // (InputScriptVerifyFlags adds it only once the block era is post-Genesis). Under
117
+ // Chronicle it survives as a non-malleability rule, so a malleable version is exempt,
118
+ // and that case DOES arise on today's mainnet flags.
119
+ if ((flags & Interpreter.SCRIPT_VERIFY_SIGPUSHONLY) !== 0) {
120
+ var chronicleBlock = (flags & Interpreter.SCRIPT_CHRONICLE) !== 0
121
+ var pushOnlyRequired = (((flags & Interpreter.SCRIPT_GENESIS) !== 0) && !chronicleBlock) ||
122
+ (chronicleBlock && enforcesNonMalleability(flags, tx))
123
+ if (pushOnlyRequired && !scriptSig.isPushOnly()) {
124
+ this.errstr = 'SCRIPT_ERR_SIG_PUSHONLY'
125
+ return false
126
+ }
127
+ }
128
+
106
129
  // evaluate scriptSig
107
130
  if (!this.evaluate()) {
108
131
  return false
@@ -197,18 +220,25 @@ Interpreter.prototype._verifyCore = function (scriptSig, scriptPubkey, tx, nin,
197
220
  // Disallow CLEANSTACK without P2SH, as otherwise a switch
198
221
  // CLEANSTACK->P2SH+CLEANSTACK would be possible, which is not a
199
222
  // softfork (and P2SH should be one).
200
- // Genesis removed P2SH, so post-Genesis the pairing no longer applies and
201
- // CLEANSTACK stands on its own.
202
- if ((flags & Interpreter.SCRIPT_VERIFY_P2SH) === 0 &&
203
- (flags & Interpreter.SCRIPT_UTXO_AFTER_GENESIS) === 0) {
204
- throw new Error('internal error - CLEANSTACK without P2SH')
223
+ // The flags come from a caller, so this is a bad request rather than a broken
224
+ // invariant. The node names it (SCRIPT_ERR_INVALID_FLAGS); throwing turned a verdict
225
+ // into a crash. It requires the P2SH flag in every era, including after Genesis removed
226
+ // P2SH, and its own corpus never reaches this branch because the harness adds the flag
227
+ // (`if(flags & SCRIPT_VERIFY_CLEANSTACK) flags |= SCRIPT_VERIFY_P2SH;` in DoTest,
228
+ // src/test/script_tests.cpp) — which is why this used to carry a post-Genesis carve-out
229
+ // that let the pair through. That was ours, not the node's.
230
+ if ((flags & Interpreter.SCRIPT_VERIFY_P2SH) === 0) {
231
+ this.errstr = 'SCRIPT_ERR_INVALID_FLAGS'
232
+ return false
205
233
  }
206
234
 
207
235
  // The final stack. After a P2SH evaluation that is stackCopy itself, since
208
236
  // the redeem script was evaluated over it, but reading stackCopy directly
209
237
  // is wrong once P2SH no longer applies: it is then either the stack as it
210
238
  // stood after the scriptSig, or never assigned at all.
211
- if (this.stack.length !== 1) {
239
+ // Clean stack was only ever a policy rule, never consensus, so Chronicle ties it to
240
+ // the transaction version rather than to the age of the output being spent.
241
+ if (this.enforceNonMalleability() && this.stack.length !== 1) {
212
242
  this.errstr = 'SCRIPT_ERR_CLEANSTACK'
213
243
  return false
214
244
  }
@@ -841,6 +871,37 @@ Interpreter.castToBool = function (buf) {
841
871
  /**
842
872
  * Translated from bitcoind's CheckSignatureEncoding
843
873
  */
874
+ /**
875
+ * Chronicle lets a transaction opt into malleability by using a version above 1, and the
876
+ * rules that exist only to stop a signed transaction being rewritten in flight then stop
877
+ * applying to it. The node's EnforceNonMalleability(flags, checker.Version()):
878
+ *
879
+ * return !(IsChronicle(flags) && IsMalleableTxnVersion(txnVersion)); // version > 1
880
+ *
881
+ * It gates LOW_S, MINIMALDATA, MINIMALIF, NULLFAIL, NULLDUMMY, SIGPUSHONLY and CLEANSTACK.
882
+ * Note which era flag it reads: SCRIPT_CHRONICLE, the era of the block being built, not
883
+ * SCRIPT_UTXO_AFTER_CHRONICLE, the era of the output being spent.
884
+ *
885
+ * Every version at or below 1 is non-malleable, so the rules apply; a missing transaction
886
+ * is treated the same way, which is the enforcing answer.
887
+ */
888
+ function enforcesNonMalleability (flags, tx) {
889
+ if ((flags & Interpreter.SCRIPT_CHRONICLE) === 0) {
890
+ return true
891
+ }
892
+ // int32, as CTransaction::nVersion is and as checker.Version() returns it. Comparing the
893
+ // JS number would read a version of 0xffffffff as 4294967295 and call the transaction
894
+ // malleable, where the node reads -1 and enforces. Such a version cannot arrive from the
895
+ // network — writeInt32LE refuses it and readInt32LE has already signed anything parsed —
896
+ // but a caller can set it in code, and the fail-open reading is the wrong one to have.
897
+ // With no transaction at all the rules apply: BaseSignatureChecker::Version() returns 0.
898
+ return !(tx && ((tx.version | 0) > 1))
899
+ }
900
+
901
+ Interpreter.prototype.enforceNonMalleability = function () {
902
+ return enforcesNonMalleability(this.flags, this.tx)
903
+ }
904
+
844
905
  Interpreter.prototype.checkSignatureEncoding = function (buf) {
845
906
  var sig
846
907
 
@@ -850,16 +911,26 @@ Interpreter.prototype.checkSignatureEncoding = function (buf) {
850
911
  return true
851
912
  }
852
913
 
914
+ // Three independent checks, as CheckSignatureEncoding has them. They used to be chained
915
+ // with else-if, so LOW_S — which mainnetFlags() and currentConsensusFlags() both set —
916
+ // returned early and the whole STRICTENC block below never ran. On the library's own
917
+ // default flags that silently accepted a signature with an undefined hash type, one
918
+ // without FORKID where FORKID is required, and one asking for the Chronicle digest
919
+ // outside Chronicle: three things the node refuses by name.
853
920
  if ((this.flags & (Interpreter.SCRIPT_VERIFY_DERSIG | Interpreter.SCRIPT_VERIFY_LOW_S | Interpreter.SCRIPT_VERIFY_STRICTENC)) !== 0 && !Signature.isTxDER(buf)) {
854
921
  this.errstr = 'SCRIPT_ERR_SIG_DER_INVALID_FORMAT'
855
922
  return false
856
- } else if ((this.flags & Interpreter.SCRIPT_VERIFY_LOW_S) !== 0) {
923
+ }
924
+
925
+ if ((this.flags & Interpreter.SCRIPT_VERIFY_LOW_S) !== 0) {
857
926
  sig = Signature.fromTxFormat(buf)
858
- if (!sig.hasLowS()) {
927
+ if (!sig.hasLowS() && this.enforceNonMalleability()) {
859
928
  this.errstr = 'SCRIPT_ERR_SIG_DER_HIGH_S'
860
929
  return false
861
930
  }
862
- } else if ((this.flags & Interpreter.SCRIPT_VERIFY_STRICTENC) !== 0) {
931
+ }
932
+
933
+ if ((this.flags & Interpreter.SCRIPT_VERIFY_STRICTENC) !== 0) {
863
934
  sig = Signature.fromTxFormat(buf)
864
935
  if (!sig.hasDefinedHashtype()) {
865
936
  this.errstr = 'SCRIPT_ERR_SIG_HASHTYPE'
@@ -1384,7 +1455,8 @@ Interpreter.prototype.step = function () {
1384
1455
  return false
1385
1456
  }
1386
1457
 
1387
- var fRequireMinimal = (this.flags & Interpreter.SCRIPT_VERIFY_MINIMALDATA) !== 0
1458
+ var fRequireMinimal = (this.flags & Interpreter.SCRIPT_VERIFY_MINIMALDATA) !== 0 &&
1459
+ this.enforceNonMalleability()
1388
1460
 
1389
1461
  var buf, buf1, buf2, spliced, n, x1, x2, bn, bn1, bn2, bufSig, bufPubkey, subscript
1390
1462
  var sig, pubkey
@@ -1770,15 +1842,11 @@ Interpreter.prototype.step = function () {
1770
1842
  }
1771
1843
  buf = stacktop(-1)
1772
1844
 
1773
- if (this.flags & Interpreter.SCRIPT_VERIFY_MINIMALIF) {
1774
- if (buf.length > 1) {
1775
- this.errstr = 'SCRIPT_ERR_MINIMALIF'
1776
- return false
1777
- }
1778
- if (buf.length === 1 && buf[0] !== 1) {
1779
- this.errstr = 'SCRIPT_ERR_MINIMALIF'
1780
- return false
1781
- }
1845
+ if ((this.flags & Interpreter.SCRIPT_VERIFY_MINIMALIF) &&
1846
+ (buf.length > 1 || (buf.length === 1 && buf[0] !== 1)) &&
1847
+ this.enforceNonMalleability()) {
1848
+ this.errstr = 'SCRIPT_ERR_MINIMALIF'
1849
+ return false
1782
1850
  }
1783
1851
  fValue = Interpreter.castToBool(buf)
1784
1852
  if (opcodenum === Opcode.OP_NOTIF) {
@@ -2457,7 +2525,7 @@ Interpreter.prototype.step = function () {
2457
2525
  }
2458
2526
 
2459
2527
  if (!fSuccess && (this.flags & Interpreter.SCRIPT_VERIFY_NULLFAIL) &&
2460
- bufSig.length) {
2528
+ bufSig.length && this.enforceNonMalleability()) {
2461
2529
  this.errstr = 'SCRIPT_ERR_NULLFAIL'
2462
2530
  return false
2463
2531
  }
@@ -2583,7 +2651,7 @@ Interpreter.prototype.step = function () {
2583
2651
  // Clean up stack of actual arguments
2584
2652
  while (i-- > 1) {
2585
2653
  if (!fSuccess && (this.flags & Interpreter.SCRIPT_VERIFY_NULLFAIL) &&
2586
- !ikey2 && stacktop(-1).length) {
2654
+ !ikey2 && stacktop(-1).length && this.enforceNonMalleability()) {
2587
2655
  this.errstr = 'SCRIPT_ERR_NULLFAIL'
2588
2656
  return false
2589
2657
  }
@@ -2605,7 +2673,8 @@ Interpreter.prototype.step = function () {
2605
2673
  this.errstr = 'SCRIPT_ERR_INVALID_STACK_OPERATION'
2606
2674
  return false
2607
2675
  }
2608
- if ((this.flags & Interpreter.SCRIPT_VERIFY_NULLDUMMY) && stacktop(-1).length) {
2676
+ if ((this.flags & Interpreter.SCRIPT_VERIFY_NULLDUMMY) && stacktop(-1).length &&
2677
+ this.enforceNonMalleability()) {
2609
2678
  this.errstr = 'SCRIPT_ERR_SIG_NULLDUMMY'
2610
2679
  return false
2611
2680
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartledger/bsv",
3
- "version": "9.14.0",
3
+ "version": "9.15.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",
@@ -184,6 +184,17 @@ function classifyFlags (flagStr) {
184
184
  * only the spending transaction carries the version under test.
185
185
  */
186
186
  function evaluate (row, flags) {
187
+ // DoTest's one flag adjustment, which the rows themselves do not state:
188
+ //
189
+ // if(flags & SCRIPT_VERIFY_CLEANSTACK) flags |= SCRIPT_VERIFY_P2SH;
190
+ //
191
+ // Without it a row naming CLEANSTACK alone is verified under a flag set the node refuses
192
+ // outright, so it fails for the wrong reason and the row silently stops testing clean
193
+ // stacks at all.
194
+ if ((flags & Interpreter.SCRIPT_VERIFY_CLEANSTACK) !== 0) {
195
+ flags |= Interpreter.SCRIPT_VERIFY_P2SH
196
+ }
197
+
187
198
  const scriptSig = fromBitcoindString(row.scriptSig)
188
199
  const scriptPubKey = fromBitcoindString(row.scriptPubKey)
189
200
 
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.14.0'
3
+ module.exports = '9.15.0'