@smartledger/bsv 7.12.0 → 7.13.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,8 +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 **v7.12.0**, 2026-08-10 (`lib/` is byte-identical to v7.11.0, where these
9
- figures were first taken). Re-measure before sending if the version has
8
+ Measured against **v7.13.0**, 2026-08-11. Re-measure before sending if the version has
10
9
  moved (`docs/AUDIT_SCOPE.md` is not covered by a drift gate).
11
10
 
12
11
  ## 1. The question we are asking
@@ -30,24 +29,24 @@ testing.
30
29
  Two tiers, to be **priced separately** so the boundary can be drawn against a number
31
30
  rather than before seeing one.
32
31
 
33
- ### Tier 1 — core, 11,739 lines across 33 files
32
+ ### Tier 1 — core, 11,879 lines across 33 files
34
33
 
35
34
  | Module | Lines | Why it matters |
36
35
  | --- | ---: | --- |
37
- | `lib/script/` | 3,375 | Consensus script interpreter. Divergence from the node means accepting a transaction the network rejects, or the reverse. |
36
+ | `lib/script/` | 3,394 | Consensus script interpreter. Divergence from the node means accepting a transaction the network rejects, or the reverse. |
38
37
  | `lib/transaction/` | 2,767 | Sighash construction and signing — both BIP-143 and the Original Transaction Digest Algorithm. |
39
- | `lib/crypto/` | 2,378 | ECDSA, nonce derivation, signature encoding, the script-number type. |
38
+ | `lib/crypto/` | 2,499 | ECDSA, nonce derivation, signature encoding, the script-number type. |
40
39
  | `lib/hdprivatekey.js`, `lib/hdpublickey.js` | 1,168 | BIP-32 derivation, including hardened paths. |
41
40
  | `lib/privatekey.js`, `lib/publickey.js` | 843 | Key construction, serialisation, WIF. Recent defects here produced a *different* key without error. |
42
41
  | `lib/address.js` | 543 | Address derivation and network binding. |
43
42
  | `lib/networks.js`, `lib/opcode.js` | 665 | Network parameters and the opcode table, which BSV upgrades have reassigned. |
44
43
 
45
- ### Tier 2 — optional, 1,496 lines
44
+ ### Tier 2 — optional, 1,607 lines
46
45
 
47
46
  | Module | Lines | Why it may belong in scope |
48
47
  | --- | ---: | --- |
49
- | `lib/encoding/` | 644 | Base58Check, varint and buffer readers — the parsing surface untrusted bytes hit first. |
50
- | `lib/mnemonic/` | 544 | BIP-39 seed derivation. Small, but a weakness here compromises every key beneath it. |
48
+ | `lib/encoding/` | 708 | Base58Check, varint and buffer readers — the parsing surface untrusted bytes hit first. |
49
+ | `lib/mnemonic/` | 591 | BIP-39 seed derivation. Small, but a weakness here compromises every key beneath it. |
51
50
  | `lib/ecies/` | 308 | Encryption built on audited primitives; the composition is ours. |
52
51
 
53
52
  Tier 2 is cryptographic rather than application code, so excluding it is a **budget
@@ -59,19 +58,19 @@ is not.
59
58
  | Component | Status | Reason |
60
59
  | --- | --- | --- |
61
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. |
62
- | `lib/smart_contract/`, `lib/ltp/`, `lib/gdaf/`, `lib/ordinals/`, `lib/block/`, plus 9 further directories and 6 top-level files | Excluded | Application layer, 22,699 lines — 18,435 in the five named modules and 4,264 in the remainder. Written in-house and covered by adversarial tests. Worth a separate engagement; including it here would blur the question in §1. |
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. |
63
62
 
64
- Totals reconcile against `lib/`, which is 35,934 lines across 122 files:
63
+ Totals reconcile against `lib/`, which is 36,301 lines across 123 files:
65
64
 
66
65
  ```
67
- tier 1 11,739
68
- tier 2 1,496
69
- excluded 22,699
66
+ tier 1 11,879
67
+ tier 2 1,607
68
+ excluded 22,815
70
69
  ------
71
- total 35,934
70
+ total 36,301
72
71
  ```
