@smartledger/bsv 8.0.0 → 8.1.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.
@@ -5,7 +5,7 @@ cryptographic core, and carries the enquiry text to send to vendors. It exists s
5
5
  every vendor prices the *same* thing, and so that the reasoning behind the scope
6
6
  boundary survives past the engagement that prompted it.
7
7
 
8
- Measured against **v8.0.0**, 2026-08-13. Re-measure before sending if the version has
8
+ Measured against **v8.1.0**, 2026-08-13. Re-measure before sending if the version has
9
9
  moved (`docs/AUDIT_SCOPE.md` is not covered by a drift gate).
10
10
 
11
11
  ## 1. The question we are asking
@@ -29,11 +29,11 @@ testing.
29
29
  Two tiers, to be **priced separately** so the boundary can be drawn against a number
30
30
  rather than before seeing one.
31
31
 
32
- ### Tier 1 — core, 12,254 lines across 33 files
32
+ ### Tier 1 — core, 12,268 lines across 33 files
33
33
 
34
34
  | Module | Lines | Why it matters |
35
35
  | --- | ---: | --- |
36
- | `lib/script/` | 3,737 | Consensus script interpreter. Divergence from the node means accepting a transaction the network rejects, or the reverse. |
36
+ | `lib/script/` | 3,751 | Consensus script interpreter. Divergence from the node means accepting a transaction the network rejects, or the reverse. |
37
37
  | `lib/transaction/` | 2,779 | Sighash construction and signing — both BIP-143 and the Original Transaction Digest Algorithm. |
38
38
  | `lib/crypto/` | 2,519 | ECDSA, nonce derivation, signature encoding, the script-number type. |
39
39
  | `lib/hdprivatekey.js`, `lib/hdpublickey.js` | 1,168 | BIP-32 derivation, including hardened paths. |
@@ -60,17 +60,17 @@ is not.
60
60
  | `@noble/curves`, `@noble/hashes`, `@noble/ciphers` | Already audited | The primitives come from the Noble libraries, which **Cure53 has audited and published on**. We do not implement curve or hash arithmetic ourselves. State this explicitly to vendors — otherwise they price work we do not need. |
61
61
  | `lib/smart_contract/`, `lib/ltp/`, `lib/gdaf/`, `lib/ordinals/`, `lib/block/`, plus 9 further directories and 6 top-level files | Excluded | Application layer, 22,815 lines — 18,435 in the five named modules and 4,380 in the remainder. Written in-house and covered by adversarial tests. Worth a separate engagement; including it here would blur the question in §1. |
62
62
 
63
- Totals reconcile against `lib/`, which is 36,676 lines across 123 files:
63
+ Totals reconcile against `lib/`, which is 36,690 lines across 123 files:
64
64
 
65
65
  ```
66
- tier 1 12,254
66
+ tier 1 12,268
67
67
  tier 2 1,607
68
68
  excluded 22,815
69
69
  ------
70
- total 36,676
70
+ total 36,690
71
71
  ```
72
72
 
73
- Core + optional = 13,861.
73
+ Core + optional = 13,875.
74
74
 
75
75
  ## 4. What an auditor gets on day one
76
76
 
@@ -133,7 +133,7 @@ seeking a quote for an independent security review of its cryptographic core.
133
133
 
134
134
  Scope, and we would like these priced separately:
135
135
 
136
- Tier 1 — 12,254 lines, 33 files. Script interpreter, sighash and signing,
136
+ Tier 1 — 12,268 lines, 33 files. Script interpreter, sighash and signing,
137
137
  ECDSA and signature encoding, BIP-32 derivation, key and address
138
138
  construction.
139
139
 
@@ -171,7 +171,7 @@ SmartLedger Technology
171
171
  Every figure in this document, including the excluded total, must come out of this
172
172
  script. **Derive the excluded count as the complement — never by subtracting tier 1
173
173
  alone.** The first draft did exactly that, double-counted tier 2, and published parts
174
- summing to 37,430 against a 36,676 whole; §7 could not catch it because it reproduced
174
+ summing to 37,430 against a 36,690 whole; §7 could not catch it because it reproduced
175
175
  every figure except the wrong one.
