smartledger-bsv 3.4.4 → 4.0.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 +168 -0
- package/README.md +40 -40
- package/SECURITY.md +6 -3
- package/bsv-covenant.min.js +4 -4
- package/bsv-ecies.min.js +1 -1
- package/bsv-gdaf.min.js +4 -4
- package/bsv-ltp.min.js +4 -4
- package/bsv-smartcontract.min.js +3 -3
- package/bsv.bundle.js +3 -3
- package/bsv.min.js +3 -3
- package/docs/COVENANT_DEVELOPMENT_RESOLVED.md +2 -2
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/getting-started/INSTALLATION.md +25 -25
- package/docs/getting-started/QUICK_START.md +7 -7
- package/docs/migration/FROM_BSV_1_5_6.md +5 -5
- package/lib/crypto/ecdsa.js +10 -27
- package/lib/ecies/electrum-ecies.js +12 -1
- package/lib/gdaf/attestation-signer.js +37 -2
- package/lib/gdaf/attestation-verifier.js +48 -10
- package/lib/script/script.js +19 -0
- package/lib/transaction/input/publickeyhash.js +6 -1
- package/lib/transaction/transaction.js +5 -1
- package/package.json +1 -4
- package/utilities/wallet.json +0 -30
|
@@ -136,9 +136,9 @@ node custom_script_signature_test.js
|
|
|
136
136
|
## 📦 Installation
|
|
137
137
|
|
|
138
138
|
```bash
|
|
139
|
-
npm install smartledger-bsv@
|
|
139
|
+
npm install smartledger-bsv@4.0.0
|
|
140
140
|
# or
|
|
141
|
-
npm install @smartledger/bsv@
|
|
141
|
+
npm install @smartledger/bsv@4.0.0
|
|
142
142
|
```
|
|
143
143
|
|
|
144
144
|
## ✅ Verification Results
|
|
@@ -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@
|
|
58
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@4.0.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@
|
|
64
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@4.0.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@
|
|
70
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@4.0.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@
|
|
85
|
-
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@
|
|
86
|
-
| **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@
|
|
87
|
-
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@
|
|
88
|
-
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@
|
|
89
|
-
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@
|
|
90
|
-
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@
|
|
91
|
-
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@
|
|
92
|
-
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@
|
|
93
|
-
| **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@
|
|
94
|
-
| **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@
|
|
95
|
-
| **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@
|
|
84
|
+
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@4.0.0/bsv.min.js` |
|
|
85
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@4.0.0/bsv.bundle.js` |
|
|
86
|
+
| **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@4.0.0/bsv-smartcontract.min.js` |
|
|
87
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@4.0.0/bsv-covenant.min.js` |
|
|
88
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@4.0.0/bsv-script-helper.min.js` |
|
|
89
|
+
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@4.0.0/bsv-security.min.js` |
|
|
90
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@4.0.0/bsv-ecies.min.js` |
|
|
91
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@4.0.0/bsv-message.min.js` |
|
|
92
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@4.0.0/bsv-mnemonic.min.js` |
|
|
93
|
+
| **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@4.0.0/bsv-shamir.min.js` |
|
|
94
|
+
| **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@4.0.0/bsv-gdaf.min.js` |
|
|
95
|
+
| **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@4.0.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@
|
|
104
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv.min.js"></script>
|
|
104
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.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@
|
|
110
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
111
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
109
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv.min.js"></script>
|
|
110
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv-covenant.min.js"></script>
|
|
111
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.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@
|
|
117
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
118
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
116
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv.min.js"></script>
|
|
117
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv-ltp.min.js"></script>
|
|
118
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.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@
|
|
136
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
137
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
135
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv.min.js"></script>
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv-security.min.js"></script>
|
|
137
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.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@
|
|
149
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.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@
|
|
725
|
+
<script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@4.0.0/bsv.min.js"></script>
|
|
726
726
|
</head>
|
|
727
727
|
<body>
|
|
728
728
|
<script>
|
|
@@ -12,10 +12,10 @@ SmartLedger-BSV offers multiple installation methods to suit different developme
|
|
|
12
12
|
npm install @smartledger/bsv
|
|
13
13
|
|
|
14
14
|
# Install specific version
|
|
15
|
-
npm install @smartledger/bsv@
|
|
15
|
+
npm install @smartledger/bsv@4.0.0
|
|
16
16
|
|
|
17
17
|
# Install with exact version lock
|
|
18
|
-
npm install --save-exact @smartledger/bsv@
|
|
18
|
+
npm install --save-exact @smartledger/bsv@4.0.0
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
### **Usage in Node.js**
|
|
@@ -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@
|
|
51
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.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@
|
|
61
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.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@
|
|
75
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
76
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
74
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv.min.js"></script>
|
|
75
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv-covenant.min.js"></script>
|
|
76
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.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@
|
|
86
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
87
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
85
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv.min.js"></script>
|
|
86
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv-ltp.min.js"></script>
|
|
87
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.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@
|
|
102
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
103
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
101
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv.min.js"></script>
|
|
102
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv-security.min.js"></script>
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.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@
|
|
118
|
-
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@
|
|
119
|
-
| **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@
|
|
120
|
-
| **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@
|
|
121
|
-
| **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@
|
|
122
|
-
| **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@
|
|
123
|
-
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@
|
|
124
|
-
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@
|
|
125
|
-
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@
|
|
126
|
-
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@
|
|
127
|
-
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@
|
|
128
|
-
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@
|
|
117
|
+
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@4.0.0/bsv.min.js` |
|
|
118
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@4.0.0/bsv.bundle.js` |
|
|
119
|
+
| **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@4.0.0/bsv-smartcontract.min.js` |
|
|
120
|
+
| **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@4.0.0/bsv-ltp.min.js` |
|
|
121
|
+
| **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@4.0.0/bsv-gdaf.min.js` |
|
|
122
|
+
| **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@4.0.0/bsv-shamir.min.js` |
|
|
123
|
+
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@4.0.0/bsv-security.min.js` |
|
|
124
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@4.0.0/bsv-mnemonic.min.js` |
|
|
125
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@4.0.0/bsv-ecies.min.js` |
|
|
126
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@4.0.0/bsv-covenant.min.js` |
|
|
127
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@4.0.0/bsv-script-helper.min.js` |
|
|
128
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@4.0.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@
|
|
17
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv.min.js"></script>
|
|
18
18
|
|
|
19
19
|
<!-- Everything included (937KB) -->
|
|
20
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
20
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.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@
|
|
130
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv.min.js"></script>
|
|
131
131
|
|
|
132
132
|
<!-- Smart contracts (937KB) -->
|
|
133
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
133
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv-smartcontract.min.js"></script>
|
|
134
134
|
|
|
135
135
|
<!-- Legal tokens (1.16MB) -->
|
|
136
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv-ltp.min.js"></script>
|
|
137
137
|
|
|
138
138
|
<!-- Digital identity (1.16MB) -->
|
|
139
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
139
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv-gdaf.min.js"></script>
|
|
140
140
|
|
|
141
141
|
<!-- Everything (937KB) -->
|
|
142
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
142
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.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@
|
|
162
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv.min.js"></script>
|
|
163
163
|
|
|
164
164
|
<!-- Add smart contracts when ready -->
|
|
165
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
165
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv-smartcontract.min.js"></script>
|
|
166
166
|
|
|
167
167
|
<!-- Add advanced features as needed -->
|
|
168
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
169
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
168
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv-ltp.min.js"></script>
|
|
169
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv-gdaf.min.js"></script>
|
|
170
170
|
|
|
171
171
|
<!-- Everything in one file -->
|
|
172
|
-
<script src="https://unpkg.com/@smartledger/bsv@
|
|
172
|
+
<script src="https://unpkg.com/@smartledger/bsv@4.0.0/bsv.bundle.js"></script>
|
|
173
173
|
```
|
|
174
174
|
|
|
175
175
|
## 🔍 **Testing Your Migration**
|
package/lib/crypto/ecdsa.js
CHANGED
|
@@ -172,30 +172,27 @@ ECDSA.prototype.sigError = function () {
|
|
|
172
172
|
return 'hashbuf must be a 32 byte buffer'
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
// === SmartLedger Security Patches ===
|
|
176
|
-
// Apply security validation during cryptographic verification
|
|
177
175
|
var r = this.sig.r
|
|
178
176
|
var s = this.sig.s
|
|
179
177
|
var n = Point.getN()
|
|
180
178
|
|
|
181
179
|
try {
|
|
182
|
-
//
|
|
183
|
-
|
|
180
|
+
// Reject out-of-range r, s: both must lie in [1, n-1]. lte(0) covers
|
|
181
|
+
// negative and zero values; gte(n) covers anything at or above the order.
|
|
182
|
+
if (r.lte(BN.Zero) || s.lte(BN.Zero) || r.gte(n) || s.gte(n)) {
|
|
184
183
|
return 'r and s not in range'
|
|
185
184
|
}
|
|
186
185
|
|
|
187
|
-
// Fix 3: Handle canonicalization properly
|
|
188
|
-
// For verification, we need to try both the original s and canonical s
|
|
189
|
-
// This handles both pre-canonicalized signatures and non-canonical ones
|
|
190
|
-
var nh = n.shrn(1) // n/2
|
|
191
|
-
var canonicalS = s.gt(nh) ? n.sub(s) : s
|
|
192
|
-
|
|
193
186
|
var e = BN.fromBuffer(this.hashbuf, this.endian ? {
|
|
194
187
|
endian: this.endian
|
|
195
188
|
} : undefined)
|
|
196
189
|
|
|
197
|
-
//
|
|
198
|
-
|
|
190
|
+
// Standard ECDSA verification. This accepts both (r, s) and (r, n - s):
|
|
191
|
+
// ECDSA is inherently malleable in s, and verifying the canonical form
|
|
192
|
+
// yields the same accept/reject as verifying s directly, so there is no
|
|
193
|
+
// need to canonicalize or retry here. Low-S is enforced at *signing* time
|
|
194
|
+
// (see ECDSA.toLowS), which is where malleability protection belongs.
|
|
195
|
+
var sinv = s.invm(n)
|
|
199
196
|
var u1 = sinv.mul(e).umod(n)
|
|
200
197
|
var u2 = sinv.mul(r).umod(n)
|
|
201
198
|
|
|
@@ -205,23 +202,9 @@ ECDSA.prototype.sigError = function () {
|
|
|
205
202
|
}
|
|
206
203
|
|
|
207
204
|
if (p.getX().umod(n).cmp(r) !== 0) {
|
|
208
|
-
// If canonical verification failed and s was already canonical,
|
|
209
|
-
// try with the non-canonical version (for backwards compatibility)
|
|
210
|
-
if (s.lte(nh)) {
|
|
211
|
-
var nonCanonicalS = n.sub(s)
|
|
212
|
-
sinv = nonCanonicalS.invm(n)
|
|
213
|
-
u1 = sinv.mul(e).umod(n)
|
|
214
|
-
u2 = sinv.mul(r).umod(n)
|
|
215
|
-
|
|
216
|
-
p = Point.getG().mulAdd(u1, this.pubkey.point, u2)
|
|
217
|
-
if (!p.isInfinity() && p.getX().umod(n).cmp(r) === 0) {
|
|
218
|
-
return false // Verification succeeded with non-canonical s
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
205
|
return 'Invalid signature'
|
|
222
|
-
} else {
|
|
223
|
-
return false // Verification succeeded with canonical s
|
|
224
206
|
}
|
|
207
|
+
return false
|
|
225
208
|
} catch (error) {
|
|
226
209
|
return 'Signature security validation failed: ' + error.message
|
|
227
210
|
}
|
|
@@ -163,7 +163,18 @@ ECIES.prototype.decrypt = function (encbuf) {
|
|
|
163
163
|
var hmac2 = Hash.sha256hmac(encbuf.slice(0, encbuf.length - tagLength), this.kM)
|
|
164
164
|
if (this.opts.shortTag) hmac2 = hmac2.slice(0, 4)
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
// Constant-time tag comparison. Buffer.equals() short-circuits on the first
|
|
167
|
+
// differing byte, which leaks how many leading bytes matched and enables a
|
|
168
|
+
// forgery oracle on the MAC; compare every byte unconditionally instead
|
|
169
|
+
// (mirrors the loop in bitcore-ecies.js).
|
|
170
|
+
if (hmac.length !== hmac2.length) {
|
|
171
|
+
throw new errors.DecryptionError('Invalid checksum')
|
|
172
|
+
}
|
|
173
|
+
var equal = 0
|
|
174
|
+
for (var i = 0; i < hmac2.length; i++) {
|
|
175
|
+
equal |= (hmac[i] ^ hmac2[i])
|
|
176
|
+
}
|
|
177
|
+
if (equal !== 0) {
|
|
167
178
|
throw new errors.DecryptionError('Invalid checksum')
|
|
168
179
|
}
|
|
169
180
|
|
|
@@ -49,14 +49,49 @@ function AttestationSigner(privateKey, options) {
|
|
|
49
49
|
return this
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Recursively produce a value with all object keys sorted, so that
|
|
54
|
+
* JSON.stringify yields a deterministic, fully-covering serialization.
|
|
55
|
+
*
|
|
56
|
+
* IMPORTANT: this replaces a previous implementation that called
|
|
57
|
+
* `JSON.stringify(obj, Object.keys(obj).sort())`. That used the JSON.stringify
|
|
58
|
+
* *replacer array* form, which whitelists keys at EVERY nesting level to the
|
|
59
|
+
* top-level key set. The result was that nested objects (notably
|
|
60
|
+
* `credentialSubject`) serialized to `{}` and were therefore NOT covered by the
|
|
61
|
+
* signature -- a forger could rewrite the subject's claims without invalidating
|
|
62
|
+
* the proof. This recursive sort includes every key at every depth.
|
|
63
|
+
*
|
|
64
|
+
* Note: keys are ordered with Array.prototype.sort (UTF-16 code-unit order) and
|
|
65
|
+
* inserted in that order. Credential keys are non-integer strings, so insertion
|
|
66
|
+
* order is preserved by JSON.stringify; do not feed integer-like keys here.
|
|
67
|
+
*
|
|
68
|
+
* @param {*} value - Value to canonicalize
|
|
69
|
+
* @returns {*} Value with all nested object keys sorted
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
AttestationSigner._sortValue = function(value) {
|
|
73
|
+
if (Array.isArray(value)) {
|
|
74
|
+
// Arrays are order-significant: preserve order, canonicalize each element.
|
|
75
|
+
return value.map(function(item) { return AttestationSigner._sortValue(item) })
|
|
76
|
+
}
|
|
77
|
+
if (value !== null && typeof value === 'object') {
|
|
78
|
+
return Object.keys(value).sort().reduce(function(sorted, key) {
|
|
79
|
+
sorted[key] = AttestationSigner._sortValue(value[key])
|
|
80
|
+
return sorted
|
|
81
|
+
}, {})
|
|
82
|
+
}
|
|
83
|
+
// Primitives (string, number, boolean, null) are returned unchanged.
|
|
84
|
+
return value
|
|
85
|
+
}
|
|
86
|
+
|
|
52
87
|
/**
|
|
53
88
|
* Create canonical JSON string for signing
|
|
54
89
|
* @param {Object} obj - Object to canonicalize
|
|
55
90
|
* @returns {String} Canonical JSON string
|
|
56
91
|
*/
|
|
57
92
|
AttestationSigner._canonicalizeJSON = function(obj) {
|
|
58
|
-
//
|
|
59
|
-
return JSON.stringify(
|
|
93
|
+
// Deterministic serialization that covers every nested key at every depth.
|
|
94
|
+
return JSON.stringify(AttestationSigner._sortValue(obj))
|
|
60
95
|
}
|
|
61
96
|
|
|
62
97
|
/**
|
|
@@ -251,6 +251,16 @@ AttestationVerifier._validateStructure = function(credential) {
|
|
|
251
251
|
* Verify credential signature
|
|
252
252
|
* @private
|
|
253
253
|
*/
|
|
254
|
+
AttestationVerifier._normalizeDID = function(issuer) {
|
|
255
|
+
// W3C VC allows `issuer` to be a DID string or an object with an `id`.
|
|
256
|
+
var did = (issuer && typeof issuer === 'object') ? issuer.id : issuer
|
|
257
|
+
if (typeof did !== 'string' || did.length === 0) {
|
|
258
|
+
return null
|
|
259
|
+
}
|
|
260
|
+
// Strip any fragment so `did:...#keys-1` compares equal to `did:...`.
|
|
261
|
+
return did.split('#')[0]
|
|
262
|
+
}
|
|
263
|
+
|
|
254
264
|
AttestationVerifier._verifySignature = async function(credential) {
|
|
255
265
|
try {
|
|
256
266
|
var proof = credential.proof
|
|
@@ -273,7 +283,22 @@ AttestationVerifier._verifySignature = async function(credential) {
|
|
|
273
283
|
// Extract DID from verification method
|
|
274
284
|
var verificationMethod = proof.verificationMethod
|
|
275
285
|
var did = verificationMethod.split('#')[0]
|
|
276
|
-
|
|
286
|
+
|
|
287
|
+
// Bind the signing key to the claimed issuer. Without this, a valid
|
|
288
|
+
// signature from ANY DID is accepted while `credential.issuer` names a
|
|
289
|
+
// different (e.g. trusted) authority -- an issuer-spoofing forgery. The
|
|
290
|
+
// DID that owns the verificationMethod MUST equal the credential issuer.
|
|
291
|
+
var issuerDID = AttestationVerifier._normalizeDID(credential.issuer)
|
|
292
|
+
if (!issuerDID) {
|
|
293
|
+
return { valid: false, errors: ['Missing or invalid credential issuer'] }
|
|
294
|
+
}
|
|
295
|
+
if (issuerDID !== did) {
|
|
296
|
+
return {
|
|
297
|
+
valid: false,
|
|
298
|
+
errors: ['Verification method DID (' + did + ') does not match credential issuer (' + issuerDID + ')']
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
277
302
|
// Get public key from DID
|
|
278
303
|
var publicKey = DIDResolver.getPublicKey(did)
|
|
279
304
|
|
|
@@ -292,9 +317,12 @@ AttestationVerifier._verifySignature = async function(credential) {
|
|
|
292
317
|
ecdsa.hashbuf = credentialHash
|
|
293
318
|
ecdsa.pubkey = publicKey
|
|
294
319
|
ecdsa.sig = signature
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
320
|
+
|
|
321
|
+
// NOTE: ECDSA.prototype.verify() returns the ECDSA *instance* (always
|
|
322
|
+
// truthy), not a boolean. Read the `.verified` flag, otherwise every
|
|
323
|
+
// structurally-valid proof passes regardless of the actual signature.
|
|
324
|
+
var valid = ecdsa.verify().verified
|
|
325
|
+
|
|
298
326
|
if (valid) {
|
|
299
327
|
return {
|
|
300
328
|
valid: true,
|
|
@@ -355,9 +383,11 @@ AttestationVerifier._verifyPresentationSignature = async function(presentation)
|
|
|
355
383
|
ecdsa.hashbuf = presentationHash
|
|
356
384
|
ecdsa.pubkey = publicKey
|
|
357
385
|
ecdsa.sig = signature
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
386
|
+
|
|
387
|
+
// ECDSA.prototype.verify() returns the instance, not a boolean — read
|
|
388
|
+
// `.verified` (see _verifySignature).
|
|
389
|
+
var valid = ecdsa.verify().verified
|
|
390
|
+
|
|
361
391
|
return {
|
|
362
392
|
valid: valid,
|
|
363
393
|
errors: valid ? [] : ['Presentation signature verification failed']
|
|
@@ -392,10 +422,18 @@ AttestationVerifier._validateIssuer = async function(credential, options) {
|
|
|
392
422
|
return { valid: false, errors: errors }
|
|
393
423
|
}
|
|
394
424
|
|
|
395
|
-
//
|
|
425
|
+
// Enforce the trusted-issuer allow-list when one is supplied. Previously a
|
|
426
|
+
// non-member only produced a warning, so `trustedIssuers` provided no
|
|
427
|
+
// actual enforcement and any resolvable DID was accepted. Comparison is
|
|
428
|
+
// done on normalized DIDs so fragment/object issuer forms match.
|
|
396
429
|
if (options.trustedIssuers && Array.isArray(options.trustedIssuers)) {
|
|
397
|
-
|
|
398
|
-
|
|
430
|
+
var issuerDID = AttestationVerifier._normalizeDID(issuer)
|
|
431
|
+
var trusted = options.trustedIssuers
|
|
432
|
+
.map(function(t) { return AttestationVerifier._normalizeDID(t) })
|
|
433
|
+
.filter(Boolean)
|
|
434
|
+
if (!issuerDID || trusted.indexOf(issuerDID) === -1) {
|
|
435
|
+
errors.push('Issuer not in trusted list')
|
|
436
|
+
return { valid: false, errors: errors, warnings: warnings }
|
|
399
437
|
}
|
|
400
438
|
}
|
|
401
439
|
|
package/lib/script/script.js
CHANGED
|
@@ -334,6 +334,25 @@ Script.prototype.isPublicKeyHashOut = function () {
|
|
|
334
334
|
this.chunks[4].opcodenum === Opcode.OP_CHECKSIG)
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
+
/**
|
|
338
|
+
* @returns {boolean} true if the FIRST five chunks are a P2PKH pattern, regardless
|
|
339
|
+
* of any trailing chunks. Matches 1Sat Ordinals (P2PKH + `OP_FALSE OP_IF "ord" …
|
|
340
|
+
* OP_ENDIF`), MAP+BAP-style appended metadata, sCrypt covenants with a P2PKH
|
|
341
|
+
* spendable guard, etc. The strict `isPublicKeyHashOut()` is unchanged so
|
|
342
|
+
* address derivation / script classification keep their canonical semantics;
|
|
343
|
+
* this loose check is used by `Transaction.from()` so spending such outputs
|
|
344
|
+
* via the high-level API Just Works.
|
|
345
|
+
*/
|
|
346
|
+
Script.prototype.isPublicKeyHashOutPrefix = function () {
|
|
347
|
+
return !!(this.chunks.length >= 5 &&
|
|
348
|
+
this.chunks[0].opcodenum === Opcode.OP_DUP &&
|
|
349
|
+
this.chunks[1].opcodenum === Opcode.OP_HASH160 &&
|
|
350
|
+
this.chunks[2].buf &&
|
|
351
|
+
this.chunks[2].buf.length === 20 &&
|
|
352
|
+
this.chunks[3].opcodenum === Opcode.OP_EQUALVERIFY &&
|
|
353
|
+
this.chunks[4].opcodenum === Opcode.OP_CHECKSIG)
|
|
354
|
+
}
|
|
355
|
+
|
|
337
356
|
/**
|
|
338
357
|
* @returns {boolean} if this is a pay to public key hash input script
|
|
339
358
|
*/
|
|
@@ -34,7 +34,12 @@ PublicKeyHashInput.prototype.getSignatures = function (transaction, privateKey,
|
|
|
34
34
|
hashData = hashData || Hash.sha256ripemd160(privateKey.publicKey.toBuffer())
|
|
35
35
|
sigtype = sigtype || (Signature.SIGHASH_ALL | Signature.SIGHASH_FORKID)
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
// The dispatcher (Transaction._fromNonP2SH) may have routed a "P2PKH +
|
|
38
|
+
// trailing data" script here via isPublicKeyHashOutPrefix() — in which
|
|
39
|
+
// case the strict getPublicKeyHash() would throw. Read the 20-byte hash
|
|
40
|
+
// directly from chunks[2] (validated by the prefix check at dispatch).
|
|
41
|
+
var scriptPkh = this.output.script.chunks[2] && this.output.script.chunks[2].buf
|
|
42
|
+
if (scriptPkh && hashData.equals(scriptPkh)) {
|
|
38
43
|
return [new TransactionSignature({
|
|
39
44
|
publicKey: privateKey.publicKey,
|
|
40
45
|
prevTxId: this.prevTxId,
|
|
@@ -549,7 +549,11 @@ Transaction.prototype.from = function (utxo, pubkeys, threshold) {
|
|
|
549
549
|
Transaction.prototype._fromNonP2SH = function (utxo) {
|
|
550
550
|
var Clazz
|
|
551
551
|
utxo = new UnspentOutput(utxo)
|
|
552
|
-
|
|
552
|
+
// Use the loose P2PKH check so 1Sat Ordinal outputs (P2PKH + inscription
|
|
553
|
+
// envelope) and other "P2PKH + trailing data" patterns dispatch to the
|
|
554
|
+
// signing-capable subclass instead of falling through to the abstract
|
|
555
|
+
// base Input. See Script.prototype.isPublicKeyHashOutPrefix.
|
|
556
|
+
if (utxo.script.isPublicKeyHashOutPrefix()) {
|
|
553
557
|
Clazz = PublicKeyHashInput
|
|
554
558
|
} else if (utxo.script.isPublicKeyOut()) {
|
|
555
559
|
Clazz = PublicKeyInput
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smartledger-bsv",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "🚀 Complete Bitcoin SV development framework with legally-recognizable DID:web + W3C VC-JWT toolkit, Legal Token Protocol (LTP), Global Digital Attestation Framework (GDAF), StatusList2021 revocation, and 16 flexible loading options. Standards-based credentials with ES256/ES256K support, on-chain BSV anchoring, and comprehensive Bitcoin SV API. Perfect for legal tokens, verifiable credentials, DeFi, smart contracts, and secure Bitcoin applications.",
|
|
5
5
|
"author": "SmartLedger Technology <hello@smartledger.technology> (https://smartledger.technology)",
|
|
6
6
|
"homepage": "https://github.com/codenlighten/smartledger-bsv#readme",
|
|
@@ -74,7 +74,6 @@
|
|
|
74
74
|
"lib/",
|
|
75
75
|
"utilities/*.js",
|
|
76
76
|
"utilities/README.md",
|
|
77
|
-
"utilities/wallet.json",
|
|
78
77
|
"ecies/",
|
|
79
78
|
"message/",
|
|
80
79
|
"mnemonic/",
|
|
@@ -132,7 +131,6 @@
|
|
|
132
131
|
"debug-tools",
|
|
133
132
|
"modular-loading",
|
|
134
133
|
"standalone-modules",
|
|
135
|
-
"security-hardened",
|
|
136
134
|
"elliptic-curve-fix",
|
|
137
135
|
"smartledger",
|
|
138
136
|
"transaction",
|
|
@@ -184,7 +182,6 @@
|
|
|
184
182
|
"webpack-ready",
|
|
185
183
|
"cdn-ready",
|
|
186
184
|
"typescript-definitions",
|
|
187
|
-
"vulnerability-free",
|
|
188
185
|
"drop-in-replacement",
|
|
189
186
|
"performance-optimized",
|
|
190
187
|
"bip21",
|