@smartledger/bsv 7.6.0 → 7.6.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.6.0/bsv-shamir.min.js`
58
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv-gdaf.min.js`
64
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv-ltp.min.js`
70
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv.min.js` |
85
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.6.0/bsv.bundle.js` |
86
- | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.6.0/bsv-smartcontract.min.js` |
87
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.6.0/bsv-covenant.min.js` |
88
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv-security.min.js` |
90
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.6.0/bsv-ecies.min.js` |
91
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.6.0/bsv-message.min.js` |
92
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.6.0/bsv-mnemonic.min.js` |
93
- | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.6.0/bsv-shamir.min.js` |
94
- | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.6.0/bsv-gdaf.min.js` |
95
- | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.6.0/bsv-ltp.min.js` |
84
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.6.1/bsv.min.js` |
85
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.6.1/bsv.bundle.js` |
86
+ | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.6.1/bsv-smartcontract.min.js` |
87
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.6.1/bsv-covenant.min.js` |
88
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.6.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.6.1/bsv-security.min.js` |
90
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.6.1/bsv-ecies.min.js` |
91
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.6.1/bsv-message.min.js` |
92
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.6.1/bsv-mnemonic.min.js` |
93
+ | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.6.1/bsv-shamir.min.js` |
94
+ | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.6.1/bsv-gdaf.min.js` |
95
+ | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv.min.js"></script>
104
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-script-helper.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv.min.js"></script>
104
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv.min.js"></script>
110
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-covenant.min.js"></script>
111
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-smartcontract.min.js"></script>
109
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv.min.js"></script>
110
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv-covenant.min.js"></script>
111
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv.min.js"></script>
117
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-ltp.min.js"></script>
118
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-gdaf.min.js"></script>
116
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv.min.js"></script>
117
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv-ltp.min.js"></script>
118
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv.min.js"></script>
136
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-security.min.js"></script>
137
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-shamir.min.js"></script>
135
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv-security.min.js"></script>
137
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv.bundle.js"></script>
149
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv.min.js"></script>
725
+ <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@7.6.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.6.0/bsv.min.js"></script>
51
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv.bundle.js"></script>
61
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv.min.js"></script>
75
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-covenant.min.js"></script>
76
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-smartcontract.min.js"></script>
74
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv.min.js"></script>
75
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv-covenant.min.js"></script>
76
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv.min.js"></script>
86
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-ltp.min.js"></script>
87
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-gdaf.min.js"></script>
85
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv.min.js"></script>
86
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv-ltp.min.js"></script>
87
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv.min.js"></script>
102
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-security.min.js"></script>
103
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-shamir.min.js"></script>
101
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv.min.js"></script>
102
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv-security.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv.min.js` |
118
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.6.0/bsv.bundle.js` |
119
- | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.6.0/bsv-smartcontract.min.js` |
120
- | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.6.0/bsv-ltp.min.js` |
121
- | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.6.0/bsv-gdaf.min.js` |
122
- | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.6.0/bsv-shamir.min.js` |
123
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.6.0/bsv-security.min.js` |
124
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.6.0/bsv-mnemonic.min.js` |
125
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.6.0/bsv-ecies.min.js` |
126
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.6.0/bsv-covenant.min.js` |
127
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.6.0/bsv-script-helper.min.js` |
128
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.6.0/bsv-message.min.js` |
117
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.6.1/bsv.min.js` |
118
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.6.1/bsv.bundle.js` |
119
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.6.1/bsv-smartcontract.min.js` |
120
+ | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.6.1/bsv-ltp.min.js` |
121
+ | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.6.1/bsv-gdaf.min.js` |
122
+ | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.6.1/bsv-shamir.min.js` |
123
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.6.1/bsv-security.min.js` |
124
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.6.1/bsv-mnemonic.min.js` |
125
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.6.1/bsv-ecies.min.js` |
126
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.6.1/bsv-covenant.min.js` |
127
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.6.1/bsv-script-helper.min.js` |
128
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv.min.js"></script>
17
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv.min.js"></script>
18
18
 
19
19
  <!-- Everything included (937KB) -->
20
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv.bundle.js"></script>
20
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv.min.js"></script>
130
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv.min.js"></script>
131
131
 
132
132
  <!-- Smart contracts (937KB) -->
133
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-smartcontract.min.js"></script>
133
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv-smartcontract.min.js"></script>
134
134
 
135
135
  <!-- Legal tokens (1.16MB) -->
136
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-ltp.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv-ltp.min.js"></script>
137
137
 
138
138
  <!-- Digital identity (1.16MB) -->
139
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-gdaf.min.js"></script>
139
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv-gdaf.min.js"></script>
140
140
 
141
141
  <!-- Everything (937KB) -->
142
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv.bundle.js"></script>
142
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.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.6.0/bsv.min.js"></script>
162
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv.min.js"></script>
163
163
 
164
164
  <!-- Add smart contracts when ready -->
165
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-smartcontract.min.js"></script>
165
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv-smartcontract.min.js"></script>
166
166
 
167
167
  <!-- Add advanced features as needed -->
168
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-ltp.min.js"></script>
169
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv-gdaf.min.js"></script>
168
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv-ltp.min.js"></script>
169
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv-gdaf.min.js"></script>
170
170
 
171
171
  <!-- Everything in one file -->
172
- <script src="https://unpkg.com/@smartledger/bsv@7.6.0/bsv.bundle.js"></script>
172
+ <script src="https://unpkg.com/@smartledger/bsv@7.6.1/bsv.bundle.js"></script>
173
173
  ```