176
176
 
177
177
  ```sh
@@ -55,19 +55,19 @@ Three advanced modules totaling **~2.7MB** of functionality:
55
55
  - **Purpose**: Threshold cryptography for secure secret distribution
56
56
  - **Use Cases**: Backup keys, multi-party security, key recovery
57
57
  - **Features**: Split secrets into N shares, require M to reconstruct
58
- - **CDN**: `unpkg.com/@smartledger/bsv@8.0.0/bsv-shamir.min.js`
58
+ - **CDN**: `unpkg.com/@smartledger/bsv@8.1.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@8.0.0/bsv-gdaf.min.js`
64
+ - **CDN**: `unpkg.com/@smartledger/bsv@8.1.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@8.0.0/bsv-ltp.min.js`
70
+ - **CDN**: `unpkg.com/@smartledger/bsv@8.1.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@8.0.0/bsv.min.js` |
85
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@8.0.0/bsv.bundle.js` |
86
- | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@8.0.0/bsv-smartcontract.min.js` |
87
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@8.0.0/bsv-covenant.min.js` |
88
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@8.0.0/bsv-script-helper.min.js` |
89
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@8.0.0/bsv-security.min.js` |
90
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@8.0.0/bsv-ecies.min.js` |
91
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@8.0.0/bsv-message.min.js` |
92
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@8.0.0/bsv-mnemonic.min.js` |
93
- | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@8.0.0/bsv-shamir.min.js` |
94
- | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@8.0.0/bsv-gdaf.min.js` |
95
- | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@8.0.0/bsv-ltp.min.js` |
84
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@8.1.0/bsv.min.js` |
85
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@8.1.0/bsv.bundle.js` |
86
+ | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@8.1.0/bsv-smartcontract.min.js` |
87
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@8.1.0/bsv-covenant.min.js` |
88
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@8.1.0/bsv-script-helper.min.js` |
89
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@8.1.0/bsv-security.min.js` |
90
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@8.1.0/bsv-ecies.min.js` |
91
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@8.1.0/bsv-message.min.js` |
92
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@8.1.0/bsv-mnemonic.min.js` |
93
+ | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@8.1.0/bsv-shamir.min.js` |
94
+ | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@8.1.0/bsv-gdaf.min.js` |
95
+ | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@8.1.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@8.0.0/bsv.min.js"></script>
104
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-script-helper.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv.min.js"></script>
104
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.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@8.0.0/bsv.min.js"></script>
110
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-covenant.min.js"></script>
111
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-smartcontract.min.js"></script>
109
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv.min.js"></script>
110
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv-covenant.min.js"></script>
111
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.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@8.0.0/bsv.min.js"></script>
117
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-ltp.min.js"></script>
118
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-gdaf.min.js"></script>
116
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv.min.js"></script>
117
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv-ltp.min.js"></script>
118
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.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@8.0.0/bsv.min.js"></script>
136
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-security.min.js"></script>
137
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-shamir.min.js"></script>
135
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv-security.min.js"></script>
137
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.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@8.0.0/bsv.bundle.js"></script>
149
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.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@8.0.0/bsv.min.js"></script>
725
+ <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@8.1.0/bsv.min.js"></script>
726
726
  </head>
727
727
  <body>
728
728
  <script>
@@ -48,7 +48,7 @@ const tx: Transaction = new Transaction();
48
48
  #### **Core Library Only (937KB)**
49
49
  For basic Bitcoin SV operations:
50
50
  ```html
