@smartledger/bsv 9.10.0 → 9.11.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 +68 -0
- package/README.md +19 -19
- package/bsv-gdaf.min.js +58 -58
- package/bsv-ltp.min.js +28 -28
- package/bsv-smartcontract.min.js +1 -1
- package/bsv.bundle.js +58 -58
- package/bsv.min.js +58 -58
- package/docs/AUDIT_SCOPE.md +8 -8
- package/docs/BRC220_CERTIFICATE_FIELDS_AMENDMENT.md +7 -3
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/audit-rfq/cure53.txt +2 -2
- package/docs/audit-rfq/ncc-group.txt +2 -2
- package/docs/audit-rfq/trail-of-bits.txt +2 -2
- 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/lib/notaryhash/suites.js +2 -2
- package/lib/script/interpreter.js +40 -10
- package/lib/script/script.js +72 -21
- package/lib/transaction/sighash.js +12 -5
- package/package.json +1 -1
- package/version.js +1 -1
package/docs/AUDIT_SCOPE.md
CHANGED
|
@@ -34,12 +34,12 @@ module sounds. That is a deliberate revision: an earlier version of this documen
|
|
|
34
34
|
scoped Tier 1 as "the cryptographic core" and would have excluded four of the six real
|
|
35
35
|
defects this codebase has produced. See §2.1.
|
|
36
36
|
|
|
37
|
-
### Tier 1 —
|
|
37
|
+
### Tier 1 — 12,013 lines
|
|
38
38
|
|
|
39
39
|
| Module | Lines | Why it matters |
|
|
40
40
|
| --- | ---: | --- |
|
|
41
|
-
| `lib/transaction/` | 2,
|
|
42
|
-
| `lib/script/interpreter.js` | 2,
|
|
41
|
+
| `lib/transaction/` | 2,786 | Sighash construction and signing — both BIP-143 and the Original Transaction Digest Algorithm. |
|
|
42
|
+
| `lib/script/interpreter.js` | 2,851 | **Scoped to the flag and era surface, not opcode execution.** Consensus-flag selection and defaults, era derivation (Genesis/Chronicle), the limits derived from them, and the semantics of the exported `verify()`. Opcode execution is excluded — see §2.2. |
|
|
43
43
|
| `lib/crypto/` | 2,519 | ECDSA, nonce derivation, signature encoding, the script-number type. **Scope this for an architectural judgement as well as for bugs** — see §2.3. |
|
|
44
44
|
| `lib/notaryhash/` | 2,028 | BRC-220 signing and verification. Publicly reachable and relied on downstream. |
|
|
45
45
|
| `lib/privatekey.js`, `lib/publickey.js` | 843 | Key construction, serialisation, WIF. Recent defects here produced a *different* key without error. |
|
|
@@ -150,14 +150,14 @@ this repository.
|
|
|
150
150
|
| `lib/address.js`, `lib/networks.js`, `lib/opcode.js`, `lib/hdprivatekey.js`, `lib/hdpublickey.js` (2,391 lines) | Cut to pay for §2.1 | Formatting, network constants and BIP-32 derivation. No defect has originated here, and `networks.js` in particular defines addressing constants — pubkey hashes, xpub prefixes, ports, DNS seeds — and contains **no consensus-flag logic at all**. |
|
|
151
151
|
| The rest of the application layer — `lib/gdaf/`, `lib/ltp/`, `lib/ordinals/`, `lib/block/`, `lib/didweb/`, `lib/vcjwt/`, `lib/statuslist/`, most of `lib/smart_contract/`, plus assorted top-level files | Excluded | ~26,000 lines. Worth a separate engagement; including it here would blur the question in §1. Note the parts of it with a demonstrated defect history have been pulled *into* Tier 1 rather than left here — see §2.1. |
|
|
152
152
|
|
|
153
|
-
Totals reconcile against `lib/`, which is 39,
|
|
153
|
+
Totals reconcile against `lib/`, which is 39,748 lines across 131 files:
|
|
154
154
|
|
|
155
155
|
```
|
|
156
|
-
tier 1
|
|
156
|
+
tier 1 12,013
|
|
157
157
|
tier 2 1,607
|
|
158
|
-
excluded 26,
|
|
158
|
+
excluded 26,128
|
|
159
159
|
------
|
|
160
|
-
total 39,
|
|
160
|
+
total 39,748
|
|
161
161
|
```
|
|
162
162
|
|
|
163
163
|
Measured 2026-08-29 at `a954c27`. These figures drift as the library changes — an
|
|
@@ -228,7 +228,7 @@ seeking a quote for an independent security review.
|
|
|
228
228
|
|
|
229
229
|
Scope, and we would like these priced separately:
|
|
230
230
|
|
|
231
|
-
Tier 1 —
|
|
231
|
+
Tier 1 — 12,013 lines. Sighash construction and signing; ECDSA, nonce
|
|
232
232
|
derivation and signature encoding; the consensus-flag and era-derivation
|
|
233
233
|
surface of the script interpreter; BRC-220 signing and verification;
|
|
234
234
|
key construction and serialisation; the covenant verification harness and
|
|
@@ -108,7 +108,7 @@ byte forms sit in §Certificate, under the fields they describe, rather than in
|
|
|
108
108
|
> | `createdAt` | `createdAtUnix` as an ISO 8601 UTC timestamp with milliseconds, e.g. `"2026-01-01T00:00:00.000Z"`. The milliseconds are always `000`, because only whole seconds enter the canonical bytes; a verifier recovers `createdAtUnix` as the whole seconds the timestamp denotes. Advisory only — see §Verification. |
|
|
109
109
|
> | `anchor` | the object below |
|
|
110
110
|
>
|
|
111
|
-
> For `ECDSA-secp256k1`, `publicKey` is 33 bytes (compressed) or 65 (uncompressed), and `signature` is 64 bytes (`r ‖ s`, each a 32-byte big-endian integer) or DER. A verifier
|
|
111
|
+
> For `ECDSA-secp256k1`, `publicKey` is 33 bytes (compressed) or 65 (uncompressed), and `signature` is 64 bytes (`r ‖ s`, each a 32-byte big-endian integer) or DER. A verifier reads a 64-byte `signature` as `r ‖ s`, and any other `signature` as DER, which must parse as DER. DER can itself be 64 bytes long — only when `r` and `s` are unusually short — and is then read as `r ‖ s` and does not verify; a signer holding such a signature sends it as `r ‖ s` instead. `S` is not normalised: the certificate commits, through `proofHash`, to the exact bytes the signer produced, so the malleated form of a signature is a different certificate rather than a forgery of this one.
|
|
112
112
|
>
|
|
113
113
|
> `anchor` locates the on-chain record:
|
|
114
114
|
>
|
|
@@ -198,7 +198,7 @@ untouched.
|
|
|
198
198
|
|
|
199
199
|
## Decisions
|
|
200
200
|
|
|
201
|
-
The first draft left six points to the author. Each is decided here, with the reason.
|
|
201
|
+
The first draft left six points to the author; review added a seventh. Each is decided here, with the reason.
|
|
202
202
|
|
|
203
203
|
1. **A verifier refuses a `version` it does not implement.** This is in the proposed text.
|
|
204
204
|
The reference wrote `"1.0"` and read anything: a certificate saying `"2.0"` passed its
|
|
@@ -227,7 +227,11 @@ The first draft left six points to the author. Each is decided here, with the re
|
|
|
227
227
|
is one implementation's history. That implementation's readers handle it:
|
|
228
228
|
`@smartledger/bsv` reads those certificates and reports them as legacy. A clause in the
|
|
229
229
|
spec would bind every other implementation to the same history.
|
|
230
|
-
6. **
|
|
230
|
+
6. **A 64-byte signature is always `r ‖ s`.** Review of #247 pointed out that DER can itself
|
|
231
|
+
be 64 bytes long, so the first wording, "DER is not 64 bytes long", was false. The text now
|
|
232
|
+
states the decoding rule the reference applies: exactly 64 bytes is `r ‖ s`, and anything
|
|
233
|
+
else must parse as DER.
|
|
234
|
+
7. **High-S ECDSA is accepted.** This is in the proposed text, as the reference behaves.
|
|
231
235
|
Requiring low-S would reject certificates the reference has already issued, and
|
|
232
236
|
`proofHash` already stops the malleated form from being passed off as the same
|
|
233
237
|
certificate.
|
|
@@ -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.11.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.11.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.11.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.11.0/bsv.min.js` |
|
|
85
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.11.0/bsv.bundle.js` |
|
|
86
|
+
| **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@9.11.0/bsv-smartcontract.min.js` |
|
|
87
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.11.0/bsv-covenant.min.js` |
|
|
88
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.11.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.11.0/bsv-security.min.js` |
|
|
90
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@9.11.0/bsv-ecies.min.js` |
|
|
91
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@9.11.0/bsv-message.min.js` |
|
|
92
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@9.11.0/bsv-mnemonic.min.js` |
|
|
93
|
+
| **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@9.11.0/bsv-shamir.min.js` |
|
|
94
|
+
| **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@9.11.0/bsv-gdaf.min.js` |
|
|
95
|
+
| **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@9.11.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.11.0/bsv.min.js"></script>
|
|
104
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.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.11.0/bsv.min.js"></script>
|
|
110
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv-covenant.min.js"></script>
|
|
111
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.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.11.0/bsv.min.js"></script>
|
|
117
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv-ltp.min.js"></script>
|
|
118
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.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.11.0/bsv.min.js"></script>
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv-security.min.js"></script>
|
|
137
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.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.11.0/bsv.bundle.js"></script>
|
|
150
150
|
<script>
|
|
151
151
|
// Everything available immediately
|
|
152
152
|
const shares = bsv.splitSecret('secret', 5, 3);
|
|
@@ -722,7 +722,7 @@ interface UTXO {
|
|
|
722
722
|
<html>
|
|
723
723
|
<head>
|
|
724
724
|
<title>UTXO Manager Demo</title>
|
|
725
|
-
<script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@9.
|
|
725
|
+
<script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@9.11.0/bsv.min.js"></script>
|
|
726
726
|
</head>
|
|
727
727
|
<body>
|
|
728
728
|
<script>
|
|
@@ -15,7 +15,7 @@ seeking a quote for an independent security review of its cryptographic core.
|
|
|
15
15
|
|
|
16
16
|
Scope, and we would like these priced separately:
|
|
17
17
|
|
|
18
|
-
Tier 1 —
|
|
18
|
+
Tier 1 — 12,013 lines. Sighash construction and signing; ECDSA, nonce
|
|
19
19
|
derivation and signature encoding; the consensus-flag and era surface of the
|
|
20
20
|
script interpreter; BRC-220 signing; the covenant verification harness; RFC
|
|
21
21
|
8785 canonicalization; and the covenant-facing entrypoints of the smart
|
|
@@ -30,7 +30,7 @@ Explicitly out of scope: elliptic-curve and hash primitives, which are supplied
|
|
|
30
30
|
by the Noble libraries and already audited; opcode EXECUTION in the script
|
|
31
31
|
interpreter, which passes 1,483 of 1,483 of the reference node's own consensus
|
|
32
32
|
vectors with zero false accepts and zero false rejects; and the remaining
|
|
33
|
-
26,
|
|
33
|
+
26,128-line application layer (credentials, tokens, ordinals), which we would
|
|
34
34
|
treat as a separate engagement.
|
|
35
35
|
|
|
36
36
|
Note the shape of that first exclusion, because it is what we want priced. The
|
|
@@ -15,7 +15,7 @@ seeking a quote for an independent security review of its cryptographic core.
|
|
|
15
15
|
|
|
16
16
|
Scope, and we would like these priced separately:
|
|
17
17
|
|
|
18
|
-
Tier 1 —
|
|
18
|
+
Tier 1 — 12,013 lines. Sighash construction and signing; ECDSA, nonce
|
|
19
19
|
derivation and signature encoding; the consensus-flag and era surface of the
|
|
20
20
|
script interpreter; BRC-220 signing; the covenant verification harness; RFC
|
|
21
21
|
8785 canonicalization; and the covenant-facing entrypoints of the smart
|
|
@@ -30,7 +30,7 @@ Explicitly out of scope: elliptic-curve and hash primitives, which are supplied
|
|
|
30
30
|
by the Noble libraries and already audited; opcode EXECUTION in the script
|
|
31
31
|
interpreter, which passes 1,483 of 1,483 of the reference node's own consensus
|
|
32
32
|
vectors with zero false accepts and zero false rejects; and the remaining
|
|
33
|
-
26,
|
|
33
|
+
26,128-line application layer (credentials, tokens, ordinals), which we would
|
|
34
34
|
treat as a separate engagement.
|
|
35
35
|
|
|
36
36
|
Note the shape of that first exclusion, because it is what we want priced. The
|
|
@@ -15,7 +15,7 @@ seeking a quote for an independent security review of its cryptographic core.
|
|
|
15
15
|
|
|
16
16
|
Scope, and we would like these priced separately:
|
|
17
17
|
|
|
18
|
-
Tier 1 —
|
|
18
|
+
Tier 1 — 12,013 lines. Sighash construction and signing; ECDSA, nonce
|
|
19
19
|
derivation and signature encoding; the consensus-flag and era surface of the
|
|
20
20
|
script interpreter; BRC-220 signing; the covenant verification harness; RFC
|
|
21
21
|
8785 canonicalization; and the covenant-facing entrypoints of the smart
|
|
@@ -30,7 +30,7 @@ Explicitly out of scope: elliptic-curve and hash primitives, which are supplied
|
|
|
30
30
|
by the Noble libraries and already audited; opcode EXECUTION in the script
|
|
31
31
|
interpreter, which passes 1,483 of 1,483 of the reference node's own consensus
|
|
32
32
|
vectors with zero false accepts and zero false rejects; and the remaining
|
|
33
|
-
26,
|
|
33
|
+
26,128-line application layer (credentials, tokens, ordinals), which we would
|
|
34
34
|
treat as a separate engagement.
|
|
35
35
|
|
|
36
36
|
Note the shape of that first exclusion, because it is what we want priced. The
|
|
@@ -48,7 +48,7 @@ const tx: Transaction = new Transaction();
|
|
|
48
48
|
#### **Core Library Only (937KB)**
|
|
49
49
|
For basic Bitcoin SV operations:
|
|
50
50
|
```html
|
|
51
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
51
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv.min.js"></script>
|
|
52
52
|
<script>
|
|
53
53
|
const privateKey = new bsv.PrivateKey();
|
|
54
54
|
const address = privateKey.toAddress();
|
|
@@ -58,7 +58,7 @@ For basic Bitcoin SV operations:
|
|
|
58
58
|
#### **Complete Bundle (937KB)**
|
|
59
59
|
Everything in one file:
|
|
60
60
|
```html
|
|
61
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
61
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv.bundle.js"></script>
|
|
62
62
|
<script>
|
|
63
63
|
// All features available immediately
|
|
64
64
|
const shares = bsv.splitSecret('secret', 5, 3);
|
|
@@ -71,9 +71,9 @@ Everything in one file:
|
|
|
71
71
|
|
|
72
72
|
#### **Smart Contract Development (~2.7MB total — each bundle is self-contained and re-embeds core BSV)**
|
|
73
73
|
```html
|
|
74
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
75
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
76
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
74
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv.min.js"></script>
|
|
75
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv-covenant.min.js"></script>
|
|
76
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv-smartcontract.min.js"></script>
|
|
77
77
|
<script>
|
|
78
78
|
const covenant = bsv.SmartContract.createCovenantBuilder()
|
|
79
79
|
.extractField('amount').push(50000).greaterThanOrEqual().build();
|
|
@@ -82,9 +82,9 @@ Everything in one file:
|
|
|
82
82
|
|
|
83
83
|
#### **Legal & Identity Development (~3.2MB total — each bundle is self-contained and re-embeds core BSV)**
|
|
84
84
|
```html
|
|
85
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
86
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
87
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
85
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv.min.js"></script>
|
|
86
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv-ltp.min.js"></script>
|
|
87
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv-gdaf.min.js"></script>
|
|
88
88
|
<script>
|
|
89
89
|
// Legal Token Protocol
|
|
90
90
|
const propertyToken = bsv.createPropertyToken({
|
|
@@ -98,9 +98,9 @@ Everything in one file:
|
|
|
98
98
|
|
|
99
99
|
#### **Security & Cryptography (~1.4MB total — each bundle is self-contained and re-embeds core BSV)**
|
|
100
100
|
```html
|
|
101
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
102
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
103
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
101
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv.min.js"></script>
|
|
102
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv-security.min.js"></script>
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv-shamir.min.js"></script>
|
|
104
104
|
<script>
|
|
105
105
|
// Threshold Cryptography
|
|
106
106
|
const shares = bsv.splitSecret('my_secret_key', 5, 3);
|
|
@@ -114,18 +114,18 @@ Everything in one file:
|
|
|
114
114
|
|
|
115
115
|
| Module | Size | Purpose | CDN Link |
|
|
116
116
|
|--------|------|---------|----------|
|
|
117
|
-
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.
|
|
118
|
-
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.
|
|
119
|
-
| **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@9.
|
|
120
|
-
| **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@9.
|
|
121
|
-
| **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@9.
|
|
122
|
-
| **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@9.
|
|
123
|
-
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@9.
|
|
124
|
-
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@9.
|
|
125
|
-
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@9.
|
|
126
|
-
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.
|
|
127
|
-
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.
|
|
128
|
-
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@9.
|
|
117
|
+
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@9.11.0/bsv.min.js` |
|
|
118
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@9.11.0/bsv.bundle.js` |
|
|
119
|
+
| **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@9.11.0/bsv-smartcontract.min.js` |
|
|
120
|
+
| **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@9.11.0/bsv-ltp.min.js` |
|
|
121
|
+
| **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@9.11.0/bsv-gdaf.min.js` |
|
|
122
|
+
| **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@9.11.0/bsv-shamir.min.js` |
|
|
123
|
+
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@9.11.0/bsv-security.min.js` |
|
|
124
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@9.11.0/bsv-mnemonic.min.js` |
|
|
125
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@9.11.0/bsv-ecies.min.js` |
|
|
126
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@9.11.0/bsv-covenant.min.js` |
|
|
127
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@9.11.0/bsv-script-helper.min.js` |
|
|
128
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@9.11.0/bsv-message.min.js` |
|
|
129
129
|
|
|
130
130
|
## ⚙️ **Development Environment Setup**
|
|
131
131
|
|
|
@@ -14,10 +14,10 @@ npm install @smartledger/bsv
|
|
|
14
14
|
### Browser CDN (Instant)
|
|
15
15
|
```html
|
|
16
16
|
<!-- Core library (937KB) -->
|
|
17
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
17
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv.min.js"></script>
|
|
18
18
|
|
|
19
19
|
<!-- Everything included (937KB) -->
|
|
20
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
20
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv.bundle.js"></script>
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## 💰 **Your First Transaction (60 seconds)**
|
|
@@ -127,19 +127,19 @@ SmartLedger-BSV offers 12 different loading options - use only what you need:
|
|
|
127
127
|
|
|
128
128
|
```html
|
|
129
129
|
<!-- Core BSV only (937KB) -->
|
|
130
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
130
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv.min.js"></script>
|
|
131
131
|
|
|
132
132
|
<!-- Smart contracts (937KB) -->
|
|
133
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
133
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv-smartcontract.min.js"></script>
|
|
134
134
|
|
|
135
135
|
<!-- Legal tokens (1.16MB) -->
|
|
136
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv-ltp.min.js"></script>
|
|
137
137
|
|
|
138
138
|
<!-- Digital identity (1.16MB) -->
|
|
139
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
139
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv-gdaf.min.js"></script>
|
|
140
140
|
|
|
141
141
|
<!-- Everything (937KB) -->
|
|
142
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
142
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv.bundle.js"></script>
|
|
143
143
|
```
|
|
144
144
|
|
|
145
145
|
## ⚡ **Key Advantages**
|
|
@@ -159,17 +159,17 @@ const recovered = bsv.reconstructSecret([shares[0], shares[2], shares[4]]);
|
|
|
159
159
|
### **New Modular Options**
|
|
160
160
|
```html
|
|
161
161
|
<!-- Core compatibility (same size as bsv@1.5.6) -->
|
|
162
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
162
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv.min.js"></script>
|
|
163
163
|
|
|
164
164
|
<!-- Add smart contracts when ready -->
|
|
165
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
165
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv-smartcontract.min.js"></script>
|
|
166
166
|
|
|
167
167
|
<!-- Add advanced features as needed -->
|
|
168
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
169
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
168
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv-ltp.min.js"></script>
|
|
169
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv-gdaf.min.js"></script>
|
|
170
170
|
|
|
171
171
|
<!-- Everything in one file -->
|
|
172
|
-
<script src="https://unpkg.com/@smartledger/bsv@9.
|
|
172
|
+
<script src="https://unpkg.com/@smartledger/bsv@9.11.0/bsv.bundle.js"></script>
|
|
173
173
|
```
|
|
174
174
|
|
|
175
175
|
## 🔍 **Testing Your Migration**
|
package/lib/notaryhash/suites.js
CHANGED
|
@@ -107,8 +107,8 @@ Suites.verify = function (algorithm, payloadHash, signature, publicKey) {
|
|
|
107
107
|
* What it accepts is what the reference implementation accepts, because a verifier that
|
|
108
108
|
* refuses certificates the reference issued is not a BRC-220 verifier:
|
|
109
109
|
*
|
|
110
|
-
* - a signature of 64 bytes, `r || s`, each a 32-byte big-endian integer, OR DER
|
|
111
|
-
*
|
|
110
|
+
* - a signature of 64 bytes, `r || s`, each a 32-byte big-endian integer, OR DER. A
|
|
111
|
+
* 64-byte signature is always read as r || s; anything else must parse as DER. The
|
|
112
112
|
* certificate's `encoding` field says how the bytes are WRITTEN — hex or base64 — and
|
|
113
113
|
* nothing about which of these they are;
|
|
114
114
|
* - a 33-byte compressed or 65-byte uncompressed public key;
|
|
@@ -896,6 +896,20 @@ Interpreter.prototype.checkSignatureEncoding = function (buf) {
|
|
|
896
896
|
return true
|
|
897
897
|
}
|
|
898
898
|
|
|
899
|
+
/**
|
|
900
|
+
* The node's CleanupScriptCode: remove the signature from the scriptCode it
|
|
901
|
+
* signs, unless it is a FORKID signature and FORKID is enabled. An empty
|
|
902
|
+
* signature has hash type 0, so without FORKID it removes every OP_0, as the
|
|
903
|
+
* node's does.
|
|
904
|
+
*/
|
|
905
|
+
function cleanupScriptCode (subscript, bufSig, flags) {
|
|
906
|
+
var hashType = bufSig.length ? bufSig[bufSig.length - 1] : 0
|
|
907
|
+
if (!(flags & Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID) || !(hashType & Signature.SIGHASH_FORKID)) {
|
|
908
|
+
subscript.findAndDelete(new Script().add(bufSig))
|
|
909
|
+
}
|
|
910
|
+
return subscript
|
|
911
|
+
}
|
|
912
|
+
|
|
899
913
|
/**
|
|
900
914
|
* Translated from bitcoind's CheckPubKeyEncoding
|
|
901
915
|
*/
|
|
@@ -1091,6 +1105,9 @@ Interpreter._minimallyEncode = function (buf) {
|
|
|
1091
1105
|
}
|
|
1092
1106
|
|
|
1093
1107
|
// We are not minimally encoded, we need to figure out how much to trim.
|
|
1108
|
+
// Work on a copy: the argument can be a stack element that is also the
|
|
1109
|
+
// script's push data or a shared constant.
|
|
1110
|
+
buf = Buffer.from(buf)
|
|
1094
1111
|
for (var i = buf.length - 1; i > 0; i--) {
|
|
1095
1112
|
// We found a non zero byte, time to encode.
|
|
1096
1113
|
if (buf[i - 1] !== 0) {
|
|
@@ -2067,29 +2084,33 @@ Interpreter.prototype.step = function () {
|
|
|
2067
2084
|
return false
|
|
2068
2085
|
}
|
|
2069
2086
|
|
|
2070
|
-
//
|
|
2087
|
+
// Into a new buffer, never in place: an operand can be the script's
|
|
2088
|
+
// own push data, an OP_SPLIT view of it, or the shared Interpreter.true
|
|
2089
|
+
// (and both operands can be that same buffer). Writing into it
|
|
2090
|
+
// rewrote the script and corrupted TRUE for every later evaluation.
|
|
2091
|
+
spliced = Buffer.alloc(buf1.length)
|
|
2071
2092
|
switch (opcodenum) {
|
|
2072
2093
|
case Opcode.OP_AND:
|
|
2073
2094
|
for (let i = 0; i < buf1.length; i++) {
|
|
2074
|
-
buf1[i]
|
|
2095
|
+
spliced[i] = buf1[i] & buf2[i]
|
|
2075
2096
|
}
|
|
2076
2097
|
break
|
|
2077
2098
|
case Opcode.OP_OR:
|
|
2078
2099
|
for (let i = 0; i < buf1.length; i++) {
|
|
2079
|
-
buf1[i]
|
|
2100
|
+
spliced[i] = buf1[i] | buf2[i]
|
|
2080
2101
|
}
|
|
2081
2102
|
break
|
|
2082
2103
|
case Opcode.OP_XOR:
|
|
2083
2104
|
for (let i = 0; i < buf1.length; i++) {
|
|
2084
|
-
buf1[i]
|
|
2105
|
+
spliced[i] = buf1[i] ^ buf2[i]
|
|
2085
2106
|
}
|
|
2086
2107
|
break
|
|
2087
2108
|
default:
|
|
2088
2109
|
break
|
|
2089
2110
|
}
|
|
2090
2111
|
|
|
2091
|
-
// And pop vch2.
|
|
2092
2112
|
this.stack.pop()
|
|
2113
|
+
this.stack[this.stack.length - 1] = spliced
|
|
2093
2114
|
break
|
|
2094
2115
|
|
|
2095
2116
|
case Opcode.OP_INVERT:
|
|
@@ -2101,10 +2122,13 @@ Interpreter.prototype.step = function () {
|
|
|
2101
2122
|
// stack error it had already decided on.
|
|
2102
2123
|
return false
|
|
2103
2124
|
}
|
|
2125
|
+
// A new buffer, for the same reason as OP_AND above.
|
|
2104
2126
|
buf = stacktop(-1)
|
|
2127
|
+
buf1 = Buffer.alloc(buf.length)
|
|
2105
2128
|
for (let i = 0; i < buf.length; i++) {
|
|
2106
|
-
|
|
2129
|
+
buf1[i] = ~buf[i] & 0xff
|
|
2107
2130
|
}
|
|
2131
|
+
this.stack[this.stack.length - 1] = buf1
|
|
2108
2132
|
break
|
|
2109
2133
|
|
|
2110
2134
|
case Opcode.OP_LSHIFT:
|
|
@@ -2415,9 +2439,12 @@ Interpreter.prototype.step = function () {
|
|
|
2415
2439
|
chunks: this.script.chunks.slice(this.pbegincodehash)
|
|
2416
2440
|
})
|
|
2417
2441
|
|
|
2418
|
-
// Drop the signature, since there's no way for a signature to sign
|
|
2419
|
-
|
|
2420
|
-
|
|
2442
|
+
// Drop the signature, since there's no way for a signature to sign
|
|
2443
|
+
// itself — but only where the node does: not for a FORKID signature
|
|
2444
|
+
// when FORKID is enabled (CleanupScriptCode). Removing it there let a
|
|
2445
|
+
// signature over the script minus a pushed copy of itself verify here
|
|
2446
|
+
// and fail on the network.
|
|
2447
|
+
cleanupScriptCode(subscript, bufSig, this.flags)
|
|
2421
2448
|
|
|
2422
2449
|
try {
|
|
2423
2450
|
sig = Signature.fromTxFormat(bufSig)
|
|
@@ -2515,7 +2542,7 @@ Interpreter.prototype.step = function () {
|
|
|
2515
2542
|
// Drop the signatures, since there's no way for a signature to sign itself
|
|
2516
2543
|
for (var k = 0; k < nSigsCount; k++) {
|
|
2517
2544
|
bufSig = stacktop(-isig - k)
|
|
2518
|
-
subscript
|
|
2545
|
+
cleanupScriptCode(subscript, bufSig, this.flags)
|
|
2519
2546
|
}
|
|
2520
2547
|
|
|
2521
2548
|
fSuccess = true
|
|
@@ -2770,6 +2797,9 @@ Interpreter.prototype.step = function () {
|
|
|
2770
2797
|
|
|
2771
2798
|
var signbit = 0x00
|
|
2772
2799
|
if (rawnum.length > 0) {
|
|
2800
|
+
// A copy before clearing the sign bit: rawnum can still be the
|
|
2801
|
+
// operand itself when it was already minimally encoded.
|
|
2802
|
+
rawnum = Buffer.from(rawnum)
|
|
2773
2803
|
signbit = rawnum[rawnum.length - 1] & 0x80
|
|
2774
2804
|
rawnum[rawnum.length - 1] &= 0x7f
|
|
2775
2805
|
}
|