@smartledger/bsv 9.2.0 → 9.4.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.
- package/CHANGELOG.md +133 -0
- package/README.md +19 -19
- package/SECURITY.md +23 -23
- package/anchor-entry.d.ts +8 -0
- package/bsv-gdaf.min.js +52 -52
- package/bsv-ltp.min.js +1 -1
- package/bsv-smartcontract.min.js +18 -18
- package/bsv.bundle.js +52 -52
- package/bsv.d.ts +9 -1
- package/bsv.min.js +52 -52
- package/covenant-entry.d.ts +17 -0
- package/didweb-entry.d.ts +7 -0
- package/docs/AUDIT_SCOPE.md +136 -29
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/ORDINALS_ENVELOPE_FIELDS.md +159 -0
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/audit-rfq/README.md +41 -0
- package/docs/audit-rfq/cure53.txt +49 -0
- package/docs/audit-rfq/ncc-group.txt +49 -0
- package/docs/audit-rfq/trail-of-bits.txt +49 -0
- package/docs/getting-started/INSTALLATION.md +23 -23
- package/docs/getting-started/QUICK_START.md +7 -7
- package/docs/migration/FROM_BSV_1_5_6.md +5 -5
- package/gdaf-entry.d.ts +7 -0
- package/lib/ordinals/inscription.js +112 -0
- package/lib/script/interpreter.js +7 -2
- package/lib/smart_contract/dsl.js +55 -3
- package/ltp-entry.d.ts +7 -0
- package/package.json +49 -14
- package/script-helper-entry.d.ts +75 -0
- package/security-entry.d.ts +52 -0
- package/shamir-entry.d.ts +10 -0
- package/smartcontract-entry.d.ts +8 -0
- package/statuslist-entry.d.ts +11 -0
- package/vcjwt-entry.d.ts +15 -0
- package/version.js +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Covenant construction.
|
|
3
|
+
*
|
|
4
|
+
* The default export is `SmartContract.Covenant`; `reconstructP2pkhScript` is
|
|
5
|
+
* exported alongside it at runtime.
|
|
6
|
+
*/
|
|
7
|
+
import { SmartContract, Script, PublicKey } from '@smartledger/bsv';
|
|
8
|
+
|
|
9
|
+
declare const covenant: typeof SmartContract.Covenant & {
|
|
10
|
+
/**
|
|
11
|
+
* Rebuild the P2PKH locking script a covenant spends from, for preimage
|
|
12
|
+
* construction.
|
|
13
|
+
*/
|
|
14
|
+
reconstructP2pkhScript(publicKey: PublicKey | Buffer | string): Script;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export = covenant;
|
package/docs/AUDIT_SCOPE.md
CHANGED
|
@@ -29,17 +29,23 @@ 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
|
-
|
|
32
|
+
The boundary is drawn by **where defects have actually occurred**, not by how core a
|
|
33
|
+
module sounds. That is a deliberate revision: an earlier version of this document
|
|
34
|
+
scoped Tier 1 as "the cryptographic core" and would have excluded four of the six real
|
|
35
|
+
defects this codebase has produced. See §2.1.
|
|
36
|
+
|
|
37
|
+
### Tier 1 — 11,247 lines
|
|
33
38
|
|
|
34
39
|
| Module | Lines | Why it matters |
|
|
35
40
|
| --- | ---: | --- |
|
|
36
|
-
| `lib/script/` | 3,751 | Consensus script interpreter. Divergence from the node means accepting a transaction the network rejects, or the reverse. |
|
|
37
41
|
| `lib/transaction/` | 2,779 | Sighash construction and signing — both BIP-143 and the Original Transaction Digest Algorithm. |
|
|
38
|
-
| `lib/
|
|
39
|
-
| `lib/
|
|
42
|
+
| `lib/script/interpreter.js` | 2,684 | **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
|
+
| `lib/crypto/` | 2,519 | ECDSA, nonce derivation, signature encoding, the script-number type. **Scope this for an architectural judgement as well as for bugs** — see §2.3. |
|
|
44
|
+
| `lib/notaryhash/` | 1,436 | BRC-220 signing and verification. Publicly reachable and relied on downstream. |
|
|
40
45
|
| `lib/privatekey.js`, `lib/publickey.js` | 843 | Key construction, serialisation, WIF. Recent defects here produced a *different* key without error. |
|
|
41
|
-
| `lib/
|
|
42
|
-
| `lib/
|
|
46
|
+
| `lib/smart_contract/` (targeted) | 472 | `locks.js` and the covenant-facing entrypoints in `index.js`: CLTV and HTLC locking semantics, flag plumbing, and any wrapper claiming mainnet-equivalent verification. Not the whole 6,908-line module. |
|
|
47
|
+
| `lib/covenant/` | 409 | The verification harness. Its flag word is what made covenants verify under 2019 rules while claiming to mirror mainnet. |
|
|
48
|
+
| `lib/util/jcs.js` | 105 | RFC 8785 canonicalization, now a public export and the estate's single implementation. |
|
|
43
49
|
|
|
44
50
|
### Tier 2 — optional, 1,607 lines
|
|
45
51
|
|
|
@@ -53,24 +59,87 @@ Tier 2 is cryptographic rather than application code, so excluding it is a **bud
|
|
|
53
59
|
decision, not a risk judgement**. Priced as an add-on it is cheap; discovered later it
|
|
54
60
|
is not.
|
|
55
61
|
|
|
62
|
+
### 2.1 Why the boundary moved
|
|
63
|
+
|
|
64
|
+
Six defects have been found in this codebase and fixed. Four of them were in code the
|
|
65
|
+
previous version of this scope **excluded**:
|
|
66
|
+
|
|
67
|
+
| Defect | Module | Was it in the old scope? |
|
|
68
|
+
| --- | --- | --- |
|
|
69
|
+
| Covenant verification applied pre-Genesis limits while claiming to mirror mainnet | `lib/covenant`, `lib/smart_contract` | no |
|
|
70
|
+
| `timeLockCLTV` and the HTLC timeout enforced nothing on mainnet — Genesis reverted `OP_CLTV` to a NOP, so the funds were spendable immediately | `lib/smart_contract` | no |
|
|
71
|
+
| A BRC-220 suite verified against a byte-reversed digest, rejecting every conformant signature | `lib/notaryhash` | no |
|
|
72
|
+
| The reachable RFC 8785 canonicalizer was non-conformant while a correct one sat private; three downstream packages copied the wrong one | `lib/util/jcs.js`, `lib/ltp` | partly |
|
|
73
|
+
| `ECDSA.verify()` returned the instance, so `if (verify())` was always truthy — a fail-open accepting forged signatures | `lib/crypto` | yes |
|
|
74
|
+
| ECDSA nonce reuse across two signings on one instance, leaking the private key | `lib/crypto` | yes |
|
|
75
|
+
|
|
76
|
+
The pattern is not "the primitives are weak". It is that **code making claims about
|
|
77
|
+
consensus behaviour was wrong about it**, and the tests agreed because they shared the
|
|
78
|
+
same assumption. Scope has been moved onto that surface.
|
|
79
|
+
|
|
80
|
+
### 2.2 Why `lib/script` shrinks rather than leaves
|
|
81
|
+
|
|
82
|
+
`lib/script` has the strongest external evidence in the repository: 1,483/1,483 of the
|
|
83
|
+
reference node's own consensus vectors, zero false accepts and zero false rejects. That
|
|
84
|
+
is evidence about **opcode execution**, and re-auditing it by hand is the least
|
|
85
|
+
productive money in this engagement.
|
|
86
|
+
|
|
87
|
+
It is not evidence about which flags a caller ends up with. Both consensus defects above
|
|
88
|
+
were flag-selection and era-derivation failures reachable through `interpreter.js`, and
|
|
89
|
+
no vector covers them because every vector states its own flags. So the interpreter stays
|
|
90
|
+
in scope, scoped to that surface, and the remaining 1,175 lines of `lib/script` leave.
|
|
91
|
+
|
|
92
|
+
### 2.3 A specific instruction for `lib/crypto`
|
|
93
|
+
|
|
94
|
+
Both in-scope defects — a fail-open `verify()` and nonce reuse across signings — are
|
|
95
|
+
symptoms of a **stateful object wrapper around a stateless primitive library**. The
|
|
96
|
+
curve arithmetic beneath is `@noble/curves`, which is already audited and offers
|
|
97
|
+
stateless signing, RFC 6979 nonces and a strict boolean verify.
|
|
98
|
+
|
|
99
|
+
So do not only ask whether `lib/crypto` has bugs. Ask whether the wrapper should exist:
|
|
100
|
+
what would it cost to route the signing and verification paths directly at `@noble`, and
|
|
101
|
+
which parts genuinely cannot go? `bn.js`, `Point`, `Signature` and `Shamir` are public
|
|
102
|
+
API (`bsv.crypto.*`) and cannot simply be deleted, so this is a question with a real
|
|
103
|
+
answer rather than a rhetorical one. An answer either way is worth more than a list of
|
|
104
|
+
findings inside code that should not be there.
|
|
105
|
+
|
|
106
|
+
### 2.4 The requirement that matters most
|
|
107
|
+
|
|
108
|
+
Whatever the final line count, the statement of work should carry this:
|
|
109
|
+
|
|
110
|
+
> **Audit exported security claims, defaults, and the tests that assert them as a unit,
|
|
111
|
+
> against an independent oracle or specification — not each in isolation.**
|
|
112
|
+
|
|
113
|
+
Every defect above shares one shape. The code was wrong, and its tests passed, because
|
|
114
|
+
the tests were written from the same assumption. A file-by-file review finds none of
|
|
115
|
+
them. Checking a claim against something outside this repository finds all of them —
|
|
116
|
+
which is exactly how each was eventually caught.
|
|
117
|
+
|
|
56
118
|
## 3. Out of scope, and why
|
|
57
119
|
|
|
58
120
|
| Component | Status | Reason |
|
|
59
121
|
| --- | --- | --- |
|
|
60
122
|
| `@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
|
-
|
|
|
123
|
+
| Opcode execution in `lib/script/` (1,175 lines outside `interpreter.js`) | Excluded, with evidence | 1,483/1,483 of the reference node's own consensus vectors pass, with zero false accepts and zero false rejects. See §2.2 — the flag surface stays in, the execution does not. |
|
|
124
|
+
| `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**. |
|
|
125
|
+
| 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. |
|
|
62
126
|
|
|
63
|
-
Totals reconcile against `lib/`, which is 38,
|
|
127
|
+
Totals reconcile against `lib/`, which is 38,879 lines across 131 files:
|
|
64
128
|
|
|
65
129
|
```
|
|
66
|
-
tier 1
|
|
130
|
+
tier 1 11,247
|
|
67
131
|
tier 2 1,607
|
|
68
|
-
excluded
|
|
132
|
+
excluded 26,025
|
|
69
133
|
------
|
|
70
|
-
total 38,
|
|
134
|
+
total 38,879
|
|
71
135
|
```
|
|
72
136
|
|
|
73
|
-
|
|
137
|
+
Measured 2026-08-29 at `a954c27`. These figures drift as the library changes — an
|
|
138
|
+
earlier set was 445 lines light by the time it was read, most of it in
|
|
139
|
+
`lib/script/interpreter.js`, which is priced against. **Re-run §7 immediately before
|
|
140
|
+
sending**, and update the date above with the commit measured.
|
|
141
|
+
|
|
142
|
+
Core + optional = 12,854.
|
|
74
143
|
|
|
75
144
|
## 4. What an auditor gets on day one
|
|
76
145
|
|
|
@@ -124,37 +193,56 @@ any single number.
|
|
|
124
193
|
## 6. Enquiry text
|
|
125
194
|
|
|
126
195
|
```text
|
|
127
|
-
Subject: Audit enquiry — BSV
|
|
196
|
+
Subject: Audit enquiry — BSV library, consensus and signing surface (~13k LOC JavaScript)
|
|
128
197
|
|
|
129
198
|
Hello,
|
|
130
199
|
|
|
131
200
|
We maintain @smartledger/bsv, a Bitcoin SV library published on npm. We are
|
|
132
|
-
seeking a quote for an independent security review
|
|
201
|
+
seeking a quote for an independent security review.
|
|
133
202
|
|
|
134
203
|
Scope, and we would like these priced separately:
|
|
135
204
|
|
|
136
|
-
Tier 1 —
|
|
137
|
-
|
|
138
|
-
|
|
205
|
+
Tier 1 — 11,247 lines. Sighash construction and signing; ECDSA, nonce
|
|
206
|
+
derivation and signature encoding; the consensus-flag and era-derivation
|
|
207
|
+
surface of the script interpreter; BRC-220 signing and verification;
|
|
208
|
+
key construction and serialisation; the covenant verification harness and
|
|
209
|
+
the locking-script semantics built on it; RFC 8785 canonicalization.
|
|
139
210
|
|
|
140
211
|
Tier 2 — 1,607 lines. BIP-39 mnemonics, ECIES, and the Base58Check/varint
|
|
141
212
|
decoding surface.
|
|
142
213
|
|
|
143
214
|
JavaScript (CommonJS), Node >= 20.19. The code is public.
|
|
144
215
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
216
|
+
Two things we would ask you to scope deliberately rather than by line count:
|
|
217
|
+
|
|
218
|
+
1. Please audit exported security claims, their defaults, and the tests that
|
|
219
|
+
assert them AS A UNIT, against an independent oracle or specification.
|
|
220
|
+
Every defect we have found shared one shape: the code was wrong and its
|
|
221
|
+
tests passed, because both were written from the same assumption. A
|
|
222
|
+
file-by-file review would have found none of them.
|
|
223
|
+
|
|
224
|
+
2. In lib/crypto, we would value a judgement on whether the wrapper should
|
|
225
|
+
exist at all. Our two worst defects there — a verify() that returned a
|
|
226
|
+
truthy object instead of a boolean, and nonce reuse across two signings
|
|
227
|
+
on one instance — are symptoms of a stateful wrapper around a stateless
|
|
228
|
+
primitive library (@noble/curves) that already offers stateless signing,
|
|
229
|
+
RFC 6979 nonces and a strict boolean verify. An answer on the cost of
|
|
230
|
+
removing the wrapper is worth more to us than a list of findings inside it.
|
|
231
|
+
|
|
232
|
+
Explicitly out of scope: elliptic-curve and hash primitives, supplied by the
|
|
233
|
+
Noble libraries and already audited by Cure53; opcode execution in the script
|
|
234
|
+
interpreter, which passes 1,483/1,483 of the reference node's own consensus
|
|
235
|
+
vectors with zero false accepts; and roughly 26,000 lines of application layer
|
|
236
|
+
(credentials, tokens, ordinals), which we would treat as a separate engagement.
|
|
149
237
|
|
|
150
238
|
Context that should shorten discovery: the core is inherited from bitcore and
|
|
151
239
|
has been fixed reactively but never independently reviewed. We can provide a
|
|
152
240
|
test-backed threat model, a 452-case behavioural conformance corpus that a
|
|
153
|
-
second independent implementation agrees with,
|
|
154
|
-
defects we have found ourselves.
|
|
241
|
+
second independent implementation agrees with, the node's own consensus vectors
|
|
242
|
+
run as a gate, and a documented history of the defects we have found ourselves.
|
|
155
243
|
|
|
156
244
|
The failure mode we most want examined is code that reports a check as passed
|
|
157
|
-
without performing it —
|
|
245
|
+
without performing it — every finding of ours has had that shape.
|
|
158
246
|
|
|
159
247
|
Could you indicate availability, an approximate cost range, and what you would
|
|
160
248
|
need from us to firm that up?
|
|
@@ -170,21 +258,32 @@ SmartLedger Technology
|
|
|
170
258
|
|
|
171
259
|
Every figure in this document, including the excluded total, must come out of this
|
|
172
260
|
script. **Derive the excluded count as the complement — never by subtracting tier 1
|
|
173
|
-
alone.**
|
|
261
|
+
alone.** An early draft did exactly that, double-counted tier 2, and published parts
|
|
174
262
|
summing to 37,430 against a 38,322 whole; §7 could not catch it because it reproduced
|
|
175
263
|
every figure except the wrong one.
|
|
176
264
|
|
|
265
|
+
Tier 1 is no longer whole directories. Three entries are partial — the interpreter is
|
|
266
|
+
scoped to its flag surface, `smart_contract` to its locking semantics — so those are
|
|
267
|
+
counted by file and the reason is in §2. A partial scope that is measured as a whole
|
|
268
|
+
directory is how a vendor prices 6,908 lines when you meant 472.
|
|
269
|
+
|
|
177
270
|
```sh
|
|
178
271
|
lines () { find "$@" -name '*.js' -exec cat {} + | wc -l; }
|
|
179
272
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
273
|
+
# Whole directories in tier 1
|
|
274
|
+
TIER1_DIRS="lib/crypto lib/transaction lib/notaryhash lib/covenant"
|
|
275
|
+
|
|
276
|
+
# Individual files — including the PARTIAL entries (§2.2, §2.3)
|
|
277
|
+
TIER1_FILES="lib/privatekey.js lib/publickey.js \
|
|
278
|
+
lib/script/interpreter.js \
|
|
279
|
+
lib/smart_contract/locks.js lib/smart_contract/index.js \
|
|
280
|
+
lib/util/jcs.js"
|
|
281
|
+
|
|
183
282
|
TIER2_DIRS="lib/encoding lib/mnemonic lib/ecies"
|
|
184
283
|
|
|
185
284
|
# Per-module breakdown for the scope tables
|
|
186
285
|
for d in $TIER1_DIRS $TIER2_DIRS; do
|
|
187
|
-
printf '%-
|
|
286
|
+
printf '%-20s %3s files %6s lines\n' "$d" \
|
|
188
287
|
"$(find $d -name '*.js' | wc -l)" "$(lines $d)"
|
|
189
288
|
done
|
|
190
289
|
wc -l $TIER1_FILES
|
|
@@ -203,5 +302,13 @@ printf 'tier 1 %6s\ntier 2 %6s\nexcluded %6s\n ------\ntotal
|
|
|
203
302
|
[ "$TOTAL" -gt 0 ] || echo "MISMATCH — run this from the repo root"
|
|
204
303
|
[ $(( T1 + T2 + EXCLUDED )) -eq "$TOTAL" ] || echo "MISMATCH — do not send"
|
|
205
304
|
|
|
305
|
+
# The cut list from §3, so the saving can be stated rather than asserted
|
|
306
|
+
wc -l lib/address.js lib/networks.js lib/opcode.js \
|
|
307
|
+
lib/hdprivatekey.js lib/hdpublickey.js
|
|
308
|
+
|
|
309
|
+
# networks.js carries no consensus-flag logic — the claim §3 rests on.
|
|
310
|
+
# Expect 0. A non-zero result means the cut needs re-arguing.
|
|
311
|
+
grep -cE 'SCRIPT_|GENESIS|CHRONICLE|consensus' lib/networks.js
|
|
312
|
+
|
|
206
313
|
find lib -name '*.js' | wc -l # file count
|
|
207
314
|
```
|
|
@@ -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.
|
|
58
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@9.4.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.
|
|
64
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@9.4.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.
|
|
70
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@9.4.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.
|
|
85
|
-
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.
|
|
86
|
-
| **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@9.
|
|
87
|
-
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.
|
|
88
|
-
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.
|
|
89
|
-
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@9.
|
|
90
|
-
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@9.
|
|
91
|
-
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@9.
|
|
92
|
-
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@9.
|
|
93
|
-
| **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@9.
|
|
94
|
-
| **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@9.
|
|
95
|
-
| **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@9.
|
|
84
|
+
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.4.0/bsv.min.js` |
|
|
85
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.4.0/bsv.bundle.js` |
|
|
86
|
+
| **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@9.4.0/bsv-smartcontract.min.js` |
|
|
87
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.4.0/bsv-covenant.min.js` |
|
|
88
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.4.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.4.0/bsv-security.min.js` |
|
|
90
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@9.4.0/bsv-ecies.min.js` |
|
|
91
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@9.4.0/bsv-message.min.js` |
|
|
92
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@9.4.0/bsv-mnemonic.min.js` |
|
|
93
|
+
| **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@9.4.0/bsv-shamir.min.js` |
|
|
94
|
+
| **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@9.4.0/bsv-gdaf.min.js` |
|
|
95
|
+
| **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@9.4.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.
|
|
104
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.4.0/bsv.min.js"></script>
|
|
104
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.4.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.
|
|
110
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
111
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
109
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.4.0/bsv.min.js"></script>
|
|
110
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.4.0/bsv-covenant.min.js"></script>
|
|
111
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.4.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.
|
|
117
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
118
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
116
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.4.0/bsv.min.js"></script>
|
|
117
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.4.0/bsv-ltp.min.js"></script>
|
|
118
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.4.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.
|
|
136
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
137
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
135
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.4.0/bsv.min.js"></script>
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.4.0/bsv-security.min.js"></script>
|
|
137
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.4.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.
|
|
149
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.4.0/bsv.bundle.js"></script>
|
|
150
150
|
<script>
|
|
151
151
|
// Everything available immediately
|
|
152
152
|
const shares = bsv.splitSecret('secret', 5, 3);
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# Envelope fields in `buildInscription` — handoff
|
|
2
|
+
|
|
3
|
+
**Commit:** `0242542` `feat(ordinals): write envelope fields, and refuse the ones that unbind`
|
|
4
|
+
**Touched:** `lib/ordinals/inscription.js`, `test/ordinals/inscription.js` — nothing else.
|
|
5
|
+
**Suite:** 4768 passing, 0 failing.
|
|
6
|
+
**Date:** 29 August 2026
|
|
7
|
+
|
|
8
|
+
This landed in your repo from the OrdinalSource side. It is finished and tested,
|
|
9
|
+
but it is **not releasable as-is** — see *What I did not touch*, which is the
|
|
10
|
+
part that needs you.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## What it does
|
|
15
|
+
|
|
16
|
+
`buildInscription` wrote the content type and the body and stopped. Tag 5 —
|
|
17
|
+
`metadata`, the spec's own home for an object's own record — could not be
|
|
18
|
+
written at all, and neither could any other field.
|
|
19
|
+
|
|
20
|
+
That mattered beyond convenience. The only way to produce one was to assemble
|
|
21
|
+
envelope bytes by hand, which is the most dangerous thing an integrator can do
|
|
22
|
+
on this stack: the bytes are permanent, already paid for, and nothing local
|
|
23
|
+
reports a mistake, because a builder agreeing with its own parser proves only
|
|
24
|
+
that they agree.
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
bsv.Ordinals.buildInscription({
|
|
28
|
+
address: owner,
|
|
29
|
+
contentType: 'image/jpeg',
|
|
30
|
+
content: image,
|
|
31
|
+
fields: { 5: manifest, 21: thumbnail }
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Fields are emitted between the content type and the body, in **ascending tag
|
|
36
|
+
order** so the same input always produces the same bytes. Order carries no
|
|
37
|
+
meaning to a parser before the body opens; reproducibility does.
|
|
38
|
+
|
|
39
|
+
## What it refuses, and why each one is silent otherwise
|
|
40
|
+
|
|
41
|
+
| Refused | Why it cannot be a warning |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| **Tag 0** | Opens the body. Everything after it *is* the body, so a field there does not fail — it silently becomes part of the file, and the inscription still looks fine. |
|
|
44
|
+
| **Tag 1** | Is the content type. A second one declares it twice. |
|
|
45
|
+
| **Unrecognized even tag** | The spec requires such an inscription to be "displayed as unbound, that is, without a location". It is indexed nowhere, permanently, and nothing local reports it. |
|
|
46
|
+
| Negative / non-integer tag | Not expressible as a script number. |
|
|
47
|
+
| Empty field value | Inscribes a zero-length field permanently for no reason. |
|
|
48
|
+
|
|
49
|
+
Build time is the last moment any of these is catchable before the money is
|
|
50
|
+
spent, which is why they throw rather than warn.
|
|
51
|
+
|
|
52
|
+
## The design decision most worth your review
|
|
53
|
+
|
|
54
|
+
`allowUnknownEvenFields` exists, and I went back and forth on it.
|
|
55
|
+
|
|
56
|
+
My first instinct was a hard wall — never emit an unrecognized even tag, no
|
|
57
|
+
exceptions. I changed my mind. The set of named tags grows as the protocol does,
|
|
58
|
+
so a library that can *never* be overridden eventually becomes both wrong and
|
|
59
|
+
unbypassable, and the workaround it forces — hand-assembled envelope bytes — is
|
|
60
|
+
considerably more dangerous than the thing the check prevents.
|
|
61
|
+
|
|
62
|
+
So it throws by default and can be overridden by a flag long enough that nobody
|
|
63
|
+
passes it by accident. If you disagree, this is the knob to turn; the reasoning
|
|
64
|
+
is in the JSDoc on `assertTagIsSafe` so it can be argued with rather than
|
|
65
|
+
guessed at.
|
|
66
|
+
|
|
67
|
+
## Byte-level details, since they are easy to get wrong
|
|
68
|
+
|
|
69
|
+
- Tags **1–16** are emitted as their opcodes; anything larger as a **minimal
|
|
70
|
+
data push**. `OP_16` is the largest numeric opcode, so tag 21 has no opcode
|
|
71
|
+
form at all.
|
|
72
|
+
- An indexer reads the resulting **stack element**, so `OP_5` and a one-byte
|
|
73
|
+
push of `0x05` are the same tag. The distinction still matters, because a data
|
|
74
|
+
push of a small number is non-minimal and non-minimal pushes are non-standard.
|
|
75
|
+
- Script numbers carry sign in the high bit of the last byte, so a tag ending
|
|
76
|
+
`>= 0x80` is zero-padded or it reads back **negative**.
|
|
77
|
+
|
|
78
|
+
## What was verified
|
|
79
|
+
|
|
80
|
+
Round-tripped through `@smartledger/ordinals` — a **separate** implementation,
|
|
81
|
+
not this library's own parser:
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
fields written : { 5: manifest, 21: thumbnail }
|
|
85
|
+
keys read back : ["01", "05", "15", ""] content-type, 5, 21, body
|
|
86
|
+
values : intact
|
|
87
|
+
warnings : [] errors: [] valid: true
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
All five refusals fire with their own messages, and the override builds while
|
|
91
|
+
the independent parser correctly warns about the result.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## What I did not touch — this is the part that needs you
|
|
96
|
+
|
|
97
|
+
**`CHANGELOG.md`, `version.js` and `package.json` all have uncommitted changes
|
|
98
|
+
in the working tree** — the TypeScript-declarations work, `types-test/`,
|
|
99
|
+
`scripts/check-types.js` and the `9.3.0` bump. Staging any of those to write a
|
|
100
|
+
changelog entry would have swept up half-finished work that is not mine.
|
|
101
|
+
|
|
102
|
+
So the feature is committed with **no changelog entry and no version**, which is
|
|
103
|
+
deliberate and needs closing out. Two options:
|
|
104
|
+
|
|
105
|
+
1. **Fold into 9.3.0.** It is already a minor bump and is not published yet
|
|
106
|
+
(npm `latest` is 9.2.0). Cleanest, if the declarations work ships with it.
|
|
107
|
+
2. **Hold for 9.4.0**, if you would rather 9.3.0 stay exactly what you scoped.
|
|
108
|
+
|
|
109
|
+
Ready to paste under whichever heading you choose:
|
|
110
|
+
|
|
111
|
+
```markdown
|
|
112
|
+
### Added — `buildInscription` can write envelope fields
|
|
113
|
+
|
|
114
|
+
`fields` takes tag numbers to values and emits them between the content type and
|
|
115
|
+
the body, in ascending tag order so identical input always produces identical
|
|
116
|
+
bytes. Tag 5 is `metadata`, the spec's own home for an object's own record; it
|
|
117
|
+
previously could not be written at all, so the only way to produce one was to
|
|
118
|
+
assemble envelope bytes by hand.
|
|
119
|
+
|
|
120
|
+
Three tags are refused at build time because each is silent afterwards. Tag 0
|
|
121
|
+
opens the body, so a field there does not fail — it becomes part of the file.
|
|
122
|
+
Tag 1 is the content type, and a second one declares it twice. An unrecognized
|
|
123
|
+
EVEN tag costs the inscription its location everywhere: the spec requires such
|
|
124
|
+
an inscription to be treated as unbound. Odd tags are ignored by an indexer that
|
|
125
|
+
does not know them, which is why the spec says it is okay to be odd.
|
|
126
|
+
|
|
127
|
+
`allowUnknownEvenFields` overrides the last of those. It exists because the
|
|
128
|
+
named tag set grows with the protocol, and a library that could never be
|
|
129
|
+
overridden would eventually be wrong AND unbypassable — sending people back to
|
|
130
|
+
hand-assembled bytes, which is worse than what the check prevents.
|
|
131
|
+
|
|
132
|
+
Tags 1..16 are emitted as opcodes and anything larger as a minimal data push,
|
|
133
|
+
since OP_16 is the largest numeric opcode. Script numbers carry sign in the high
|
|
134
|
+
bit of the last byte, so a tag ending >= 0x80 is zero-padded rather than read
|
|
135
|
+
back negative.
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Related, already shipped
|
|
139
|
+
|
|
140
|
+
`@smartledger/ordinals@0.1.6` went to npm the same day, fixing a matching blind
|
|
141
|
+
spot on the reading side: its parity check opened with `if (key.length !== 2)
|
|
142
|
+
return null`, so it only ever inspected single-byte tags. Tag 10 warned; tag
|
|
143
|
+
258 — `0x02 0x01`, even and unrecognized — did not, while a conformant indexer
|
|
144
|
+
still unbound the inscription.
|
|
145
|
+
|
|
146
|
+
Worth knowing here because the two are the same rule from opposite ends: this
|
|
147
|
+
library now refuses to *write* the hazard, and that one now reports it when it
|
|
148
|
+
*reads* one. Parity is settled by the least significant byte, which little-endian
|
|
149
|
+
puts first, so the rule holds at any tag width.
|
|
150
|
+
|
|
151
|
+
## Not investigated, flagged only
|
|
152
|
+
|
|
153
|
+
`test/smart_contract/ordinal_transfer.js` and `covenants.js` could not be run
|
|
154
|
+
from an installed copy of the package — they need dev dependencies that are not
|
|
155
|
+
in the published tarball. That is fine for you here in the repo, but it means a
|
|
156
|
+
consumer cannot independently confirm that covenants verify under mainnet flags.
|
|
157
|
+
Given 9.0.0 disclosed that they previously verified under *pre-Genesis* flags
|
|
158
|
+
while the network would have behaved differently, that is a claim worth having
|
|
159
|
+
independently checkable.
|
|
@@ -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.
|
|
725
|
+
<script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@9.4.0/bsv.min.js"></script>
|
|
726
726
|
</head>
|
|
727
727
|
<body>
|
|
728
728
|
<script>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Audit RFQ — ready to send
|
|
2
|
+
|
|
3
|
+
Three per-vendor copies of the enquiry in [`../AUDIT_SCOPE.md`](../AUDIT_SCOPE.md) §6.
|
|
4
|
+
|
|
5
|
+
| File | Vendor | Route |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| `cure53.txt` | Cure53 | `mail@cure53.de` |
|
|
8
|
+
| `ncc-group.txt` | NCC Group — Cryptography Services | enquiry form |
|
|
9
|
+
| `trail-of-bits.txt` | Trail of Bits | contact form |
|
|
10
|
+
|
|
11
|
+
**Verify each route on the vendor's own site before sending.** They are recorded here
|
|
12
|
+
as the commonly published ones, not as confirmed current addresses.
|
|
13
|
+
|
|
14
|
+
## What differs between them
|
|
15
|
+
|
|
16
|
+
Only the greeting. The scope section — everything from *"We maintain
|
|
17
|
+
@smartledger/bsv"* to the sign-off — is byte-identical in all three, checked by hash:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
cure53 78cfa6aba956d1ed
|
|
21
|
+
ncc-group 78cfa6aba956d1ed
|
|
22
|
+
trail-of-bits 78cfa6aba956d1ed
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
That is the point of `AUDIT_SCOPE.md`: every vendor prices the same thing, so the
|
|
26
|
+
spread in how they scope it back is informative. The one-sentence opener is drawn
|
|
27
|
+
from the vendor rationale in §5 and changes nothing priced — delete it if you would
|
|
28
|
+
rather they all receive identical text.
|
|
29
|
+
|
|
30
|
+
## Regenerating
|
|
31
|
+
|
|
32
|
+
These are generated from `AUDIT_SCOPE.md` §6, never hand-written, so the figures
|
|
33
|
+
cannot drift between the scope document and what a vendor receives. If you edit the
|
|
34
|
+
enquiry text, regenerate rather than editing these files.
|
|
35
|
+
|
|
36
|
+
**Before sending, re-run §7 of `AUDIT_SCOPE.md`.** The figures are measured at a
|
|
37
|
+
commit and go stale: the previous set was 445 lines light after twelve days, most of
|
|
38
|
+
it in `lib/script/interpreter.js`, which is tier 1 and therefore the number a vendor
|
|
39
|
+
quotes against. Current figures were measured 2026-08-28 at `aa551a1`.
|
|
40
|
+
|
|
41
|
+
Reply address in all three: `support@smartledger.technology`.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
To: Cure53
|
|
2
|
+
Route: mail@cure53.de — verify on cure53.de before sending
|
|
3
|
+
Reply-to: support@smartledger.technology
|
|
4
|
+
|
|
5
|
+
Subject: Audit enquiry — BSV cryptographic library core (~13k LOC JavaScript)
|
|
6
|
+
|
|
7
|
+
Hello,
|
|
8
|
+
|
|
9
|
+
We are approaching you first because you audited the Noble libraries our
|
|
10
|
+
primitives come from, so the layer beneath this code is already familiar to
|
|
11
|
+
you.
|
|
12
|
+
|
|
13
|
+
We maintain @smartledger/bsv, a Bitcoin SV library published on npm. We are
|
|
14
|
+
seeking a quote for an independent security review of its cryptographic core.
|
|
15
|
+
|
|
16
|
+
Scope, and we would like these priced separately:
|
|
17
|
+
|
|
18
|
+
Tier 1 — 12,391 lines, 33 files. Script interpreter, sighash and signing,
|
|
19
|
+
ECDSA and signature encoding, BIP-32 derivation, key and address
|
|
20
|
+
construction.
|
|
21
|
+
|
|
22
|
+
Tier 2 — 1,607 lines. BIP-39 mnemonics, ECIES, and the Base58Check/varint
|
|
23
|
+
decoding surface.
|
|
24
|
+
|
|
25
|
+
JavaScript (CommonJS), Node >= 20.19. The code is public.
|
|
26
|
+
|
|
27
|
+
Explicitly out of scope: elliptic-curve and hash primitives, which are supplied
|
|
28
|
+
by the Noble libraries and already audited; and our 24,769-line application
|
|
29
|
+
layer (credentials, tokens, ordinals), which we would treat as a separate
|
|
30
|
+
engagement.
|
|
31
|
+
|
|
32
|
+
Context that should shorten discovery: the core is inherited from bitcore and
|
|
33
|
+
has been fixed reactively but never independently reviewed. We can provide a
|
|
34
|
+
test-backed threat model, a 452-case behavioural conformance corpus that a
|
|
35
|
+
second independent implementation agrees with, and a documented history of the
|
|
36
|
+
defects we have found ourselves.
|
|
37
|
+
|
|
38
|
+
The failure mode we most want examined is code that reports a check as passed
|
|
39
|
+
without performing it — several of our own findings have had that shape.
|
|
40
|
+
|
|
41
|
+
Could you indicate availability, an approximate cost range, and what you would
|
|
42
|
+
need from us to firm that up?
|
|
43
|
+
|
|
44
|
+
Repository: https://github.com/codenlighten/smartledger-bsv
|
|
45
|
+
Package: https://www.npmjs.com/package/@smartledger/bsv
|
|
46
|
+
|
|
47
|
+
Thank you,
|
|
48
|
+
SmartLedger Technology
|
|
49
|
+
support@smartledger.technology
|