51
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv.min.js"></script>
51
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.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@8.0.0/bsv.bundle.js"></script>
61
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.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@8.0.0/bsv.min.js"></script>
75
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-covenant.min.js"></script>
76
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-smartcontract.min.js"></script>
74
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv.min.js"></script>
75
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv-covenant.min.js"></script>
76
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.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@8.0.0/bsv.min.js"></script>
86
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-ltp.min.js"></script>
87
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-gdaf.min.js"></script>
85
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv.min.js"></script>
86
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv-ltp.min.js"></script>
87
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.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@8.0.0/bsv.min.js"></script>
102
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-security.min.js"></script>
103
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-shamir.min.js"></script>
101
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv.min.js"></script>
102
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv-security.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.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@8.0.0/bsv.min.js` |
118
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@8.0.0/bsv.bundle.js` |
119
- | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@8.0.0/bsv-smartcontract.min.js` |
120
- | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@8.0.0/bsv-ltp.min.js` |
121
- | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@8.0.0/bsv-gdaf.min.js` |
122
- | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@8.0.0/bsv-shamir.min.js` |
123
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@8.0.0/bsv-security.min.js` |
124
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@8.0.0/bsv-mnemonic.min.js` |
125
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@8.0.0/bsv-ecies.min.js` |
126
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@8.0.0/bsv-covenant.min.js` |
127
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@8.0.0/bsv-script-helper.min.js` |
128
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@8.0.0/bsv-message.min.js` |
117
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@8.1.0/bsv.min.js` |
118
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@8.1.0/bsv.bundle.js` |
119
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@8.1.0/bsv-smartcontract.min.js` |
120
+ | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@8.1.0/bsv-ltp.min.js` |
121
+ | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@8.1.0/bsv-gdaf.min.js` |
122
+ | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@8.1.0/bsv-shamir.min.js` |
123
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@8.1.0/bsv-security.min.js` |
124
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@8.1.0/bsv-mnemonic.min.js` |
125
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@8.1.0/bsv-ecies.min.js` |
126
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@8.1.0/bsv-covenant.min.js` |
127
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@8.1.0/bsv-script-helper.min.js` |
128
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@8.1.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@8.0.0/bsv.min.js"></script>
17
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv.min.js"></script>
18
18
 
19
19
  <!-- Everything included (937KB) -->
20
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv.bundle.js"></script>
20
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.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@8.0.0/bsv.min.js"></script>
130
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv.min.js"></script>
131
131
 
132
132
  <!-- Smart contracts (937KB) -->
133
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-smartcontract.min.js"></script>
133
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv-smartcontract.min.js"></script>
134
134
 
135
135
  <!-- Legal tokens (1.16MB) -->
136
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-ltp.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv-ltp.min.js"></script>
137
137
 
138
138
  <!-- Digital identity (1.16MB) -->
139
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-gdaf.min.js"></script>
139
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv-gdaf.min.js"></script>
140
140
 
141
141
  <!-- Everything (937KB) -->
142
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv.bundle.js"></script>
142
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.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@8.0.0/bsv.min.js"></script>
162
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv.min.js"></script>
163
163
 
164
164
  <!-- Add smart contracts when ready -->
165
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-smartcontract.min.js"></script>
165
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv-smartcontract.min.js"></script>
166
166
 
167
167
  <!-- Add advanced features as needed -->
168
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-ltp.min.js"></script>
169
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv-gdaf.min.js"></script>
168
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv-ltp.min.js"></script>
169
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv-gdaf.min.js"></script>
170
170
 
171
171
  <!-- Everything in one file -->
172
- <script src="https://unpkg.com/@smartledger/bsv@8.0.0/bsv.bundle.js"></script>
172
+ <script src="https://unpkg.com/@smartledger/bsv@8.1.0/bsv.bundle.js"></script>
173
173
  ```
174
174
 
175
175
  ## 🔍 **Testing Your Migration**
@@ -268,11 +268,6 @@ Interpreter.MAX_SCRIPT_ELEMENT_SIZE = 520
268
268
  // operands through it, and Chronicle's shift bounds its result against it.
269
269
  Interpreter.MAXIMUM_ELEMENT_SIZE = 4
270
270
 
271
- // The script-number bound `useMainnetConsensus()` applies. Held separately from the
272
- // pre-Genesis default above so the two can diverge once the post-Genesis value is pinned
273
- // against the node source; see the note in useMainnetConsensus for why it is not simply
274
- // raised with the other caps.
275
- Interpreter.DEFAULT_SCRIPT_NUM_LENGTH = 4
276
271
  // Maximum number of non-push opcodes per script. Pre-Genesis consensus is 201;
277
272
  // post-Genesis BSV removed this limit. Exposed as a constant (instead of a magic
