@smartledger/bsv 7.4.0 → 7.5.1

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.4.0/bsv-shamir.min.js`
58
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.5.1/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.4.0/bsv-gdaf.min.js`
64
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.5.1/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.4.0/bsv-ltp.min.js`
70
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.5.1/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.4.0/bsv.min.js` |
85
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js` |
86
- | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js` |
87
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.4.0/bsv-covenant.min.js` |
88
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.4.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.4.0/bsv-security.min.js` |
90
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.4.0/bsv-ecies.min.js` |
91
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.4.0/bsv-message.min.js` |
92
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.4.0/bsv-mnemonic.min.js` |
93
- | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-shamir.min.js` |
94
- | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js` |
95
- | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js` |
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` |
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.4.0/bsv.min.js"></script>
104
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-script-helper.min.js"></script>
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>
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.4.0/bsv.min.js"></script>
110
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-covenant.min.js"></script>
111
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js"></script>
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>
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.4.0/bsv.min.js"></script>
117
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js"></script>
118
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js"></script>
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>
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.4.0/bsv.min.js"></script>
136
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-security.min.js"></script>
137
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-shamir.min.js"></script>
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>
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.4.0/bsv.bundle.js"></script>
149
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.1/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.4.0/bsv.min.js"></script>
725
+ <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@7.5.1/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.4.0/bsv.min.js"></script>
51
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.1/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.4.0/bsv.bundle.js"></script>
61
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.1/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.4.0/bsv.min.js"></script>
75
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-covenant.min.js"></script>
76
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js"></script>
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>
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.4.0/bsv.min.js"></script>
86
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js"></script>
87
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js"></script>
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>
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.4.0/bsv.min.js"></script>
102
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-security.min.js"></script>
103
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-shamir.min.js"></script>
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>
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.4.0/bsv.min.js` |
118
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js` |
119
- | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js` |
120
- | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js` |
121
- | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js` |
122
- | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-shamir.min.js` |
123
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.4.0/bsv-security.min.js` |
124
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.4.0/bsv-mnemonic.min.js` |
125
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.4.0/bsv-ecies.min.js` |
126
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.4.0/bsv-covenant.min.js` |
127
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.4.0/bsv-script-helper.min.js` |
128
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.4.0/bsv-message.min.js` |
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` |
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.4.0/bsv.min.js"></script>
17
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv.min.js"></script>
18
18
 
19
19
  <!-- Everything included (937KB) -->
20
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js"></script>
20
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.1/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.4.0/bsv.min.js"></script>
130
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv.min.js"></script>
131
131
 
132
132
  <!-- Smart contracts (937KB) -->
133
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js"></script>
133
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-smartcontract.min.js"></script>
134
134
 
135
135
  <!-- Legal tokens (1.16MB) -->
136
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-ltp.min.js"></script>
137
137
 
138
138
  <!-- Digital identity (1.16MB) -->
139
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js"></script>
139
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-gdaf.min.js"></script>
140
140
 
141
141
  <!-- Everything (937KB) -->
142
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js"></script>
142
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.1/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.4.0/bsv.min.js"></script>
162
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv.min.js"></script>
163
163
 
164
164
  <!-- Add smart contracts when ready -->
165
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js"></script>
165
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv-smartcontract.min.js"></script>
166
166
 
167
167
  <!-- Add advanced features as needed -->
168
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js"></script>
169
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js"></script>
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>
170
170
 
171
171
  <!-- Everything in one file -->