174
174
 
175
175
  ## 🔍 **Testing Your Migration**
@@ -681,7 +681,11 @@ Interpreter.prototype.checkSequence = function (nSequence) {
681
681
  var nLockTimeMask =
682
682
  Interpreter.SEQUENCE_LOCKTIME_TYPE_FLAG | Interpreter.SEQUENCE_LOCKTIME_MASK
683
683
  var txToSequenceMasked = new BN(txToSequence & nLockTimeMask)
684
- var nSequenceMasked = nSequence.and(nLockTimeMask)
684
+ // new BN(...) is required: bn.js `and` takes a BN, and passing the plain
685
+ // number threw 'num.clone is not a function'. The interpreter's try/catch
686
+ // swallowed it and reported SCRIPT_ERR_UNKNOWN_ERROR, making every
687
+ // OP_CHECKSEQUENCEVERIFY script fail with a misleading error.
688
+ var nSequenceMasked = nSequence.and(new BN(nLockTimeMask))
685
689
 
686
690
  // There are two kinds of nSequence: lock-by-blockheight and
687
691
  // lock-by-blocktime, distinguished by whether nSequenceMasked <
@@ -180,7 +180,22 @@ function sFromPreimage (preimage) {
180
180
  if (z[0] < 0x01 || z[0] > 0x7f) return null
181
181
  var s = new BN(z).add(new BN(Gx)).mod(N)
182
182
  if (s.gt(HALF_N)) return null // enforce low-S (canonical / non-malleable)
183
- var sBE = s.toBuffer('be', 32)
183
+ // NOT s.toBuffer('be', 32): lib/crypto/bn.js REPLACES toBuffer with an
184
+ // options-object form, so 'be' would land in `opts`, opts.size would be
185
+ // undefined and the 32 ignored — yielding a natural-length buffer.
186
+ //
187
+ // That truncation is currently UNREACHABLE, and the reason is worth writing
188
+ // down because it is not obvious: z is filtered to a leading byte of
189
+ // 0x01..0x7f above, so z is in [2**248, 2**255); adding Gx (~0.476 * 2**256)
190
+ // never wraps; and the low-S check caps the result at n/2. s therefore lands
191
+ // in a narrow band with a leading byte of 0x7a..0x7f and is always 32 bytes.
192
+ //
193
+ // The call is still wrong, and worth fixing, because that safety is an
194
+ // accident of two filters that have nothing to do with buffer length. Widen
195
+ // the MINIMALDATA range or drop low-S and the truncation becomes reachable —
196
+ // silently, inside a covenant, where DER_PREFIX declares s to be exactly 32
197
+ // bytes and a short one makes the spend invalid.
198
+ var sBE = s.toBuffer({ size: 32 })
184
199
  return (sBE[0] >= 0x01) ? sBE : null // s <= n/2 already guarantees sBE[0] <= 0x7f
185
200
  }
186
201
 
@@ -215,7 +230,12 @@ function grind (spend, inputIndex, lockingScript, satoshis, opts) {
215
230
  if (field === 'nLockTime') spend.nLockTime = nonce
216
231
  else input.sequenceNumber = 0xfffffffe - nonce // stay < 0xffffffff (non-final)
217
232
  var preimage = H.rawPreimage(spend, inputIndex, lockingScript, satoshis, sighashType)
218
- if (sFromPreimage(preimage)) return { preimage: preimage, tries: i + 1, field: field, nonce: nonce }
233
+ // Length-checked, not truthy: grind's contract is a FIXED-length DER
234
+ // signature, and a short s would be truthy. Belt-and-braces alongside the
235
+ // toBuffer fix above — this is the check that would catch it if the
236
+ // upstream filters that currently make a short s impossible ever change.
237
+ var sBE = sFromPreimage(preimage)
238
+ if (sBE && sBE.length === 32) return { preimage: preimage, tries: i + 1, field: field, nonce: nonce }
219
239
  }
220
240
  throw new Error('OP_PUSH_TX grind failed after ' + maxTries + ' tries')
221
241
  }