278
273
  // number) so applications can opt into post-Genesis rules — e.g. OP_PUSH_TX
@@ -327,9 +322,28 @@ Interpreter.LOCKTIME_THRESHOLD_BN = new BN(Interpreter.LOCKTIME_THRESHOLD)
327
322
  Interpreter.useGenesisLimits = function (max) {
328
323
  max = max || 0x7fffffff
329
324
  Interpreter.MAX_SCRIPT_ELEMENT_SIZE = max
330
- Interpreter.MAXIMUM_ELEMENT_SIZE = max
331
325
  Interpreter.MAX_OPS_PER_SCRIPT = max
332
326
  Interpreter.MAX_SCRIPT_SIZE = max
327
+
328
+ // MAXIMUM_ELEMENT_SIZE is deliberately NOT raised. It is CScriptNum's `max_length`,
329
+ // and since the limits became era-derived it serves only as the PRE-Genesis fallback
330
+ // for `maxScriptNumLength()` — post-Genesis is 750,000 and post-Chronicle 32,000,000,
331
+ // both reached through the era flags rather than this static.
332
+ //
333
+ // Raising it therefore could not enable post-Genesis arithmetic; it could only corrupt
334
+ // pre-Genesis validation, and it did. Measured, a 5-byte operand under
335
+ // P2SH,STRICTENC:
336
+ //
337
+ // fresh process: SCRIPT_ERR_SCRIPTNUM_OVERFLOW (what the node says)
338
+ // after useGenesisLimits(): ACCEPTED
339
+ //
340
+ // A false accept, in the direction that can cost money, produced by a process-wide
341
+ // side effect on unrelated code later in the same process. The node's own vectors
342
+ // agree: all 22 SCRIPTNUM_OVERFLOW rows are pre-Genesis, and raising this static turns
343
+ // 15 of them into false accepts.
344
+ //
345
+ // For post-Genesis arithmetic, pass the era — `Interpreter.mainnetFlags()`, or simply
346
+ // omit the flags argument, which now defaults to current mainnet.
333
347
  return Interpreter
334
348
  }
335
349
 
@@ -535,9 +549,16 @@ Interpreter.mainnetFlags = function (opts) {
535
549
  Interpreter.SCRIPT_VERIFY_MINIMALDATA |
536
550
  Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID |
537
551
  Interpreter.SCRIPT_ENABLE_MAGNETIC_OPCODES |
538
- Interpreter.SCRIPT_ENABLE_MONOLITH_OPCODES
552
+ Interpreter.SCRIPT_ENABLE_MONOLITH_OPCODES |
553
+ // The era flags. Without these the interpreter falls back to the pre-Genesis
554
+ // statics, so a validator built from a helper named after mainnet was applying
555
+ // 2019 limits — most sharply the 4-byte script-number bound, where post-Genesis
556
+ // is 750,000 and post-Chronicle 32,000,000. Genesis is unconditional here: it
557
+ // activated in 2020 and cannot be opted out of by anything still being spent.
558
+ Interpreter.SCRIPT_GENESIS |
559
+ Interpreter.SCRIPT_UTXO_AFTER_GENESIS
539
560
  if (opts.afterChronicle !== false) {
540
- flags |= Interpreter.SCRIPT_ENABLE_CHRONICLE
561
+ flags |= Interpreter.SCRIPT_ENABLE_CHRONICLE | Interpreter.SCRIPT_UTXO_AFTER_CHRONICLE
541
562
  }
542
563
  return flags
543
564
  }
