@smartledger/bsv 7.5.0 → 7.5.2

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.0/bsv-shamir.min.js`
58
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.5.2/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.0/bsv-gdaf.min.js`
64
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.5.2/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.0/bsv-ltp.min.js`
70
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.5.2/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.0/bsv.min.js` |
85
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.5.0/bsv.bundle.js` |
86
- | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.5.0/bsv-smartcontract.min.js` |
87
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.5.0/bsv-covenant.min.js` |
88
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.5.0/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.0/bsv-security.min.js` |
90
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.5.0/bsv-ecies.min.js` |
91
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.5.0/bsv-message.min.js` |
92
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.5.0/bsv-mnemonic.min.js` |
93
- | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.5.0/bsv-shamir.min.js` |
94
- | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.5.0/bsv-gdaf.min.js` |
95
- | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.5.0/bsv-ltp.min.js` |
84
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.5.2/bsv.min.js` |
85
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.5.2/bsv.bundle.js` |
86
+ | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.5.2/bsv-smartcontract.min.js` |
87
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.5.2/bsv-covenant.min.js` |
88
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.5.2/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.2/bsv-security.min.js` |
90
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.5.2/bsv-ecies.min.js` |
91
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.5.2/bsv-message.min.js` |
92
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.5.2/bsv-mnemonic.min.js` |
93
+ | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.5.2/bsv-shamir.min.js` |
94
+ | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.5.2/bsv-gdaf.min.js` |
95
+ | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.5.2/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.0/bsv.min.js"></script>
104
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-script-helper.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv.min.js"></script>
104
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/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.0/bsv.min.js"></script>
110
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-covenant.min.js"></script>
111
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-smartcontract.min.js"></script>
109
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv.min.js"></script>
110
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv-covenant.min.js"></script>
111
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/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.0/bsv.min.js"></script>
117
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-ltp.min.js"></script>
118
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-gdaf.min.js"></script>
116
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv.min.js"></script>
117
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv-ltp.min.js"></script>
118
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/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.0/bsv.min.js"></script>
136
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-security.min.js"></script>
137
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-shamir.min.js"></script>
135
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv-security.min.js"></script>
137
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/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.0/bsv.bundle.js"></script>
149
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/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.0/bsv.min.js"></script>
725
+ <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@7.5.2/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.0/bsv.min.js"></script>
51
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/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.0/bsv.bundle.js"></script>
61
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/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.0/bsv.min.js"></script>
75
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-covenant.min.js"></script>
76
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-smartcontract.min.js"></script>
74
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv.min.js"></script>
75
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv-covenant.min.js"></script>
76
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/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.0/bsv.min.js"></script>
86
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-ltp.min.js"></script>
87
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-gdaf.min.js"></script>
85
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv.min.js"></script>
86
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv-ltp.min.js"></script>
87
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/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.0/bsv.min.js"></script>
102
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-security.min.js"></script>
103
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-shamir.min.js"></script>
101
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv.min.js"></script>
102
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv-security.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/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.0/bsv.min.js` |
118
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.5.0/bsv.bundle.js` |
119
- | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.5.0/bsv-smartcontract.min.js` |
120
- | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.5.0/bsv-ltp.min.js` |
121
- | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.5.0/bsv-gdaf.min.js` |
122
- | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.5.0/bsv-shamir.min.js` |
123
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.5.0/bsv-security.min.js` |
124
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.5.0/bsv-mnemonic.min.js` |
125
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.5.0/bsv-ecies.min.js` |
126
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.5.0/bsv-covenant.min.js` |
127
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.5.0/bsv-script-helper.min.js` |
128
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.5.0/bsv-message.min.js` |
117
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.5.2/bsv.min.js` |
118
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.5.2/bsv.bundle.js` |
119
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.5.2/bsv-smartcontract.min.js` |
120
+ | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.5.2/bsv-ltp.min.js` |
121
+ | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.5.2/bsv-gdaf.min.js` |
122
+ | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.5.2/bsv-shamir.min.js` |
123
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.5.2/bsv-security.min.js` |
124
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.5.2/bsv-mnemonic.min.js` |
125
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.5.2/bsv-ecies.min.js` |
126
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.5.2/bsv-covenant.min.js` |
127
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.5.2/bsv-script-helper.min.js` |
128
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.5.2/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.0/bsv.min.js"></script>
17
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv.min.js"></script>
18
18
 
19
19
  <!-- Everything included (937KB) -->
20
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv.bundle.js"></script>
20
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/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.0/bsv.min.js"></script>
130
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv.min.js"></script>
131
131
 
132
132
  <!-- Smart contracts (937KB) -->
133
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-smartcontract.min.js"></script>
133
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv-smartcontract.min.js"></script>
134
134
 
135
135
  <!-- Legal tokens (1.16MB) -->
136
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-ltp.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv-ltp.min.js"></script>
137
137
 
138
138
  <!-- Digital identity (1.16MB) -->
139
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-gdaf.min.js"></script>
139
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv-gdaf.min.js"></script>
140
140
 
141
141
  <!-- Everything (937KB) -->
142
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv.bundle.js"></script>
142
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/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.0/bsv.min.js"></script>
162
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv.min.js"></script>
163
163
 
164
164
  <!-- Add smart contracts when ready -->
165
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-smartcontract.min.js"></script>
165
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv-smartcontract.min.js"></script>
166
166
 
167
167
  <!-- Add advanced features as needed -->
168
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-ltp.min.js"></script>
169
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv-gdaf.min.js"></script>
168
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv-ltp.min.js"></script>
169
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/bsv-gdaf.min.js"></script>
170
170
 
171
171
  <!-- Everything in one file -->
172
- <script src="https://unpkg.com/@smartledger/bsv@7.5.0/bsv.bundle.js"></script>
172
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.2/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
package/lib/gdaf/index.js CHANGED
@@ -294,6 +294,24 @@ GDAF.prototype.verifyMembershipProof = function(proof, validSet) {
294
294
  * Blockchain Anchoring Methods
295
295
  */
296
296
 
297
+ /**
298
+ * Normalise the `options` argument of the anchoring wrappers to `{ metadata, utxos }`.
299
+ *
300
+ * These wrappers take (payload, privateKey, options) while the underlying anchor methods
301
+ * take (payload, metadata, utxos) — so every one of them forwarded `privateKey` into a
302
+ * slot that is not a key. For registerDID/revokeCredential that landed in `utxos` and died
303
+ * on `utxos.reduce`; for anchorCredential/anchorBatch it landed in `metadata`, which is
304
+ * JSON.stringify-ed straight into the OP_RETURN, publishing the secret scalar on chain.
305
+ *
306
+ * A bare array is still accepted as the UTXO list, because that was the only shape that
307
+ * previously produced a transaction at all.
308
+ */
309
+ function _anchorOpts (options) {
310
+ if (Array.isArray(options)) return { metadata: undefined, utxos: options }
311
+ options = options || {}
312
+ return { metadata: options.metadata, utxos: options.utxos }
313
+ }
314
+
297
315
  /**
298
316
  * Anchor credential to blockchain
299
317
  * @param {Object} credential - Credential to anchor
@@ -301,9 +319,13 @@ GDAF.prototype.verifyMembershipProof = function(proof, validSet) {
301
319
  * @param {Object} options - Anchoring options
302
320
  * @returns {Object} Anchor result
303
321
  */
304
- GDAF.prototype.anchorCredential = function(credential, privateKey, options) {
322
+ GDAF.prototype.anchorCredential = function(credentialHash, privateKey, options) {
305
323
  var anchor = new SmartLedgerAnchor(privateKey, this._anchorOptions)
306
- return anchor.anchorCredential(credential, privateKey, options)
324
+ var opts = _anchorOpts(options)
325
+ // `privateKey` is NOT forwarded: the anchor already holds it, and its second parameter
326
+ // is `metadata`, which is JSON-serialised into the OP_RETURN. Passing the key here
327
+ // published it on chain. See the note above _anchorOpts.
328
+ return anchor.anchorCredential(credentialHash, opts.metadata, opts.utxos)
307
329
  }
308
330
 
309
331
  /**
@@ -313,9 +335,10 @@ GDAF.prototype.anchorCredential = function(credential, privateKey, options) {
313
335
  * @param {Object} options - Anchoring options
314
336
  * @returns {Object} Batch anchor result
315
337
  */
316
- GDAF.prototype.anchorBatch = function(credentials, privateKey, options) {
338
+ GDAF.prototype.anchorBatch = function(credentialHashes, privateKey, options) {
317
339
  var anchor = new SmartLedgerAnchor(privateKey, this._anchorOptions)
318
- return anchor.anchorBatch(credentials, privateKey, options)
340
+ var opts = _anchorOpts(options)
341
+ return anchor.anchorBatch(credentialHashes, opts.metadata, opts.utxos)
319
342
  }
320
343
 
321
344
  /**
@@ -328,7 +351,7 @@ GDAF.prototype.anchorBatch = function(credentials, privateKey, options) {
328
351
  */
329
352
  GDAF.prototype.registerDID = function(did, didDocument, privateKey, options) {
330
353
  var anchor = new SmartLedgerAnchor(privateKey, this._anchorOptions)
331
- return anchor.registerDID(did, didDocument, privateKey, options)
354
+ return anchor.registerDID(did, didDocument, _anchorOpts(options).utxos)
332
355
  }
333
356
 
334
357
  /**
@@ -341,7 +364,7 @@ GDAF.prototype.registerDID = function(did, didDocument, privateKey, options) {
341
364
  */
342
365
  GDAF.prototype.revokeCredential = function(credentialId, reason, privateKey, options) {
343
366
  var anchor = new SmartLedgerAnchor(privateKey, this._anchorOptions)
344
- return anchor.revokeCredential(credentialId, reason, privateKey, options)
367
+ return anchor.revokeCredential(credentialId, reason, _anchorOpts(options).utxos)
345
368
  }
346
369
 
347
370
  /**
@@ -226,9 +226,39 @@ SmartLedgerAnchor.prototype.revokeCredential = async function(credentialId, reas
226
226
  * Create anchor payload
227
227
  * @private
228
228
  */
229
+ /**
230
+ * Refuse to serialise anything that looks like key material.
231
+ *
232
+ * Defence in depth for the argument-order defect that put a private key in the `metadata`
233
+ * slot: even if a caller reaches this with a key, the anchor fails loudly instead of
234
+ * broadcasting the secret. Checks the shape rather than the class, because a key that has
235
+ * already been through JSON is a plain object by then.
236
+ */
237
+ function assertNoKeyMaterial (metadata) {
238
+ var SECRET_KEYS = ['bn', 'privateKey', 'privkey', 'wif', 'privateJwk', 'd', 'seed', 'xpriv', 'xprv']
239
+ function walk (value, path, depth) {
240
+ if (!value || typeof value !== 'object' || depth > 4) return
241
+ 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.')
244
+ }
245
+ 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.')
249
+ }
250
+ walk(value[k], path ? path + '.' + k : k, depth + 1)
251
+ })
252
+ }
253
+ walk(metadata, '', 0)
254
+ }
255
+
229
256
  SmartLedgerAnchor.prototype._createAnchorPayload = function(type, hash, metadata) {
230
257
  var timestamp = Math.floor(Date.now() / 1000) // Unix timestamp
231
-
258
+
259
+ // This payload goes on chain, permanently and publicly.
260
+ assertNoKeyMaterial(metadata)
261
+
232
262
  // Create structured payload
233
263
  var payload = Buffer.concat([
234
264
  Buffer.from(this.PROTOCOL_ID, 'utf8'), // Protocol identifier
package/lib/privatekey.js CHANGED
@@ -156,11 +156,18 @@ PrivateKey._transformBuffer = function (buf, network) {
156
156
  * @returns {object} an Object with keys: bn, network, and compressed
157
157
  * @private
158
158
  */
159
- PrivateKey._transformBNBuffer = function (buf, network) {
159
+ PrivateKey._transformBNBuffer = function (buf, network, compressed) {
160
160
  var info = {}
161
161
  info.network = Networks.get(network) || Networks.defaultNetwork
162
162
  info.bn = BN.fromBuffer(buf)
163
- info.compressed = false
163
+ // A raw 32-byte scalar carries no compression information, so this is a choice, not a
164
+ // reading. It used to be `false` while every other constructor path — random keys, hex
165
+ // strings, compressed WIF — produced `true`, so `PrivateKey.fromHex(h)` and
166
+ // `new PrivateKey(h)` returned different addresses and different WIFs for identical
167
+ // input. Restore a key by the wrong route and you derive an address you never funded.
168
+ // The default now matches the rest of the library; pass `false` explicitly for the
169
+ // legacy uncompressed form.
170
+ info.compressed = compressed === undefined ? true : !!compressed
164
171
  return info
165
172
  }
166
173
 
@@ -182,12 +189,21 @@ PrivateKey._transformWIF = function (str, network) {
182
189
  * @param {Network} network
183
190
  * @return {PrivateKey}
184
191
  */
185
- PrivateKey.fromBuffer = function (buf, network) {
192
+ PrivateKey.fromBuffer = function (buf, network, compressed) {
193
+ if (compressed !== undefined && buf && buf.length === 32) {
194
+ return new PrivateKey(PrivateKey._transformBNBuffer(buf, network, compressed))
195
+ }
186
196
  return new PrivateKey(buf, network)
187
197
  }
188
198
 
189
- PrivateKey.fromHex = function (hex, network) {
190
- return PrivateKey.fromBuffer(Buffer.from(hex, 'hex'), network)
199
+ /**
200
+ * @param {string} hex - 32-byte private key scalar, hex encoded
201
+ * @param {Network|string=} network
202
+ * @param {boolean=} compressed - defaults to true, matching every other constructor path
203
+ * @return {PrivateKey}
204
+ */
205
+ PrivateKey.fromHex = function (hex, network, compressed) {
206
+ return PrivateKey.fromBuffer(Buffer.from(hex, 'hex'), network, compressed)
191
207
  }
192
208
 
193
209
  /**
@@ -209,14 +225,21 @@ PrivateKey._transformObject = function (json) {
209
225
  }
210
226
 
211
227
  /**
212
- * Instantiate a PrivateKey from a WIF string
228
+ * Instantiate a PrivateKey from a WIF string, or from a hex-encoded scalar.
229
+ *
230
+ * The `network` argument used to be accepted and silently discarded, so
231
+ * `fromString(hex, 'testnet')` returned a livenet key and therefore a MAINNET address —
232
+ * funds sent there land on the wrong network. It is now honoured. For a WIF, which
233
+ * already encodes its own network, a conflicting `network` throws rather than being
234
+ * quietly overridden.
213
235
  *
214
- * @param {string} str - The WIF encoded private key string
236
+ * @param {string} str - WIF-encoded private key, or a hex-encoded scalar
237
+ * @param {Network|string=} network
215
238
  * @returns {PrivateKey} A new valid instance of PrivateKey
216
239
  */
217
- PrivateKey.fromString = PrivateKey.fromWIF = function (str) {
240
+ PrivateKey.fromString = PrivateKey.fromWIF = function (str, network) {
218
241
  $.checkArgument(_.isString(str), 'First argument is expected to be a string.')
219
- return new PrivateKey(str)
242
+ return new PrivateKey(str, network)
220
243
  }
221
244
 
222
245
  /**
@@ -350,9 +373,14 @@ PrivateKey.prototype.toAddress = function (network) {
350
373
  }
351
374
 
352
375
  /**
376
+ * A plain object representation, including the secret scalar.
377
+ *
378
+ * This is the deliberate, explicit export — the round-trip partner of
379
+ * `PrivateKey.fromObject()`. It is NOT what `JSON.stringify()` calls; see `toJSON`.
380
+ *
353
381
  * @returns {Object} A plain object representation
354
382
  */
355
- PrivateKey.prototype.toObject = PrivateKey.prototype.toJSON = function toObject () {
383
+ PrivateKey.prototype.toObject = function toObject () {
356
384
  return {
357
385
  bn: this.bn.toString('hex'),
358
386
  compressed: this.compressed,
@@ -360,6 +388,27 @@ PrivateKey.prototype.toObject = PrivateKey.prototype.toJSON = function toObject
360
388
  }
361
389
  }
362
390
 
391
+ /**
392
+ * What `JSON.stringify()` calls — deliberately REDACTED.
393
+ *
394
+ * `toJSON` used to be the same function as `toObject`, so the secret scalar was emitted
395
+ * by anything that stringified a key, or an object holding one: a log line, an error
396
+ * dump, a request body. That is how a private key reached an OP_RETURN in the GDAF
397
+ * anchor path. Serialising a key is now something you have to ask for by name.
398
+ *
399
+ * Use `toObject()` (or `toWIF()`) when you genuinely intend to export the secret;
400
+ * `PrivateKey.fromObject(key.toObject())` still round-trips exactly.
401
+ *
402
+ * @returns {Object} A redacted representation, safe to log
403
+ */
404
+ PrivateKey.prototype.toJSON = function toJSON () {
405
+ return {
406
+ bn: '[REDACTED]',
407
+ compressed: this.compressed,
408
+ network: this.network.toString()
409
+ }
410
+ }
411
+
363
412
  /**
364
413
  * Will return a string formatted for the console
365
414
  *
@@ -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.0",
3
+ "version": "7.5.2",
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
  "./*": "./*"