@smartledger/bsv 7.5.2 → 7.5.4
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 +78 -0
- package/README.md +38 -38
- package/bsv-anchor.min.js +8 -8
- package/bsv-didweb.min.js +8 -8
- package/bsv-gdaf.min.js +48 -48
- package/bsv-ltp.min.js +48 -48
- package/bsv-mnemonic.min.js +11 -11
- package/bsv-shamir.min.js +11 -11
- package/bsv-smartcontract.min.js +7 -7
- package/bsv-statuslist.min.js +29 -29
- package/bsv-vcjwt.min.js +10 -10
- package/bsv.bundle.js +48 -48
- package/bsv.min.js +48 -48
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- 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/gdaf/smartledger-anchor.js +120 -11
- package/package.json +4 -4
- package/test/gdaf/anchor_no_key_leak.js +59 -1
- package/version.js +1 -1
|
@@ -55,19 +55,19 @@ Three advanced modules totaling **~2.7MB** of functionality:
|
|
|
55
55
|
- **Purpose**: Threshold cryptography for secure secret distribution
|
|
56
56
|
- **Use Cases**: Backup keys, multi-party security, key recovery
|
|
57
57
|
- **Features**: Split secrets into N shares, require M to reconstruct
|
|
58
|
-
- **CDN**: `unpkg.com/@smartledger/bsv@7.5.
|
|
58
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@7.5.4/bsv-shamir.min.js`
|
|
59
59
|
|
|
60
60
|
#### **🌐 Global Digital Attestation Framework - GDAF (1184KB)**
|
|
61
61
|
- **Purpose**: W3C Verifiable Credentials and decentralized identity
|
|
62
62
|
- **Use Cases**: Identity verification, attestations, zero-knowledge proofs
|
|
63
63
|
- **Features**: DID creation, credential issuance, selective disclosure
|
|
64
|
-
- **CDN**: `unpkg.com/@smartledger/bsv@7.5.
|
|
64
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@7.5.4/bsv-gdaf.min.js`
|
|
65
65
|
|
|
66
66
|
#### **⚖️ Legal Token Protocol - LTP (1184KB)**
|
|
67
67
|
- **Purpose**: Legal compliance framework for tokenized assets
|
|
68
68
|
- **Use Cases**: Property rights, obligations, compliant tokenization
|
|
69
69
|
- **Features**: Legal primitives, compliance checking, attestation anchoring
|
|
70
|
-
- **CDN**: `unpkg.com/@smartledger/bsv@7.5.
|
|
70
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@7.5.4/bsv-ltp.min.js`
|
|
71
71
|
|
|
72
72
|
### **2. Incorrect File Sizes in Documentation**
|
|
73
73
|
|
|
@@ -81,18 +81,18 @@ Three advanced modules totaling **~2.7MB** of functionality:
|
|
|
81
81
|
|
|
82
82
|
| Module | Size | Use Case | CDN Link |
|
|
83
83
|
|--------|------|----------|----------|
|
|
84
|
-
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.5.
|
|
85
|
-
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.5.
|
|
86
|
-
| **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.5.
|
|
87
|
-
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.5.
|
|
88
|
-
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.5.
|
|
89
|
-
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.5.
|
|
90
|
-
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.5.
|
|
91
|
-
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.5.
|
|
92
|
-
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.5.
|
|
93
|
-
| **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.5.
|
|
94
|
-
| **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.5.
|
|
95
|
-
| **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.5.
|
|
84
|
+
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.5.4/bsv.min.js` |
|
|
85
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.5.4/bsv.bundle.js` |
|
|
86
|
+
| **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.5.4/bsv-smartcontract.min.js` |
|
|
87
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.5.4/bsv-covenant.min.js` |
|
|
88
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.5.4/bsv-script-helper.min.js` |
|
|
89
|
+
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.5.4/bsv-security.min.js` |
|
|
90
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.5.4/bsv-ecies.min.js` |
|
|
91
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.5.4/bsv-message.min.js` |
|
|
92
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.5.4/bsv-mnemonic.min.js` |
|
|
93
|
+
| **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.5.4/bsv-shamir.min.js` |
|
|
94
|
+
| **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.5.4/bsv-gdaf.min.js` |
|
|
95
|
+
| **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.5.4/bsv-ltp.min.js` |
|
|
96
96
|
|
|
97
97
|
## 🎯 **Updated Usage Examples**
|
|
98
98
|
|
|
@@ -100,22 +100,22 @@ Three advanced modules totaling **~2.7MB** of functionality:
|
|
|
100
100
|
|
|
101
101
|
#### **1. Basic Development (~963KB)**
|
|
102
102
|
```html
|
|
103
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
104
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv.min.js"></script>
|
|
104
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-script-helper.min.js"></script>
|
|
105
105
|
```
|
|
106
106
|
|
|
107
107
|
#### **2. Smart Contract Development (~2.7MB — each bundle re-embeds core BSV)**
|
|
108
108
|
```html
|
|
109
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
110
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
111
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
109
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv.min.js"></script>
|
|
110
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-covenant.min.js"></script>
|
|
111
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-smartcontract.min.js"></script>
|
|
112
112
|
```
|
|
113
113
|
|
|
114
114
|
#### **3. 🆕 Legal & Compliance Development (~3.2MB — each bundle re-embeds core BSV)**
|
|
115
115
|
```html
|
|
116
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
117
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
118
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
116
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv.min.js"></script>
|
|
117
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-ltp.min.js"></script>
|
|
118
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-gdaf.min.js"></script>
|
|
119
119
|
<script>
|
|
120
120
|
// Legal Token Protocol
|
|
121
121
|
const legalToken = bsv.createLegalToken({
|
|
@@ -132,9 +132,9 @@ Three advanced modules totaling **~2.7MB** of functionality:
|
|
|
132
132
|
|
|
133
133
|
#### **4. 🆕 Security & Cryptography (~1.4MB)**
|
|
134
134
|
```html
|
|
135
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
136
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
137
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
135
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv.min.js"></script>
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-security.min.js"></script>
|
|
137
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-shamir.min.js"></script>
|
|
138
138
|
<script>
|
|
139
139
|
// Shamir Secret Sharing
|
|
140
140
|
const shares = bsv.splitSecret('my_secret_key', 5, 3); // 5 shares, 3 needed
|
|
@@ -146,7 +146,7 @@ Three advanced modules totaling **~2.7MB** of functionality:
|
|
|
146
146
|
|
|
147
147
|
#### **5. Everything Bundle (937KB)**
|
|
148
148
|
```html
|
|
149
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
149
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv.bundle.js"></script>
|
|
150
150
|
<script>
|
|
151
151
|
// Everything available immediately
|
|
152
152
|
const shares = bsv.splitSecret('secret', 5, 3);
|
|
@@ -722,7 +722,7 @@ interface UTXO {
|
|
|
722
722
|
<html>
|
|
723
723
|
<head>
|
|
724
724
|
<title>UTXO Manager Demo</title>
|
|
725
|
-
<script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@7.5.
|
|
725
|
+
<script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@7.5.4/bsv.min.js"></script>
|
|
726
726
|
</head>
|
|
727
727
|
<body>
|
|
728
728
|
<script>
|
|
@@ -48,7 +48,7 @@ const tx: Transaction = new Transaction();
|
|
|
48
48
|
#### **Core Library Only (937KB)**
|
|
49
49
|
For basic Bitcoin SV operations:
|
|
50
50
|
```html
|
|
51
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
51
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv.min.js"></script>
|
|
52
52
|
<script>
|
|
53
53
|
const privateKey = new bsv.PrivateKey();
|
|
54
54
|
const address = privateKey.toAddress();
|
|
@@ -58,7 +58,7 @@ For basic Bitcoin SV operations:
|
|
|
58
58
|
#### **Complete Bundle (937KB)**
|
|
59
59
|
Everything in one file:
|
|
60
60
|
```html
|
|
61
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
61
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv.bundle.js"></script>
|
|
62
62
|
<script>
|
|
63
63
|
// All features available immediately
|
|
64
64
|
const shares = bsv.splitSecret('secret', 5, 3);
|
|
@@ -71,9 +71,9 @@ Everything in one file:
|
|
|
71
71
|
|
|
72
72
|
#### **Smart Contract Development (~2.7MB total — each bundle is self-contained and re-embeds core BSV)**
|
|
73
73
|
```html
|
|
74
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
75
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
76
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
74
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv.min.js"></script>
|
|
75
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-covenant.min.js"></script>
|
|
76
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-smartcontract.min.js"></script>
|
|
77
77
|
<script>
|
|
78
78
|
const covenant = bsv.SmartContract.createCovenantBuilder()
|
|
79
79
|
.extractField('amount').push(50000).greaterThanOrEqual().build();
|
|
@@ -82,9 +82,9 @@ Everything in one file:
|
|
|
82
82
|
|
|
83
83
|
#### **Legal & Identity Development (~3.2MB total — each bundle is self-contained and re-embeds core BSV)**
|
|
84
84
|
```html
|
|
85
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
86
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
87
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
85
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv.min.js"></script>
|
|
86
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-ltp.min.js"></script>
|
|
87
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-gdaf.min.js"></script>
|
|
88
88
|
<script>
|
|
89
89
|
// Legal Token Protocol
|
|
90
90
|
const propertyToken = bsv.createPropertyToken({
|
|
@@ -98,9 +98,9 @@ Everything in one file:
|
|
|
98
98
|
|
|
99
99
|
#### **Security & Cryptography (~1.4MB total — each bundle is self-contained and re-embeds core BSV)**
|
|
100
100
|
```html
|
|
101
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
102
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
103
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
101
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv.min.js"></script>
|
|
102
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-security.min.js"></script>
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-shamir.min.js"></script>
|
|
104
104
|
<script>
|
|
105
105
|
// Threshold Cryptography
|
|
106
106
|
const shares = bsv.splitSecret('my_secret_key', 5, 3);
|
|
@@ -114,18 +114,18 @@ Everything in one file:
|
|
|
114
114
|
|
|
115
115
|
| Module | Size | Purpose | CDN Link |
|
|
116
116
|
|--------|------|---------|----------|
|
|
117
|
-
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.5.
|
|
118
|
-
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.5.
|
|
119
|
-
| **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.5.
|
|
120
|
-
| **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.5.
|
|
121
|
-
| **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.5.
|
|
122
|
-
| **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.5.
|
|
123
|
-
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.5.
|
|
124
|
-
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.5.
|
|
125
|
-
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.5.
|
|
126
|
-
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.5.
|
|
127
|
-
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.5.
|
|
128
|
-
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.5.
|
|
117
|
+
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.5.4/bsv.min.js` |
|
|
118
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.5.4/bsv.bundle.js` |
|
|
119
|
+
| **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.5.4/bsv-smartcontract.min.js` |
|
|
120
|
+
| **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.5.4/bsv-ltp.min.js` |
|
|
121
|
+
| **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.5.4/bsv-gdaf.min.js` |
|
|
122
|
+
| **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.5.4/bsv-shamir.min.js` |
|
|
123
|
+
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.5.4/bsv-security.min.js` |
|
|
124
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.5.4/bsv-mnemonic.min.js` |
|
|
125
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.5.4/bsv-ecies.min.js` |
|
|
126
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.5.4/bsv-covenant.min.js` |
|
|
127
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.5.4/bsv-script-helper.min.js` |
|
|
128
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.5.4/bsv-message.min.js` |
|
|
129
129
|
|
|
130
130
|
## ⚙️ **Development Environment Setup**
|
|
131
131
|
|
|
@@ -14,10 +14,10 @@ npm install @smartledger/bsv
|
|
|
14
14
|
### Browser CDN (Instant)
|
|
15
15
|
```html
|
|
16
16
|
<!-- Core library (937KB) -->
|
|
17
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
17
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv.min.js"></script>
|
|
18
18
|
|
|
19
19
|
<!-- Everything included (937KB) -->
|
|
20
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
20
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv.bundle.js"></script>
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## 💰 **Your First Transaction (60 seconds)**
|
|
@@ -127,19 +127,19 @@ SmartLedger-BSV offers 12 different loading options - use only what you need:
|
|
|
127
127
|
|
|
128
128
|
```html
|
|
129
129
|
<!-- Core BSV only (937KB) -->
|
|
130
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
130
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv.min.js"></script>
|
|
131
131
|
|
|
132
132
|
<!-- Smart contracts (937KB) -->
|
|
133
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
133
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-smartcontract.min.js"></script>
|
|
134
134
|
|
|
135
135
|
<!-- Legal tokens (1.16MB) -->
|
|
136
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-ltp.min.js"></script>
|
|
137
137
|
|
|
138
138
|
<!-- Digital identity (1.16MB) -->
|
|
139
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
139
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-gdaf.min.js"></script>
|
|
140
140
|
|
|
141
141
|
<!-- Everything (937KB) -->
|
|
142
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
142
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv.bundle.js"></script>
|
|
143
143
|
```
|
|
144
144
|
|
|
145
145
|
## ⚡ **Key Advantages**
|
|
@@ -159,17 +159,17 @@ const recovered = bsv.reconstructSecret([shares[0], shares[2], shares[4]]);
|
|
|
159
159
|
### **New Modular Options**
|
|
160
160
|
```html
|
|
161
161
|
<!-- Core compatibility (same size as bsv@1.5.6) -->
|
|
162
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
162
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv.min.js"></script>
|
|
163
163
|
|
|
164
164
|
<!-- Add smart contracts when ready -->
|
|
165
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
165
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-smartcontract.min.js"></script>
|
|
166
166
|
|
|
167
167
|
<!-- Add advanced features as needed -->
|
|
168
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
169
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
168
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-ltp.min.js"></script>
|
|
169
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv-gdaf.min.js"></script>
|
|
170
170
|
|
|
171
171
|
<!-- Everything in one file -->
|
|
172
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.5.
|
|
172
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.5.4/bsv.bundle.js"></script>
|
|
173
173
|
```
|
|
174
174
|
|
|
175
175
|
## 🔍 **Testing Your Migration**
|
|
@@ -234,20 +234,127 @@ SmartLedgerAnchor.prototype.revokeCredential = async function(credentialId, reas
|
|
|
234
234
|
* broadcasting the secret. Checks the shape rather than the class, because a key that has
|
|
235
235
|
* already been through JSON is a plain object by then.
|
|
236
236
|
*/
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
// Field names that mean key material whatever they contain.
|
|
238
|
+
var SECRET_KEYS = ['bn', 'privateKey', 'privkey', 'privKey', 'wif', 'privateJwk', 'xpriv', 'xprv', 'mnemonic']
|
|
239
|
+
// Field names that are only suspicious when the VALUE also looks secret. `d` is the JWK
|
|
240
|
+
// private exponent but also the most common short field name there is (a date, a delta);
|
|
241
|
+
// `seed` is a BIP39 seed but also a campaign seed. Refusing these on the name alone
|
|
242
|
+
// rejected `{ d: '2026-01-01' }` and told the caller their date looked like a key.
|
|
243
|
+
var AMBIGUOUS_KEYS = ['d', 'seed', 'secret', 'key']
|
|
244
|
+
|
|
245
|
+
/** A WIF that actually decodes to a key — the checksum makes false positives negligible. */
|
|
246
|
+
function isWIF (str) {
|
|
247
|
+
if (typeof str !== 'string' || str.length < 50 || str.length > 53) return false
|
|
248
|
+
try {
|
|
249
|
+
bsv.PrivateKey.fromWIF(str)
|
|
250
|
+
return true
|
|
251
|
+
} catch (e) { return false }
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** An extended PRIVATE key (xprv/tprv). The public xpub is not secret and is allowed. */
|
|
255
|
+
function isXprv (str) {
|
|
256
|
+
if (typeof str !== 'string' || !/^(xprv|tprv)/.test(str)) return false
|
|
257
|
+
try {
|
|
258
|
+
bsv.HDPrivateKey.fromString(str)
|
|
259
|
+
return true
|
|
260
|
+
} catch (e) { return false }
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** A valid BIP39 phrase. Checked against the wordlist + checksum, not just word count. */
|
|
264
|
+
function isMnemonic (str) {
|
|
265
|
+
if (typeof str !== 'string') return false
|
|
266
|
+
var words = str.trim().split(/\s+/)
|
|
267
|
+
if ([12, 15, 18, 21, 24].indexOf(words.length) === -1) return false
|
|
268
|
+
try {
|
|
269
|
+
return bsv.Mnemonic.isValid(str.trim())
|
|
270
|
+
} catch (e) { return false }
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** 64 hex characters that are a valid secp256k1 scalar — i.e. usable as a private key. */
|
|
274
|
+
function isHexScalar (str) {
|
|
275
|
+
if (typeof str !== 'string' || !/^[0-9a-fA-F]{64}$/.test(str)) return false
|
|
276
|
+
try {
|
|
277
|
+
bsv.PrivateKey.fromHex(str)
|
|
278
|
+
return true
|
|
279
|
+
} catch (e) { return false }
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Self-identifying secrets: formats whose own encoding says "this is a private key".
|
|
284
|
+
* These are refused under ANY field name, because naming a WIF `note` does not make it
|
|
285
|
+
* safe to publish. A bare 64-hex scalar is deliberately NOT here — it is indistinguishable
|
|
286
|
+
* from a SHA-256 hash, and anchoring a document hash is the module's whole purpose.
|
|
287
|
+
*/
|
|
288
|
+
function isSelfIdentifyingSecret (str) {
|
|
289
|
+
return isWIF(str) || isXprv(str) || isMnemonic(str)
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Refuse to serialise anything that looks like key material.
|
|
294
|
+
*
|
|
295
|
+
* Defence in depth for the argument-order defect that put a private key in the `metadata`
|
|
296
|
+
* slot: even if a caller reaches this with a key, the anchor fails loudly instead of
|
|
297
|
+
* broadcasting the secret. Checks shape rather than class, because a key that has already
|
|
298
|
+
* been through JSON is a plain object by then.
|
|
299
|
+
*
|
|
300
|
+
* Three independent signals, because name alone was both too strict and too loose — it
|
|
301
|
+
* rejected `{ d: '2026-01-01' }` while happily publishing `{ note: '<a real WIF>' }`:
|
|
302
|
+
*
|
|
303
|
+
* 1. the value IS this anchor's own signing key, in any representation;
|
|
304
|
+
* 2. the value is a self-identifying secret (WIF / xprv / BIP39) under any name;
|
|
305
|
+
* 3. the field name means key material — always for `wif`/`bn`/`xprv`/…, and for
|
|
306
|
+
* ambiguous names like `d`/`seed` only when the value looks secret too.
|
|
307
|
+
*
|
|
308
|
+
* @param {object} metadata the object about to be published in the OP_RETURN
|
|
309
|
+
* @param {PrivateKey} [ownKey] this anchor's key, so leaking it is caught by value
|
|
310
|
+
*/
|
|
311
|
+
function assertNoKeyMaterial (metadata, ownKey) {
|
|
312
|
+
// Every representation of our own key. Addresses and public keys are omitted on
|
|
313
|
+
// purpose: they are public, and an anchor legitimately references them.
|
|
314
|
+
var ownForms = []
|
|
315
|
+
if (ownKey && typeof ownKey.toWIF === 'function') {
|
|
316
|
+
try {
|
|
317
|
+
ownForms = [ownKey.toWIF(), ownKey.toString(), ownKey.bn && ownKey.bn.toString(16)]
|
|
318
|
+
.filter(function (f) { return typeof f === 'string' && f.length })
|
|
319
|
+
.map(function (f) { return f.toLowerCase() })
|
|
320
|
+
} catch (e) { ownForms = [] }
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function refuse (path, why) {
|
|
324
|
+
throw new Error('Refusing to anchor: ' + (path || 'metadata') + ' ' + why +
|
|
325
|
+
', and anchor metadata is published in the OP_RETURN where it is permanent and public.')
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function checkString (str, path) {
|
|
329
|
+
if (ownForms.length && ownForms.indexOf(str.toLowerCase()) !== -1) {
|
|
330
|
+
refuse(path, "is this anchor's own private key")
|
|
331
|
+
}
|
|
332
|
+
if (isWIF(str)) refuse(path, 'is a WIF private key')
|
|
333
|
+
if (isXprv(str)) refuse(path, 'is an extended private key')
|
|
334
|
+
if (isMnemonic(str)) refuse(path, 'is a BIP39 mnemonic phrase')
|
|
335
|
+
}
|
|
336
|
+
|
|
239
337
|
function walk (value, path, depth) {
|
|
240
|
-
if (
|
|
338
|
+
if (typeof value === 'string') { checkString(value, path); return }
|
|
339
|
+
if (!value || typeof value !== 'object' || depth > 6) return
|
|
241
340
|
if (typeof value.toWIF === 'function' && value.bn) {
|
|
242
|
-
|
|
243
|
-
|
|
341
|
+
refuse(path, 'is a PrivateKey')
|
|
342
|
+
}
|
|
343
|
+
if (Array.isArray(value)) {
|
|
344
|
+
value.forEach(function (v, i) { walk(v, (path || 'metadata') + '[' + i + ']', depth + 1) })
|
|
345
|
+
return
|
|
244
346
|
}
|
|
245
347
|
Object.keys(value).forEach(function (k) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
348
|
+
var v = value[k]
|
|
349
|
+
var here = path ? path + '.' + k : k
|
|
350
|
+
if (v != null && typeof v !== 'object') {
|
|
351
|
+
var s = String(v)
|
|
352
|
+
if (SECRET_KEYS.indexOf(k) !== -1) refuse(here, 'is a field that holds key material')
|
|
353
|
+
if (AMBIGUOUS_KEYS.indexOf(k) !== -1 && (isSelfIdentifyingSecret(s) || isHexScalar(s))) {
|
|
354
|
+
refuse(here, 'holds something that decodes as a private key')
|
|
355
|
+
}
|
|
249
356
|
}
|
|
250
|
-
walk(
|
|
357
|
+
walk(v, here, depth + 1)
|
|
251
358
|
})
|
|
252
359
|
}
|
|
253
360
|
walk(metadata, '', 0)
|
|
@@ -256,8 +363,10 @@ function assertNoKeyMaterial (metadata) {
|
|
|
256
363
|
SmartLedgerAnchor.prototype._createAnchorPayload = function(type, hash, metadata) {
|
|
257
364
|
var timestamp = Math.floor(Date.now() / 1000) // Unix timestamp
|
|
258
365
|
|
|
259
|
-
// This payload goes on chain, permanently and publicly.
|
|
260
|
-
|
|
366
|
+
// This payload goes on chain, permanently and publicly. Pass our own key so that
|
|
367
|
+
// leaking *it* — the exact defect this guard exists for — is caught by value and not
|
|
368
|
+
// only by field name.
|
|
369
|
+
assertNoKeyMaterial(metadata, this.privateKey)
|
|
261
370
|
|
|
262
371
|
// Create structured payload
|
|
263
372
|
var payload = Buffer.concat([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartledger/bsv",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.4",
|
|
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",
|
|
@@ -215,15 +215,15 @@
|
|
|
215
215
|
"bs58": "=4.0.1",
|
|
216
216
|
"clone-deep": "^4.0.1",
|
|
217
217
|
"hash.js": "^1.1.7",
|
|
218
|
-
"inherits": "2.0.
|
|
218
|
+
"inherits": "2.0.4",
|
|
219
219
|
"secrets.js-grempe": "^2.0.0",
|
|
220
|
-
"unorm": "1.
|
|
220
|
+
"unorm": "1.6.0"
|
|
221
221
|
},
|
|
222
222
|
"devDependencies": {
|
|
223
223
|
"assert": "^2.1.0",
|
|
224
224
|
"browserify-zlib": "^0.2.0",
|
|
225
225
|
"buffer": "^6.0.3",
|
|
226
|
-
"chai": "
|
|
226
|
+
"chai": "6.2.2",
|
|
227
227
|
"crypto-browserify": "^3.12.1",
|
|
228
228
|
"esbuild": "^0.28.1",
|
|
229
229
|
"events": "^3.3.0",
|
|
@@ -77,7 +77,7 @@ describe('GDAF anchoring never publishes key material', function () {
|
|
|
77
77
|
it('refuses to anchor metadata carrying a key-shaped field', function () {
|
|
78
78
|
return gdaf().anchorCredential(HASH, key, { utxos: utxos, metadata: { wif: key.toWIF() } })
|
|
79
79
|
.then(function () { throw new Error('should not have anchored') },
|
|
80
|
-
function (err) { err.message.should.match(/
|
|
80
|
+
function (err) { err.message.should.match(/key material/) })
|
|
81
81
|
})
|
|
82
82
|
|
|
83
83
|
it('leaves ordinary metadata alone', function () {
|
|
@@ -85,4 +85,62 @@ describe('GDAF anchoring never publishes key material', function () {
|
|
|
85
85
|
utxos: utxos, metadata: { id: 'urn:uuid:1', nested: { note: 'fine' } }
|
|
86
86
|
}).then(function (r) { assertNoSecret(r) })
|
|
87
87
|
})
|
|
88
|
+
// The guard keyed off field NAMES alone, which was wrong in both directions: it
|
|
89
|
+
// rejected `{ d: '2026-01-01' }` as key material while publishing a real WIF stored
|
|
90
|
+
// under `note`. Detection is now by value as well as name.
|
|
91
|
+
describe('detects key material by value, not just by field name', function () {
|
|
92
|
+
var Anchor = require('../../lib/gdaf/smartledger-anchor.js')
|
|
93
|
+
var other = bsv.PrivateKey.fromBuffer(Buffer.alloc(32, 99))
|
|
94
|
+
var HASH_BUF = bsv.crypto.Hash.sha256(Buffer.from('doc'))
|
|
95
|
+
|
|
96
|
+
function build (metadata) {
|
|
97
|
+
return new Anchor(key, {})._createAnchorPayload('CREDENTIAL', HASH_BUF, metadata)
|
|
98
|
+
}
|
|
99
|
+
function refuses (label, metadata) {
|
|
100
|
+
it('refuses ' + label, function () {
|
|
101
|
+
;(function () { build(metadata) }).should.throw(/Refusing to anchor/)
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
function accepts (label, metadata) {
|
|
105
|
+
it('accepts ' + label, function () {
|
|
106
|
+
var payload = Buffer.from(build(metadata)).toString('utf8')
|
|
107
|
+
payload.indexOf(key.toWIF()).should.equal(-1)
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Self-identifying secrets: the encoding says "private key" whatever the field is
|
|
112
|
+
// called. Naming a WIF `note` does not make it safe to publish.
|
|
113
|
+
refuses('a WIF under an innocuous name', { note: other.toWIF() })
|
|
114
|
+
refuses('an xprv under an innocuous name', {
|
|
115
|
+
ref: bsv.HDPrivateKey.fromSeed(Buffer.alloc(32, 1)).toString()
|
|
116
|
+
})
|
|
117
|
+
refuses('a BIP39 mnemonic under an innocuous name', {
|
|
118
|
+
memo: 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
|
|
119
|
+
})
|
|
120
|
+
refuses('a secret nested in an array', { signers: [other.toWIF()] })
|
|
121
|
+
|
|
122
|
+
// The anchor's OWN key, in any representation — the exact defect this guard exists
|
|
123
|
+
// for. A bare hex scalar is otherwise indistinguishable from a hash, so knowing our
|
|
124
|
+
// own key is what makes this catchable.
|
|
125
|
+
refuses("the anchor's own key as a raw hex scalar", { backup: key.toString() })
|
|
126
|
+
refuses("the anchor's own key as a WIF", { backup: key.toWIF() })
|
|
127
|
+
|
|
128
|
+
// Ambiguous names are refused only when the value really is secret.
|
|
129
|
+
refuses('d holding a private scalar', { d: other.toString() })
|
|
130
|
+
refuses('seed holding a mnemonic', {
|
|
131
|
+
seed: 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
// ...and left alone otherwise. Anchoring a document hash is the module's purpose,
|
|
135
|
+
// and a 64-hex hash cannot be told apart from a scalar, so it must not be rejected.
|
|
136
|
+
accepts('d as a date', { d: '2026-01-01' })
|
|
137
|
+
accepts('seed as a campaign name', { seed: 'spring-campaign' })
|
|
138
|
+
accepts('a SHA-256 document hash', { docHash: bsv.crypto.Hash.sha256(Buffer.from('x')).toString('hex') })
|
|
139
|
+
accepts('key used as an ordinary label', { key: 'value' })
|
|
140
|
+
|
|
141
|
+
// Public material is not secret and an anchor legitimately references it.
|
|
142
|
+
accepts('an address', { payTo: key.toAddress().toString() })
|
|
143
|
+
accepts('a public key', { pub: key.toPublicKey().toString() })
|
|
144
|
+
accepts('an xpub', { xpub: bsv.HDPrivateKey.fromSeed(Buffer.alloc(32, 1)).hdPublicKey.toString() })
|
|
145
|
+
})
|
|
88
146
|
})
|
package/version.js
CHANGED