@@ -601,25 +622,18 @@ Interpreter.useMainnetConsensus = function (opts) {
601
622
  opts = opts || {}
602
623
  Interpreter.useGenesisLimits(opts.max)
603
624
 
604
- // Restore a FINITE script-number bound. `useGenesisLimits()` raises all four caps to
605
- // the same ceiling, and for MAXIMUM_ELEMENT_SIZE — which is CScriptNum's `max_length`,
606
- // not a push-size cap — a ceiling of 0x7fffffff makes Chronicle's shift overflow check
607
- // unreachable, because it tests `current_size + shift_bytes > max_length`. Measured:
608
- //
609
- // default limits: SCRIPT_ERR_SCRIPTNUM_OVERFLOW (correct)
610
- // after useGenesisLimits(): valid, grows without bound (WRONG)
611
- //
612
- // A validator looser than consensus accepts what the network rejects, so the ceiling
613
- // cannot be right whatever the true post-Genesis value turns out to be.
625
+ // The script-number bound is NOT set here. It is era-derived from the flags by
626
+ // Interpreter#maxScriptNumLength(): 4 bytes pre-Genesis, 750,000 after Genesis,
627
+ // 32,000,000 after Chronicle. An earlier version of this function pinned
628
+ // MAXIMUM_ELEMENT_SIZE to a static value to stop useGenesisLimits() raising it to
629
+ // 0x7fffffff, which made Chronicle's shift-overflow check unreachable. That was
630
+ // treating the symptom: the real defect was mainnetFlags() omitting the era flags,
631
+ // so the era-derived bound never applied. Fixed there instead.
614
632
  //
615
- // The true value is NOT settled here. Genesis raised this bound above the pre-Genesis
616
- // 4 bytes, so the conservative default below is stricter than mainnet for wide
617
- // arithmetic — the same class of error #112 fixed, in the opposite direction. It is
618
- // chosen deliberately: given a choice between rejecting a valid script and accepting
619
- // an invalid one, this library fails closed. Callers who know the bound their workload
620
- // needs should pass `maxScriptNumLength` explicitly, and the value should be pinned
621
- // against the SV Node source before this default changes.
622
- Interpreter.MAXIMUM_ELEMENT_SIZE = opts.maxScriptNumLength || Interpreter.DEFAULT_SCRIPT_NUM_LENGTH
633
+ // The node's vectors settle the pre-Genesis value at 4 and are silent on the rest —
634
+ // all 22 SCRIPTNUM_OVERFLOW rows carry P2SH,STRICTENC and no era flag. Raising the
635
+ // static bound to 8 turns 15 of them into false accepts, which is how that was
636
+ // measured.
623
637
 
624
638
  return Interpreter.mainnetFlags(opts)
625
639
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartledger/bsv",
3
- "version": "8.0.0",
3
+ "version": "8.1.0",
4
4
  "description": "🚀 Complete Bitcoin SV development framework with legally-recognizable DID:web + W3C VC-JWT toolkit, Legal Token Protocol (LTP), Global Digital Attestation Framework (GDAF), StatusList2021 revocation, and 16 flexible loading options. Standards-based credentials with ES256/ES256K support, on-chain BSV anchoring, and comprehensive Bitcoin SV API. Perfect for legal tokens, verifiable credentials, DeFi, smart contracts, and secure Bitcoin applications.",
5
5
  "author": "SmartLedger Technology <hello@smartledger.technology> (https://smartledger.technology)",
6
6
  "homepage": "https://github.com/codenlighten/smartledger-bsv#readme",
@@ -91,3 +91,70 @@ describe('verify() consensus defaults', function () {
91
91
  })
92
92
  })
93
93
  })