@@ -340,7 +340,7 @@ Transaction.prototype.fromObject = function fromObject (arg) {
340
340
  var self = this
341
341
  var transaction
342
342
  if (arg instanceof Transaction) {
343
- transaction = transaction.toObject()
343
+ transaction = arg.toObject()
344
344
  } else {
345
345
  transaction = arg
346
346
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartledger/bsv",
3
- "version": "7.6.0",
3
+ "version": "7.6.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",
@@ -0,0 +1,180 @@
1
+ 'use strict'
2
+
3
+ /* global describe, it */
4
+
5
+ // Regressions for three wrong calls that shipped through 7.5.8, each of which
6
+ // no test exercised.
7
+ //
8
+ // Two were live: Transaction#fromObject threw on an input its own
9
+ // checkArgument accepts, and OP_CHECKSEQUENCEVERIFY failed every script with a
10
+ // misleading error. Those two tests fail on the unfixed code.
11
+ //
12
+ // The third — sFromPreimage's toBuffer call — is LATENT, and the tests say so
13
+ // rather than pretending otherwise. See the note on that block.
14
+
15
+ require('chai').should()
16
+ var bsv = require('../')
17
+ var BN = bsv.crypto.BN
18
+
19
+ describe('regressions', function () {
20
+ describe('Transaction#fromObject with a Transaction', function () {
21
+ // `fromObject` read `transaction.toObject()` where it meant
22
+ // `arg.toObject()`, so the branch that exists specifically to accept a
23
+ // Transaction was the only branch that could not work. checkArgument
24
+ // admits the input; the next line threw TypeError on it.
25
+ it('accepts a Transaction, which its own checkArgument allows', function () {
26
+ var key = bsv.PrivateKey.fromRandom()
27
+ var source = new bsv.Transaction().to(key.toAddress(), 1000)
28
+
29
+ var copy = new bsv.Transaction().fromObject(source)
30
+
31
+ copy.outputs.length.should.equal(1)
32
+ copy.outputs[0].satoshis.should.equal(1000)
33
+ copy.toObject().should.deep.equal(source.toObject())
34
+ })
35
+
36
+ it('still accepts the plain object form', function () {
37
+ var key = bsv.PrivateKey.fromRandom()
38
+ var source = new bsv.Transaction().to(key.toAddress(), 1000)
39
+
40
+ var copy = new bsv.Transaction().fromObject(source.toObject())
41
+
42
+ copy.toObject().should.deep.equal(source.toObject())
43
+ })
44
+ })
45
+
46
+ describe('BN#toBuffer with the native signature', function () {
47
+ // lib/crypto/bn.js REPLACES toBuffer with an options-object form. Calling
48
+ // it with bn.js's native (endian, length) signature silently ignores the
49
+ // length: 'be' lands in `opts`, `opts.size` is undefined, and the result
50
+ // is the natural-length buffer.
51
+ it('pads to the requested size when given the options form', function () {
52
+ // Leading zero byte, so the natural encoding is shorter than 32.
53
+ var n = new BN('00ff' + '11'.repeat(30), 'hex')
54
+
55
+ n.toBuffer({ size: 32 }).length.should.equal(32)
56
+ })
57
+
58
+ it('does NOT honour a positional length, which is why the options form is required', function () {
59
+ var n = new BN('00ff' + '11'.repeat(30), 'hex')
60
+
61
+ // Documents the trap rather than endorsing it: this is the call shape
62
+ // that produced a 31-byte s inside the OP_PUSH_TX grind.
63
+ n.toBuffer('be', 32).length.should.equal(31)
64
+ })
65
+ })
66
+
67
+ describe('PushTx.sFromPreimage uses the right toBuffer signature', function () {
68
+ // sFromPreimage called `s.toBuffer('be', 32)` — bn.js's NATIVE signature,
69
+ // against a toBuffer that lib/crypto/bn.js has replaced with an
70
+ // options-object form. The length argument was therefore ignored.
71
+ //
72
+ // This is a latent defect, NOT a live one, and the distinction is worth
73
+ // stating precisely: the truncation is currently unreachable. `s` is
74
+ // (HASH256(preimage) + Gx) mod n, and the caller has already required the
75
+ // hash's leading byte to be 0x01..0x7f, so z is in [2**248, 2**255).
76
+ // Adding Gx (about 0.476 * 2**256) never wraps, and the low-S filter caps
77
+ // the result at n/2 — confining s to a narrow band whose leading byte is
78
+ // always 0x7a..0x7f. It can never be zero, so the natural encoding is
79
+ // always 32 bytes anyway.
80
+ //
81
+ // The fix is worth making because the correctness of the output currently
82
+ // depends on two upstream filters that have nothing to do with buffer
83
+ // length. Change the MINIMALDATA range or drop the low-S requirement and
84
+ // the truncation becomes reachable, silently, in a covenant.
85
+ it('always returns exactly 32 bytes', function () {
86
+ var PushTx = bsv.SmartContract.PushTx
87
+ var accepted = 0
88
+
89
+ for (var i = 0; i < 4000; i++) {
90
+ var preimage = bsv.crypto.Hash.sha256(Buffer.from('grind-' + i))
91
+ var sBE = PushTx.sFromPreimage(preimage)
92
+ if (sBE) {
93
+ accepted++
94
+ sBE.length.should.equal(32)
95
+ }
96
+ }
97
+
98
+ accepted.should.be.above(0)
99
+ })
100
+
101
+ it('keeps s inside the band that makes the length safe', function () {
102
+ // Pins the property the paragraph above relies on. If this ever fails,
103
+ // the toBuffer call shape matters again — and the fix is already in.
104
+ var PushTx = bsv.SmartContract.PushTx
105
+
106
+ for (var i = 0; i < 2000; i++) {
107
+ var preimage = bsv.crypto.Hash.sha256(Buffer.from('band-' + i))
108
+ var sBE = PushTx.sFromPreimage(preimage)
109
+ if (sBE) {
110
+ sBE[0].should.be.within(0x01, 0x7f)
111
+ }
112
+ }
113
+ })
114
+ })
115
+
116
+ describe('OP_CHECKSEQUENCEVERIFY', function () {
117
+ // checkSequence masked with `nSequence.and(nLockTimeMask)` where the mask
118
+ // is a plain number. bn.js `and` requires a BN, so it threw
119
+ // 'num.clone is not a function'; the interpreter's try/catch swallowed
120
+ // that and reported SCRIPT_ERR_UNKNOWN_ERROR, making every CSV script fail
121
+ // with a misleading error.
122
+ //
123
+ // Note this is only reachable with SCRIPT_VERIFY_CHECKSEQUENCEVERIFY set:
124
+ // post-Genesis BSV reverted CSV to OP_NOP3 and the flag is off by default.
125
+ it('evaluates instead of failing with SCRIPT_ERR_UNKNOWN_ERROR', function () {
126
+ var Interpreter = bsv.Script.Interpreter
127
+ var key = bsv.PrivateKey.fromRandom()
128
+ var address = key.toAddress()
129
+ var prev = new bsv.Transaction().to(address, 1000)
130
+ var spend = new bsv.Transaction().from({
131
+ txId: prev.hash,
132
+ outputIndex: 0,
133
+ script: bsv.Script.buildPublicKeyHashOut(address).toHex(),
134
+ satoshis: 1000
135
+ })
136
+ spend.version = 2
137
+ spend.inputs[0].sequenceNumber = 20
138
+
139
+ var interpreter = new Interpreter()
140
+ var verified = interpreter.verify(
141
+ bsv.Script.fromASM('OP_1'),
142
+ bsv.Script.fromASM('OP_10 OP_CHECKSEQUENCEVERIFY'),
143
+ spend, 0,
144
+ Interpreter.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY,
145
+ new BN(1000)
146
+ )
147
+
148
+ interpreter.errstr.should.equal('')
149
+ verified.should.equal(true)
150
+ })
151
+
152
+ it('still rejects a sequence that does not satisfy the requirement', function () {
153
+ var Interpreter = bsv.Script.Interpreter
154
+ var key = bsv.PrivateKey.fromRandom()
155
+ var address = key.toAddress()
156
+ var prev = new bsv.Transaction().to(address, 1000)
157
+ var spend = new bsv.Transaction().from({
158
+ txId: prev.hash,
159
+ outputIndex: 0,
160
+ script: bsv.Script.buildPublicKeyHashOut(address).toHex(),
161
+ satoshis: 1000
162
+ })
163
+ spend.version = 2
164
+ // Below the required relative locktime of 10.
165
+ spend.inputs[0].sequenceNumber = 5
166
+
167
+ var interpreter = new Interpreter()
168
+ var verified = interpreter.verify(
169
+ bsv.Script.fromASM('OP_1'),
170
+ bsv.Script.fromASM('OP_10 OP_CHECKSEQUENCEVERIFY'),
171
+ spend, 0,
172
+ Interpreter.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY,
173
+ new BN(1000)
174
+ )
175
+
176
+ verified.should.equal(false)
177
+ interpreter.errstr.should.equal('SCRIPT_ERR_UNSATISFIED_LOCKTIME')
178
+ })
179
+ })
180
+ })
package/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  'use strict'
2
2
  // GENERATED by scripts/sync-version.js on `npm version` — do not edit.
3
- module.exports = '7.6.0'
3
+ module.exports = '7.6.1'