172
- <script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js"></script>
172
+ <script src="https://unpkg.com/@smartledger/bsv@7.5.1/bsv.bundle.js"></script>
173
173
  ```
174
174
 
175
175
  ## 🔍 **Testing Your Migration**
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
  *
@@ -223,15 +223,23 @@ Interpreter.MAXIMUM_ELEMENT_SIZE = 4
223
223
  // number) so applications can opt into post-Genesis rules — e.g. OP_PUSH_TX
224
224
  // covenants, which need a few hundred opcodes — without forking the interpreter.
225
225
  Interpreter.MAX_OPS_PER_SCRIPT = 201
226
+ // Maximum total serialized script size. Pre-Genesis consensus is 10,000 bytes;
227
+ // post-Genesis BSV removed this limit too. It was previously a literal inside
228
+ // evaluate(), so `useGenesisLimits()` could not lift it and any script over 10 KB —
229
+ // a large 1Sat Ordinals inscription, for instance — failed SCRIPT_ERR_SCRIPT_SIZE
230
+ // no matter what the caller asked for.
231
+ Interpreter.MAX_SCRIPT_SIZE = 10000
226
232
 
227
233
  Interpreter.LOCKTIME_THRESHOLD = 500000000
228
234
  Interpreter.LOCKTIME_THRESHOLD_BN = new BN(Interpreter.LOCKTIME_THRESHOLD)
229
235
 
230
236
  /**
231
237
  * Opt into post-Genesis BSV consensus limits: effectively no caps on stack
232
- * element size, script-number width, or opcode count. Pre-Genesis defaults
233
- * (520 / 4 / 201) remain the out-of-the-box behavior; call this before
234
- * verify() to run modern covenants such as OP_PUSH_TX.
238
+ * element size, script-number width, opcode count, or total script size.
239
+ * Pre-Genesis defaults (520 / 4 / 201 / 10,000) remain the out-of-the-box
240
+ * behavior; call this before verify() to run modern covenants such as
241
+ * OP_PUSH_TX, or to evaluate a script larger than 10 KB such as a sizeable
242
+ * 1Sat Ordinals inscription.
235
243
  *
236
244
  * IMPORTANT: this mutates static properties on the Interpreter constructor
237
245
  * and therefore affects EVERY subsequent `new Interpreter()` in this
@@ -245,7 +253,7 @@ Interpreter.LOCKTIME_THRESHOLD_BN = new BN(Interpreter.LOCKTIME_THRESHOLD)
245
253
  *
246
254
  * bsv.Script.Interpreter.useGenesisLimits(64 * 1024)
247
255
  *
248
- * @param {number} [max=0x7fffffff] Ceiling applied to all three caps.
256
+ * @param {number} [max=0x7fffffff] Ceiling applied to all four caps.
249
257
  * @returns {Interpreter} the Interpreter constructor (for chaining)
250
258
  */
251
259
  Interpreter.useGenesisLimits = function (max) {
@@ -253,6 +261,40 @@ Interpreter.useGenesisLimits = function (max) {
253
261
  Interpreter.MAX_SCRIPT_ELEMENT_SIZE = max
254
262
  Interpreter.MAXIMUM_ELEMENT_SIZE = max
255
263
  Interpreter.MAX_OPS_PER_SCRIPT = max
264
+ Interpreter.MAX_SCRIPT_SIZE = max
265
+ return Interpreter
266
+ }
267
+
268
+ /** The four consensus caps, as a plain object. */
269
+ Interpreter.getLimits = function () {
270
+ return {
271
+ maxScriptElementSize: Interpreter.MAX_SCRIPT_ELEMENT_SIZE,
272
+ maximumElementSize: Interpreter.MAXIMUM_ELEMENT_SIZE,
273
+ maxOpsPerScript: Interpreter.MAX_OPS_PER_SCRIPT,
274
+ maxScriptSize: Interpreter.MAX_SCRIPT_SIZE
275
+ }
276
+ }
277
+
278
+ /**
279
+ * Restore caps captured by `getLimits()`. Because the caps are process-wide statics,
280
+ * anything that raises them must put them back or it silently changes the rules for
281
+ * unrelated code later in the same process — which is exactly how a test that opts
282
+ * into Genesis limits can make a pre-Genesis consensus fixture pass. Pair the two:
283
+ *
284
+ * var saved = Interpreter.getLimits()
285
+ * Interpreter.useGenesisLimits()
286
+ * ...
287
+ * Interpreter.setLimits(saved)
288
+ *
289
+ * @param {object} limits as returned by getLimits()
290
+ * @returns {Interpreter} the Interpreter constructor (for chaining)
291
+ */
292
+ Interpreter.setLimits = function (limits) {
293
+ limits = limits || {}
294
+ if (limits.maxScriptElementSize != null) Interpreter.MAX_SCRIPT_ELEMENT_SIZE = limits.maxScriptElementSize
295
+ if (limits.maximumElementSize != null) Interpreter.MAXIMUM_ELEMENT_SIZE = limits.maximumElementSize
296
+ if (limits.maxOpsPerScript != null) Interpreter.MAX_OPS_PER_SCRIPT = limits.maxOpsPerScript
297
+ if (limits.maxScriptSize != null) Interpreter.MAX_SCRIPT_SIZE = limits.maxScriptSize
256
298
  return Interpreter
257
299
  }
258
300
 
@@ -520,8 +562,7 @@ Interpreter._minimallyEncode = function (buf) {
520
562
  * bitcoind commit: b5d1b1092998bc95313856d535c632ea5a8f9104
521
563
  */
522
564
  Interpreter.prototype.evaluate = function () {
523
- // TODO: script size should be configurable. no magic numbers
524
- if (this.script.toBuffer().length > 10000) {
565
+ if (this.script.toBuffer().length > Interpreter.MAX_SCRIPT_SIZE) {
525
566
  this.errstr = 'SCRIPT_ERR_SCRIPT_SIZE'
526
567
  return false
527
568
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartledger/bsv",
3
- "version": "7.4.0",
3
+ "version": "7.5.1",
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",