94
+
95
+ // The script-number bound is era-derived, not a process-wide static.
96
+ //
97
+ // `mainnetFlags()` omitted every era flag except SCRIPT_ENABLE_CHRONICLE, so
98
+ // `maxScriptNumLength()` fell back to the pre-Genesis 4 for a validator built from the
99
+ // helper named after mainnet — while post-Genesis is 750,000 and post-Chronicle
100
+ // 32,000,000. An earlier fix pinned MAXIMUM_ELEMENT_SIZE to stop useGenesisLimits()
101
+ // raising it to 0x7fffffff and making Chronicle's shift-overflow check unreachable; that
102
+ // treated the symptom rather than the missing flags.
103
+ //
104
+ // The node's vectors settle the pre-Genesis value at 4 and are silent above it: all 22
105
+ // SCRIPTNUM_OVERFLOW rows carry P2SH,STRICTENC and no era flag, and raising the static
106
+ // bound to 8 turns 15 of them into false accepts.
107
+ describe('script-number bound follows the era', function () {
108
+ function boundFor (flags) {
109
+ var i = new Interpreter()
110
+ i.set({ flags: flags })
111
+ return i.maxScriptNumLength()
112
+ }
113
+
114
+ it('is 4 before Genesis, which the node vectors pin', function () {
115
+ boundFor(0).should.equal(4)
116
+ })
117
+
118
+ it('is the post-Genesis figure when only Genesis is asked for', function () {
119
+ boundFor(Interpreter.mainnetFlags({ afterChronicle: false }))
120
+ .should.equal(Interpreter.MAX_SCRIPT_NUM_LENGTH_AFTER_GENESIS)
121
+ })
122
+
123
+ it('is the post-Chronicle figure under mainnetFlags() and the default', function () {
124
+ boundFor(Interpreter.mainnetFlags())
125
+ .should.equal(Interpreter.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE)
126
+ boundFor(Interpreter.currentConsensusFlags())
127
+ .should.equal(Interpreter.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE)
128
+ })
129
+
130
+ // Genesis activated in 2020 and nothing still spendable predates it in a way that
131
+ // makes a mainnet helper want the older limits, so it is not opt-out-able here.
132
+ it('carries the Genesis era flags in mainnetFlags(), both variants', function () {
133
+ ;[Interpreter.mainnetFlags(), Interpreter.mainnetFlags({ afterChronicle: false })].forEach(function (f) {
134
+ (f & Interpreter.SCRIPT_GENESIS).should.equal(Interpreter.SCRIPT_GENESIS)
135
+ ;(f & Interpreter.SCRIPT_UTXO_AFTER_GENESIS).should.equal(Interpreter.SCRIPT_UTXO_AFTER_GENESIS)
136
+ })
137
+ })
138
+
139
+ it('drops only the Chronicle pair for a pre-activation UTXO', function () {
140
+ var pre = Interpreter.mainnetFlags({ afterChronicle: false })
141
+ ;(pre & Interpreter.SCRIPT_ENABLE_CHRONICLE).should.equal(0)
142
+ ;(pre & Interpreter.SCRIPT_UTXO_AFTER_CHRONICLE).should.equal(0)
143
+ })
144
+
145
+ // useMainnetConsensus() must no longer pin the static; the flags carry the bound.
146
+ //
147
+ // The limits are process-wide statics, so this saves and restores them. Without the
148
+ // restore the raised caps leak into every later test in the same mocha process — 24 of
149
+ // them, when this was first written, including the inherited pre-Genesis bitcoind
150
+ // vectors. The same trap #114 hit and documented.
151
+ it('is not overridden by useMainnetConsensus()', function () {
152
+ var saved = Interpreter.getLimits()
153
+ try {
154
+ var flags = Interpreter.useMainnetConsensus()
155
+ boundFor(flags).should.equal(Interpreter.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE)
156
+ } finally {
157
+ Interpreter.setLimits(saved)
158
+ }
159
+ })
160
+ })
@@ -3,6 +3,7 @@
3
3
  /* global describe, it, beforeEach, afterEach */
4
4
  var should = require('chai').should()
5
5
  var bsv = require('../..')
6
+ var BN = bsv.crypto.BN
6
7
  var Interpreter = bsv.Script.Interpreter
7
8
  var Script = bsv.Script
8
9
  var Opcode = bsv.Opcode
@@ -28,11 +29,30 @@ describe('Interpreter post-Genesis limits', function () {
28
29
  Interpreter.MAX_OPS_PER_SCRIPT.should.equal(500)
29
30
  })
30
31
 