73
72
 
74
- Core + optional = 13,235.
73
+ Core + optional = 13,486.
75
74
 
76
75
  ## 4. What an auditor gets on day one
77
76
 
@@ -125,17 +124,17 @@ seeking a quote for an independent security review of its cryptographic core.
125
124
 
126
125
  Scope, and we would like these priced separately:
127
126
 
128
- Tier 1 — 11,739 lines, 33 files. Script interpreter, sighash and signing,
127
+ Tier 1 — 11,879 lines, 33 files. Script interpreter, sighash and signing,
129
128
  ECDSA and signature encoding, BIP-32 derivation, key and address
130
129
  construction.
131
130
 
132
- Tier 2 — 1,496 lines. BIP-39 mnemonics, ECIES, and the Base58Check/varint
131
+ Tier 2 — 1,607 lines. BIP-39 mnemonics, ECIES, and the Base58Check/varint
133
132
  decoding surface.
134
133
 
135
134
  JavaScript (CommonJS), Node >= 20.19. The code is public.
136
135
 
137
136
  Explicitly out of scope: elliptic-curve and hash primitives, which are supplied
138
- by the Noble libraries and already audited; and our 22,699-line application
137
+ by the Noble libraries and already audited; and our 22,815-line application
139
138
  layer (credentials, tokens, ordinals), which we would treat as a separate
140
139
  engagement.
141
140
 
@@ -163,7 +162,7 @@ SmartLedger Technology
163
162
  Every figure in this document, including the excluded total, must come out of this
164
163
  script. **Derive the excluded count as the complement — never by subtracting tier 1
165
164
  alone.** The first draft did exactly that, double-counted tier 2, and published parts
166
- summing to 37,430 against a 35,934 whole; §7 could not catch it because it reproduced
165
+ summing to 37,430 against a 36,301 whole; §7 could not catch it because it reproduced
167
166
  every figure except the wrong one.
168
167
 
169
168
  ```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@7.12.0/bsv-shamir.min.js`
