@smartledger/bsv 7.5.1 → 7.5.3

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.
@@ -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.1/bsv-shamir.min.js`
58
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.5.3/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.1/bsv-gdaf.min.js`
64
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.5.3/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.1/bsv-ltp.min.js`
70
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.5.3/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.1/bsv.min.js` |
85
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.5.1/bsv.bundle.js` |
86
- | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.5.1/bsv-smartcontract.min.js` |
87
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.5.1/bsv-covenant.min.js` |
88
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.5.1/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.1/bsv-security.min.js` |
90
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.5.1/bsv-ecies.min.js` |
91
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.5.1/bsv-message.min.js` |
92
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.5.1/bsv-mnemonic.min.js` |
93
- | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.5.1/bsv-shamir.min.js` |
94
- | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.5.1/bsv-gdaf.min.js` |
95
- | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.5.1/bsv-ltp.min.js` |
84
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.5.3/bsv.min.js` |
85
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.5.3/bsv.bundle.js` |
86
+ | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.5.3/bsv-smartcontract.min.js` |
87
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.5.3/bsv-covenant.min.js` |
88
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.5.3/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.3/bsv-security.min.js` |
90
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.5.3/bsv-ecies.min.js` |
91
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.5.3/bsv-message.min.js` |
92
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.5.3/bsv-mnemonic.min.js` |
93
+ | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.5.3/bsv-shamir.min.js` |
94
+ | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.5.3/bsv-gdaf.min.js` |
95
+ | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.5.3/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.1/bsv.min.js"></script>
104
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-script-helper.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv.min.js"></script>
104
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/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.1/bsv.min.js"></script>
110
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-covenant.min.js"></script>
111
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-smartcontract.min.js"></script>
109
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv.min.js"></script>
110
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv-covenant.min.js"></script>
111
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/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.1/bsv.min.js"></script>
117
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-ltp.min.js"></script>
118
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-gdaf.min.js"></script>
116
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv.min.js"></script>
117
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv-ltp.min.js"></script>
118
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/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.1/bsv.min.js"></script>
136
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-security.min.js"></script>
137
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-shamir.min.js"></script>
135
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv-security.min.js"></script>
137
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/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.1/bsv.bundle.js"></script>
149
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/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.1/bsv.min.js"></script>
725
+ <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@7.5.3/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.1/bsv.min.js"></script>
51
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/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.1/bsv.bundle.js"></script>
61
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/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.1/bsv.min.js"></script>
75
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-covenant.min.js"></script>
76
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-smartcontract.min.js"></script>
74
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv.min.js"></script>
75
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv-covenant.min.js"></script>
76
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/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.1/bsv.min.js"></script>
86
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-ltp.min.js"></script>
87
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-gdaf.min.js"></script>
85
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv.min.js"></script>
86
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv-ltp.min.js"></script>
87
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/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.1/bsv.min.js"></script>
102
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-security.min.js"></script>
103
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-shamir.min.js"></script>
101
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv.min.js"></script>
102
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv-security.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/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.1/bsv.min.js` |
118
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.5.1/bsv.bundle.js` |
119
- | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.5.1/bsv-smartcontract.min.js` |
120
- | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.5.1/bsv-ltp.min.js` |
121
- | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.5.1/bsv-gdaf.min.js` |
122
- | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.5.1/bsv-shamir.min.js` |
123
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.5.1/bsv-security.min.js` |
124
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.5.1/bsv-mnemonic.min.js` |
125
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.5.1/bsv-ecies.min.js` |
126
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.5.1/bsv-covenant.min.js` |
127
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.5.1/bsv-script-helper.min.js` |
128
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.5.1/bsv-message.min.js` |
117
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.5.3/bsv.min.js` |
118
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.5.3/bsv.bundle.js` |
119
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.5.3/bsv-smartcontract.min.js` |
120
+ | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.5.3/bsv-ltp.min.js` |
121
+ | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.5.3/bsv-gdaf.min.js` |
122
+ | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.5.3/bsv-shamir.min.js` |
123
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.5.3/bsv-security.min.js` |
124
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.5.3/bsv-mnemonic.min.js` |
125
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.5.3/bsv-ecies.min.js` |
126
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.5.3/bsv-covenant.min.js` |
127
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.5.3/bsv-script-helper.min.js` |
128
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.5.3/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.1/bsv.min.js"></script>
17
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv.min.js"></script>
18
18
 
19
19
  <!-- Everything included (937KB) -->
20
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv.bundle.js"></script>
20
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/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.1/bsv.min.js"></script>
130
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv.min.js"></script>
131
131
 
132
132
  <!-- Smart contracts (937KB) -->
133
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-smartcontract.min.js"></script>
133
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv-smartcontract.min.js"></script>
134
134
 
135
135
  <!-- Legal tokens (1.16MB) -->
136
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-ltp.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv-ltp.min.js"></script>
137
137
 
138
138
  <!-- Digital identity (1.16MB) -->
139
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-gdaf.min.js"></script>
139
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv-gdaf.min.js"></script>
140
140
 
141
141
  <!-- Everything (937KB) -->
142
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv.bundle.js"></script>
142
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/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.1/bsv.min.js"></script>
162
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv.min.js"></script>
163
163
 
164
164
  <!-- Add smart contracts when ready -->
165
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-smartcontract.min.js"></script>
165
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv-smartcontract.min.js"></script>
166
166
 
167
167
  <!-- Add advanced features as needed -->
168
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-ltp.min.js"></script>
169
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-gdaf.min.js"></script>
168
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv-ltp.min.js"></script>
169
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv-gdaf.min.js"></script>
170
170
 
171
171
  <!-- Everything in one file -->
172
- <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv.bundle.js"></script>
172
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.3/bsv.bundle.js"></script>
173
173
  ```