31
- it('useGenesisLimits() lifts all three caps', function () {
32
+ // MAXIMUM_ELEMENT_SIZE is no longer among them. It is CScriptNum's max_length, and
33
+ // since the limits became era-derived it is only the PRE-Genesis fallback — raising it
34
+ // could not enable post-Genesis arithmetic, only corrupt pre-Genesis validation.
35
+ it('useGenesisLimits() lifts the size caps but not the script-number bound', function () {
32
36
  Interpreter.useGenesisLimits()
33
37
  Interpreter.MAX_SCRIPT_ELEMENT_SIZE.should.equal(0x7fffffff)
34
- Interpreter.MAXIMUM_ELEMENT_SIZE.should.equal(0x7fffffff)
35
38
  Interpreter.MAX_OPS_PER_SCRIPT.should.equal(0x7fffffff)
39
+ Interpreter.MAXIMUM_ELEMENT_SIZE.should.equal(4)
40
+ })
41
+
42
+ // The reason it must not be raised, stated as a test: a 5-byte operand is an overflow
43
+ // before Genesis, and no process-wide call may turn that into an accept.
44
+ it('cannot be made to accept a pre-Genesis script-number overflow', function () {
45
+ var overflow = new Script()
46
+ .add(Buffer.from('1234567890', 'hex'))
47
+ .add(Buffer.from([2]))
48
+ .add(Opcode.OP_MUL)
49
+ var flags = Interpreter.SCRIPT_VERIFY_P2SH | Interpreter.SCRIPT_VERIFY_STRICTENC |
50
+ Interpreter.SCRIPT_ENABLE_MONOLITH_OPCODES | Interpreter.SCRIPT_ENABLE_MAGNETIC_OPCODES
51
+ Interpreter.useGenesisLimits()
52
+ var interp = new Interpreter()
53
+ interp.verify(new Script(), overflow, new bsv.Transaction(), 0, flags, new BN(0))
54
+ .should.equal(false)
55
+ interp.errstr.should.equal('SCRIPT_ERR_SCRIPTNUM_OVERFLOW')
36
56
  })
37
57
 
38
58
  // <2^32> <2^32> OP_ADD <2^33> OP_NUMEQUAL — operands exceed the 4-byte cap.
@@ -54,9 +74,18 @@ describe('Interpreter post-Genesis limits', function () {
54
74
  run(bigAdd).should.equal(false)
55
75
  })
56
76
 
57
- it('allows >4-byte arithmetic after useGenesisLimits()', function () {
77
+ // Post-Genesis arithmetic is reached through the ERA, not through the static. Before
78
+ // the limits became era-derived, useGenesisLimits() was the only route; it no longer
79
+ // is, and using it for this would corrupt pre-Genesis validation elsewhere.
80
+ it('allows >4-byte arithmetic when the post-Genesis era is asked for', function () {
81
+ var interp = new Interpreter()
82
+ interp.verify(new Script(), bigAdd, new bsv.Transaction(), 0,
83
+ Interpreter.mainnetFlags(), new BN(0)).should.equal(true)
84
+ })
85
+
86
+ it('still rejects it under pre-Genesis rules, whatever the statics say', function () {
58
87
  Interpreter.useGenesisLimits()
59
- run(bigAdd).should.equal(true)
88
+ run(bigAdd).should.equal(false)
60
89
  })
61
90
 
62
91
  // 220 OP_NOPs then OP_1 — more non-push opcodes than the 201 cap allows.
@@ -156,14 +185,16 @@ describe('Interpreter post-Genesis limits', function () {
156
185
  })
157
186
  })
158
187
 
159
- it('useGenesisLimits raises all four caps, and getLimits/setLimits round-trip', function () {
188
+ it('useGenesisLimits raises the size caps, and getLimits/setLimits round-trip', function () {
160
189
  var before = Interpreter.getLimits()
161
190
  before.maxScriptSize.should.equal(10000)
162
191
  Interpreter.useGenesisLimits(64 * 1024)
163
192
  var after = Interpreter.getLimits()
164
193
  after.maxScriptElementSize.should.equal(64 * 1024)
165
- after.maximumElementSize.should.equal(64 * 1024)
166
194
  after.maxOpsPerScript.should.equal(64 * 1024)
195
+ // Not raised — see the note on useGenesisLimits. setLimits() can still set it
196
+ // explicitly, which is what the round-trip below checks.
197
+ after.maximumElementSize.should.equal(4)
167
198
  after.maxScriptSize.should.equal(64 * 1024)
168
199
  Interpreter.setLimits(before)
169
200
  Interpreter.getLimits().maxScriptSize.should.equal(10000)
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 = '8.0.0'
3
+ module.exports = '8.1.0'