58
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.13.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@7.12.0/bsv-gdaf.min.js`
64
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.13.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@7.12.0/bsv-ltp.min.js`
70
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.13.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@7.12.0/bsv.min.js` |
85
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.12.0/bsv.bundle.js` |
86
- | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.12.0/bsv-smartcontract.min.js` |
87
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.12.0/bsv-covenant.min.js` |
88
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.12.0/bsv-script-helper.min.js` |
89
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.12.0/bsv-security.min.js` |
90
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.12.0/bsv-ecies.min.js` |
91
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.12.0/bsv-message.min.js` |
92
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.12.0/bsv-mnemonic.min.js` |
93
- | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.12.0/bsv-shamir.min.js` |
94
- | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.12.0/bsv-gdaf.min.js` |
95
- | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.12.0/bsv-ltp.min.js` |
84
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.13.0/bsv.min.js` |
85
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.13.0/bsv.bundle.js` |
86
+ | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.13.0/bsv-smartcontract.min.js` |
87
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.13.0/bsv-covenant.min.js` |
88
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.13.0/bsv-script-helper.min.js` |
89
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.13.0/bsv-security.min.js` |
90
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.13.0/bsv-ecies.min.js` |
91
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.13.0/bsv-message.min.js` |
92
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.13.0/bsv-mnemonic.min.js` |
93
+ | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.13.0/bsv-shamir.min.js` |
94
+ | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.13.0/bsv-gdaf.min.js` |
95
+ | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.13.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@7.12.0/bsv.min.js"></script>
104
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-script-helper.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv.min.js"></script>
104
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.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@7.12.0/bsv.min.js"></script>
110
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-covenant.min.js"></script>
111
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-smartcontract.min.js"></script>
109
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv.min.js"></script>
110
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv-covenant.min.js"></script>
111
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.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@7.12.0/bsv.min.js"></script>
117
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-ltp.min.js"></script>
118
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-gdaf.min.js"></script>
116
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv.min.js"></script>
117
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv-ltp.min.js"></script>
118
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.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@7.12.0/bsv.min.js"></script>
136
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-security.min.js"></script>
137
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-shamir.min.js"></script>
135
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv-security.min.js"></script>
137
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.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@7.12.0/bsv.bundle.js"></script>
149
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.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@7.12.0/bsv.min.js"></script>
725
+ <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@7.13.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@7.12.0/bsv.min.js"></script>
51
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.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@7.12.0/bsv.bundle.js"></script>
61
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.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@7.12.0/bsv.min.js"></script>
75
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-covenant.min.js"></script>
76
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-smartcontract.min.js"></script>
74
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv.min.js"></script>
75
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv-covenant.min.js"></script>
76
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.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@7.12.0/bsv.min.js"></script>
86
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-ltp.min.js"></script>
87
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-gdaf.min.js"></script>
85
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv.min.js"></script>
86
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv-ltp.min.js"></script>
87
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.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@7.12.0/bsv.min.js"></script>
102
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-security.min.js"></script>
103
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-shamir.min.js"></script>
101
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv.min.js"></script>
102
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv-security.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.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@7.12.0/bsv.min.js` |
118
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.12.0/bsv.bundle.js` |
119
- | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.12.0/bsv-smartcontract.min.js` |
120
- | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.12.0/bsv-ltp.min.js` |
121
- | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.12.0/bsv-gdaf.min.js` |
122
- | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.12.0/bsv-shamir.min.js` |
123
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.12.0/bsv-security.min.js` |
124
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.12.0/bsv-mnemonic.min.js` |
125
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.12.0/bsv-ecies.min.js` |
126
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.12.0/bsv-covenant.min.js` |
127
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.12.0/bsv-script-helper.min.js` |
128
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.12.0/bsv-message.min.js` |
117
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.13.0/bsv.min.js` |
118
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.13.0/bsv.bundle.js` |
119
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.13.0/bsv-smartcontract.min.js` |
120
+ | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.13.0/bsv-ltp.min.js` |
121
+ | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.13.0/bsv-gdaf.min.js` |
122
+ | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.13.0/bsv-shamir.min.js` |
123
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.13.0/bsv-security.min.js` |
124
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.13.0/bsv-mnemonic.min.js` |
125
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.13.0/bsv-ecies.min.js` |
126
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.13.0/bsv-covenant.min.js` |
127
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.13.0/bsv-script-helper.min.js` |
128
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.13.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@7.12.0/bsv.min.js"></script>
17
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv.min.js"></script>
18
18
 
19
19
  <!-- Everything included (937KB) -->
20
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv.bundle.js"></script>
20
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.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@7.12.0/bsv.min.js"></script>
130
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv.min.js"></script>
131
131
 
132
132
  <!-- Smart contracts (937KB) -->
133
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-smartcontract.min.js"></script>
133
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv-smartcontract.min.js"></script>
134
134
 
135
135
  <!-- Legal tokens (1.16MB) -->
136
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-ltp.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv-ltp.min.js"></script>
137
137
 
138
138
  <!-- Digital identity (1.16MB) -->
139
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-gdaf.min.js"></script>
139
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv-gdaf.min.js"></script>
140
140
 
141
141
  <!-- Everything (937KB) -->
142
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv.bundle.js"></script>
142
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.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@7.12.0/bsv.min.js"></script>
162
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv.min.js"></script>
163
163
 
164
164
  <!-- Add smart contracts when ready -->
165
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-smartcontract.min.js"></script>
165
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv-smartcontract.min.js"></script>
166
166
 
167
167
  <!-- Add advanced features as needed -->
168
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-ltp.min.js"></script>
169
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv-gdaf.min.js"></script>
168
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv-ltp.min.js"></script>
169
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv-gdaf.min.js"></script>
170
170
 
171
171
  <!-- Everything in one file -->