174
174
 
175
175
  ## 🔍 **Testing Your Migration**
package/index.js CHANGED
@@ -57,7 +57,10 @@ bsv.securityFeatures = [
57
57
  'canonical-signatures',
58
58
  'malleability-protection',
59
59
  'enhanced-validation',
60
- 'elliptic-patches'
60
+ // 'elliptic-patches' was listed here long after `elliptic` stopped being a dependency.
61
+ // This array is what a compliance reviewer reads, so it states what is actually true.
62
+ 'audited-noble-curves',
63
+ 'fail-closed-verification'
61
64
  ]
62
65
 
63
66
  // crypto
@@ -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
- function assertNoKeyMaterial (metadata) {
238
- var SECRET_KEYS = ['bn', 'privateKey', 'privkey', 'wif', 'privateJwk', 'd', 'seed', 'xpriv', 'xprv']
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 (!value || typeof value !== 'object' || depth > 4) return
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
- throw new Error('Refusing to anchor: ' + (path || 'metadata') + ' is a PrivateKey. ' +
243
- 'Anchor metadata is published in the OP_RETURN and must never contain key material.')
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
- if (SECRET_KEYS.indexOf(k) !== -1 && value[k] != null && typeof value[k] !== 'object') {
247
- throw new Error('Refusing to anchor: ' + (path ? path + '.' : '') + k +
248
- ' looks like key material, and anchor metadata is published in the OP_RETURN.')
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(value[k], path ? path + '.' + k : k, depth + 1)
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
- assertNoKeyMaterial(metadata)
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([
@@ -78,6 +78,14 @@ function redeemScript (m, pubkeys) {
78
78
  }
79
79
 
80
80
  function multisig (m, nKeys) {
81
+ // `nKeys` is a COUNT, not the keys. Passing an array made `m > nKeys` compare a number
82
+ // to an array, which coerces to NaN, so the guard passed and an authorizer was built
83
+ // with the array spliced into its name — broken, but silently.
84
+ if (typeof nKeys !== 'number' || !Number.isInteger(nKeys)) {
85
+ throw new Error('multisig(m, nKeys): nKeys is the NUMBER of keys, not the keys themselves' +
86
+ (Array.isArray(nKeys) ? ' — pass ' + nKeys.length + ' instead of the array' : ''))
87
+ }
88
+ if (typeof m !== 'number' || !Number.isInteger(m)) throw new Error('multisig(m, nKeys): m must be an integer')
81
89
  if (m < 1 || m > nKeys || nKeys < 1 || nKeys > 16) throw new Error('multisig requires 1 <= m <= n <= 16')
82
90
  return {
83
91
  name: m + '-of-' + nKeys + '-multisig',
@@ -80,8 +80,10 @@ SmartContract.perpetualCovenant = function (fee) {
80
80
  }
81
81
  // Stateful ownership token (NFT) locking script. ownerPubKeyHash = HASH160 of the
82
82
  // owner's public key (SmartContract.Token.ownerId); transfers are ECDSA-authorized.
83
- SmartContract.ownershipToken = function (fee, ownerPubKeyHash) {
84
- return SmartContract.Token.ownershipToken(fee, ownerPubKeyHash)
83
+ // `auth` was NOT forwarded here, so a co-signed token built through this alias silently
84
+ // came out single-key — the authorizer was accepted and dropped.
85
+ SmartContract.ownershipToken = function (fee, ownerPubKeyHash, auth) {
86
+ return SmartContract.Token.ownershipToken(fee, ownerPubKeyHash, auth)
85
87
  }
86
88
  // OP_PUSH_TX value/output covenant: coins can only go where the covenant says.
87
89
  SmartContract.valueCovenant = function (expectedHashOutputs) {
@@ -115,6 +115,11 @@ async function updateStatusList(params) {
115
115
  if (!params.listVcJwt || params.index === undefined || !params.status || !params.privateJwk) {
116
116
  throw new Error('listVcJwt, index, status, and privateJwk are required')
117
117
  }
118
+ if (params.status === 'suspended') {
119
+ throw new Error("status 'suspended' is not supported by this list: its statusPurpose " +
120
+ "is 'revocation', and suspension would be written to the same bit and read back as " +
121
+ "'revoked'. Maintain a separate list for suspension until statusPurpose is configurable.")
122
+ }
118
123
 
119
124
  // Verify the existing list's signature+issuer before building on top of it —
120
125
  // an unverified base list lets an attacker seed forged revocation state.
@@ -132,9 +137,12 @@ async function updateStatusList(params) {
132
137
  throw new Error('Index out of range')
133
138
  }
134
139
 
135
- // StatusList2021 uses 2 bits per credential for 4 states
136
- // For simplicity, we'll use single bit: 0=valid, 1=revoked/suspended
137
- var statusBit = (params.status === 'revoked' || params.status === 'suspended') ? 1 : 0
140
+ // StatusList2021 uses 2 bits per credential for 4 states; this implementation uses a
141
+ // single bit (0 = valid, 1 = revoked) and hardcodes statusPurpose: 'revocation'.
142
+ // 'suspended' therefore has nowhere to go: it used to set the SAME bit as 'revoked' and
143
+ // read back as 'revoked', so a suspension was silently recorded — and reported — as a
144
+ // permanent revocation. Fail closed rather than lie about which state was written.
145
+ var statusBit = params.status === 'revoked' ? 1 : 0
138
146
 
139
147
  if (statusBit === 1) {
140
148
  bitstring[byteIndex] |= (1 << bitIndex)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartledger/bsv",
3
- "version": "7.5.1",
3
+ "version": "7.5.3",
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",
@@ -18,6 +18,17 @@
18
18
  },
19
19
  "./package.json": "./package.json",
20
20
  "./version": "./version.js",
21
+ "./anchor": "./anchor-entry.js",
22
+ "./covenant": "./covenant-entry.js",
23
+ "./didweb": "./didweb-entry.js",
24
+ "./gdaf": "./gdaf-entry.js",
25
+ "./ltp": "./ltp-entry.js",
26
+ "./script-helper": "./script-helper-entry.js",
27
+ "./security": "./security-entry.js",
28
+ "./shamir": "./shamir-entry.js",
29
+ "./smartcontract": "./smartcontract-entry.js",
30
+ "./statuslist": "./statuslist-entry.js",
31
+ "./vcjwt": "./vcjwt-entry.js",
21
32
  "./lib/*.js": "./lib/*.js",
22
33
  "./lib/*": "./lib/*.js",
23
34
  "./*": "./*"
@@ -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(/looks like key material/) })
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
  })
@@ -45,7 +45,9 @@ function collectDeclaredPaths (source) {
45
45
  } else if (ts.isClassDeclaration(node) && node.name) {
46
46
  paths.push(prefix.concat(node.name.text))
47
47
  } else if (ts.isFunctionDeclaration(node) && node.name) {
48
- paths.push(prefix.concat(node.name.text))
48
+ var p = prefix.concat(node.name.text)
49
+ p.returnType = node.type ? node.type.getText() : null
50
+ paths.push(p)
49
51
  } else if (ts.isVariableStatement(node)) {
50
52
  node.declarationList.declarations.forEach(function (d) {
51
53
  if (ts.isIdentifier(d.name)) paths.push(prefix.concat(d.name.text))
@@ -89,6 +91,26 @@ describe('types: bsv.d.ts does not drift from runtime', function () {
89
91
  { label: 'SPV', obj: bsv.SPV, decl: 'SPV' }
90
92
  ]
91
93
 
94
+ // An `async` runtime function declared with a non-Promise return type is the most
95
+ // dangerous kind of drift, because the type checker actively hides the bug rather than
96
+ // merely failing to catch it: `StatusList.getCredentialStatusEntry` was declared
97
+ // `: CredentialStatus` while being async, so `if (fn(...) === 'revoked')` compiled clean
98
+ // and was ALWAYS false — every revoked credential passed as valid.
99
+ it('no async runtime function is declared with a synchronous return type', function () {
100
+ var lies = []
101
+ declaredPaths.forEach(function (segs) {
102
+ if (!segs.returnType) return
103
+ var fn = resolve(bsv, segs)
104
+ if (typeof fn !== 'function') return
105
+ var isAsync = fn.constructor && fn.constructor.name === 'AsyncFunction'
106
+ var declaresPromise = /\bPromise\s*</.test(segs.returnType)
107
+ if (isAsync && !declaresPromise) {
108
+ lies.push(segs.join('.') + ' is async but is declared `: ' + segs.returnType + '`')
109
+ }
110
+ })
111
+ lies.should.deep.equal([], 'these declarations hide a Promise:\n ' + lies.join('\n '))
112
+ })
113
+
92
114
  AUDITED.forEach(function (ns) {
93
115
  it('every runtime function on ' + ns.label + ' is declared in bsv.d.ts', function () {
94
116
  ns.obj.should.be.an('object')