172
- <script src="https://unpkg.com/@smartledger/bsv@7.12.0/bsv.bundle.js"></script>
172
+ <script src="https://unpkg.com/@smartledger/bsv@7.13.0/bsv.bundle.js"></script>
173
173
  ```
174
174
 
175
175
  ## 🔍 **Testing Your Migration**
package/index.js CHANGED
@@ -24,14 +24,22 @@ bsv.deps = bsv.deps || {}
24
24
  bsv.deps._ = require('./lib/util/_')
25
25
  bsv.deps.Buffer = (typeof Buffer !== 'undefined') ? Buffer : null
26
26
 
27
+ // `bsv.deps.bs58` is kept as a compatible facade rather than the `bs58` package, which
28
+ // this library no longer depends on — the encoder now lives in lib/encoding/base58.js.
29
+ // The contract callers rely on is unchanged: `encode(Buffer) -> string` and
30
+ // `decode(string) -> bytes` (a Buffer, which is a Uint8Array, as bs58 also returned).
31
+ var Base58Dep = require('./lib/encoding/base58')
32
+ bsv.deps.bs58 = {
33
+ encode: Base58Dep.encode,
34
+ decode: Base58Dep.decode
35
+ }
36
+
27
37
  if (typeof window === 'undefined') {
28
38
  // Node — hard require; failure means broken install.
29
39
  bsv.deps.bnjs = require('bn.js')
30
- bsv.deps.bs58 = require('bs58')
31
40
  } else {
32
41
  // Browser — bundler-resolved; tolerate absence individually.
33
42
  try { bsv.deps.bnjs = require('bn.js') } catch (e) { /* polyfilled by bundler */ }
34
- try { bsv.deps.bs58 = require('bs58') } catch (e) { /* polyfilled by bundler */ }
35
43
  }
36
44
 
37
45
  // module information (./version is generated from package.json by the `version` npm hook;
@@ -1,6 +1,14 @@
1
1
  'use strict'
2
2
 
3
- var hash = require('hash.js')
3
+ // The browser digests come from @noble/hashes — the same audited implementation the
4
+ // Node path's primitives ultimately rest on, and already a dependency here for
5
+ // @noble/curves. Previously this file used `hash.js`, so the browser bundle and Node
6
+ // computed the same digests via two different implementations; one of them was audited.
7
+ //
8
+ // Only the four raw digests came from that dependency. `Hash.hmac` below is
9
+ // hand-implemented against `hashf.blocksize` and is unchanged.
10
+ var { sha256, sha512 } = require('@noble/hashes/sha2.js')
11
+ var { sha1, ripemd160 } = require('@noble/hashes/legacy.js')
4
12
  var $ = require('../util/preconditions')
5
13
 
6
14
  var Hash = module.exports
@@ -16,7 +24,7 @@ var Hash = module.exports
16
24
  */
17
25
  Hash.sha1 = function (buf) {
18
26
  $.checkArgument(Buffer.isBuffer(buf))
19
- return Buffer.from(hash.sha1().update(buf).digest('hex'), 'hex')
27
+ return Buffer.from(sha1(buf))
20
28
  }
21
29
 
22
30
  Hash.sha1.blocksize = 512
@@ -32,7 +40,7 @@ Hash.sha1.blocksize = 512
32
40
  */
33
41
  Hash.sha256 = function (buf) {
34
42
  $.checkArgument(Buffer.isBuffer(buf))
35
- return Buffer.from(hash.sha256().update(buf).digest('hex'), 'hex')
43
+ return Buffer.from(sha256(buf))
36
44
  }
37
45
 
38
46
  Hash.sha256.blocksize = 512
@@ -64,7 +72,7 @@ Hash.sha256sha256 = function (buf) {
64
72
  */
65
73
  Hash.ripemd160 = function (buf) {
66
74
  $.checkArgument(Buffer.isBuffer(buf))
67
- return Buffer.from(hash.ripemd160().update(buf).digest('hex'), 'hex')
75
+ return Buffer.from(ripemd160(buf))
68
76
  }
69
77
  /**
70
78
  * A RIPEMD160 hash of a SHA256 hash, which is always 160 bits or 20 bytes long.
@@ -93,7 +101,7 @@ Hash.sha256ripemd160 = function (buf) {
93
101
  */
94
102
  Hash.sha512 = function (buf) {
95
103
  $.checkArgument(Buffer.isBuffer(buf))
96
- return Buffer.from(hash.sha512().update(buf).digest('hex'), 'hex')
104
+ return Buffer.from(sha512(buf))
97
105
  }
98
106
 
99
107
  Hash.sha512.blocksize = 1024
@@ -1,2 +1,58 @@
1
- if (process.browser) module.exports = require('./hash.browser')
2
- else module.exports = require('./hash.node')
1
+ 'use strict'
2
+
3
+ // Pick the hashing backend by CAPABILITY, not by `process.browser`.
4
+ //
5
+ // This file used to read `process.browser`, a Browserify-era convention that is
6
+ // undefined in React Native, Deno, Cloudflare Workers and Bun. All of them took the
7
+ // node branch and required('crypto'), which in React Native fails outright or — worse —
8
+ // resolves to a partial shim. See lib/crypto/random.js for the same bug in the CSPRNG.
9
+ //
10
+ // Node's implementation is kept as the preferred backend rather than always using
11
+ // @noble/hashes, because it is materially faster on the payload sizes this library
12
+ // actually hashes in bulk: measured at parity for 32 bytes (1.2x) but ~10x for 64 KB
13
+ // and above, which is block parsing and document anchoring.
14
+ //
15
+ // Two capability checks, not one:
16
+ //
17
+ // - The digests must be CORRECT, verified against known-answer vectors. A partial
18
+ // crypto shim that supplies a wrong or stubbed createHash would otherwise silently
19
+ // corrupt every hash in the library. Falling back to the audited pure-JS
20
+ // implementation is always safe; trusting an unknown shim is not.
21
+ // - `ripemd160` must be present. OpenSSL 3 moved it to the legacy provider, so some
22
+ // Node builds have sha256 but throw on ripemd160 — which is what addresses are
23
+ // built from, making this a real failure and not a theoretical one.
24
+ //
25
+ // The probe costs four hashes of three bytes, once, at module load.
26
+
27
+ var VECTORS = {
28
+ sha1: 'a9993e364706816aba3e25717850c26c9cd0d89d',
29
+ sha256: 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad',
30
+ sha512: 'ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a' +
31
+ '2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f',
32
+ ripemd160: '8eb208f7e05d987a9b044a8e98c6b087f15a0bfc'
33
+ }
34
+
35
+ function nodeHashesAreUsable () {
36
+ var crypto
37
+ try {
38
+ crypto = require('crypto')
39
+ } catch (e) {
40
+ return false
41
+ }
42
+ if (!crypto || typeof crypto.createHash !== 'function') return false
43
+
44
+ var algorithms = Object.keys(VECTORS)
45
+ for (var i = 0; i < algorithms.length; i++) {
46
+ var algorithm = algorithms[i]
47
+ try {
48
+ if (crypto.createHash(algorithm).update('abc').digest('hex') !== VECTORS[algorithm]) {
49
+ return false
50
+ }
51
+ } catch (e) {
52
+ return false
53
+ }
54
+ }
55
+ return true
56
+ }
57
+
58
+ module.exports = nodeHashesAreUsable() ? require('./hash.node') : require('./hash.browser')
@@ -1,37 +1,94 @@
1
1
  'use strict'
2
2
 
3
+ // WebCrypto refuses more than 65,536 bytes in a single getRandomValues() call, so large
4
+ // requests are filled in chunks. Node's randomBytes has no such limit, which is why this
5
+ // only matters on the WebCrypto path.
6
+ var MAX_GET_RANDOM_VALUES = 65536
7
+
3
8
  function Random () {
4
9
  }
5
10
 
6
- /* secure random bytes that sometimes throws an error due to lack of entropy */
11
+ /**
12
+ * Cryptographically secure random bytes.
13
+ *
14
+ * Backend selection is by FEATURE DETECTION, not by environment guess. This previously
15
+ * branched on `process.browser` — a Browserify-era convention that is undefined in React
16
+ * Native, Deno, Cloudflare Workers, Bun, and any bundler that does not shim it. All of
17
+ * those fell through to `require('crypto').randomBytes`. In React Native that is a hard
18
+ * failure at best; at worst a partial crypto shim (rn-nodeify and several RN starter
19
+ * templates register one) supplies a weak `randomBytes`, and `PrivateKey.fromRandom()`
20
+ * silently produces guessable keys.
21
+ *
22
+ * `globalThis.crypto.getRandomValues` covers browsers, Node >= 19, Deno, Workers, Bun,
23
+ * and React Native with react-native-get-random-values, so it is tried first.
24
+ *
25
+ * If no CSPRNG can be found this THROWS. That is as important as the detection: a key
26
+ * library must never return bytes it cannot vouch for.
27
+ *
28
+ * @param {number} size - number of bytes
29
+ * @returns {Buffer}
30
+ */
7
31
  Random.getRandomBuffer = function (size) {
8
- if (process.browser) { return Random.getRandomBufferBrowser(size) } else { return Random.getRandomBufferNode(size) }
32
+ var webcrypto = typeof globalThis !== 'undefined' ? globalThis.crypto : undefined
33
+ if (webcrypto && typeof webcrypto.getRandomValues === 'function') {
34
+ return Random._fromGetRandomValues(webcrypto, size)
35
+ }
36
+
37
+ // Node < 19 has no global crypto. Kept as a fallback rather than the default.
38
+ try {
39
+ var nodeCrypto = require('crypto')
40
+ if (nodeCrypto && typeof nodeCrypto.randomBytes === 'function') {
41
+ return nodeCrypto.randomBytes(size)
42
+ }
43
+ } catch (e) { /* no node crypto in this environment */ }
44
+
45
+ throw new Error('bsv: no CSPRNG available in this environment (needs globalThis.crypto.getRandomValues or node crypto)')
9
46
  }
10
47
 
48
+ /**
49
+ * Fill `size` bytes from a WebCrypto instance, respecting the per-call limit.
50
+ * @private
51
+ */
52
+ Random._fromGetRandomValues = function (webcrypto, size) {
53
+ var buf = Buffer.alloc(size)
54
+ for (var offset = 0; offset < size; offset += MAX_GET_RANDOM_VALUES) {
55
+ var chunk = new Uint8Array(Math.min(MAX_GET_RANDOM_VALUES, size - offset))
56
+ webcrypto.getRandomValues(chunk)
57
+ Buffer.from(chunk).copy(buf, offset)
58
+ }
59
+ return buf
60
+ }
61
+
62
+ /**
63
+ * Node-specific CSPRNG. Retained as public API; `getRandomBuffer` no longer routes
64
+ * here by default.
65
+ */
11
66
  Random.getRandomBufferNode = function (size) {
12
67
  var crypto = require('crypto')
13
68
  return crypto.randomBytes(size)
14
69
  }
15
70
 
71
+ /**
72
+ * WebCrypto CSPRNG. Retained as public API.
73
+ *
74
+ * Reads `globalThis` rather than a bare `window`, which does not exist in Web Workers,
75
+ * Node, or React Native.
76
+ */
16
77
  Random.getRandomBufferBrowser = function (size) {
17
- if (!window.crypto && !window.msCrypto) {
18
- throw new Error('window.crypto not available')
78
+ var g = typeof globalThis !== 'undefined' ? globalThis : {}
79
+ var crypto = null
80
+
81
+ if (g.crypto && typeof g.crypto.getRandomValues === 'function') {
82
+ crypto = g.crypto
83
+ } else if (g.msCrypto && typeof g.msCrypto.getRandomValues === 'function') { // internet explorer
84
+ crypto = g.msCrypto
19
85
  }
20
- var crypto
21
86
 
22
- if (window.crypto && window.crypto.getRandomValues) {
23
- crypto = window.crypto
24
- } else if (window.msCrypto && window.msCrypto.getRandomValues) { // internet explorer
25
- crypto = window.msCrypto
26
- } else {
87
+ if (!crypto) {
27
88
  throw new Error('window.crypto.getRandomValues not available')
28
89
  }
29
90
 
30
- var bbuf = new Uint8Array(size)
31
- crypto.getRandomValues(bbuf)
32
- var buf = Buffer.from(bbuf)
33
-
34
- return buf
91
+ return Random._fromGetRandomValues(crypto, size)
35
92
  }
36
93
 
37
94
  module.exports = Random