smartledger-bsv 4.2.0 → 4.4.0

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.
@@ -136,9 +136,9 @@ node custom_script_signature_test.js
136
136
  ## 📦 Installation
137
137
 
138
138
  ```bash
139
- npm install smartledger-bsv@4.2.0
139
+ npm install smartledger-bsv@4.2.1
140
140
  # or
141
- npm install @smartledger/bsv@4.2.0
141
+ npm install @smartledger/bsv@4.2.1
142
142
  ```
143
143
 
144
144
  ## ✅ Verification Results
@@ -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@4.2.0/bsv-shamir.min.js`
58
+ - **CDN**: `unpkg.com/@smartledger/bsv@4.2.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@4.2.0/bsv-gdaf.min.js`
64
+ - **CDN**: `unpkg.com/@smartledger/bsv@4.2.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@4.2.0/bsv-ltp.min.js`
70
+ - **CDN**: `unpkg.com/@smartledger/bsv@4.2.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@4.2.0/bsv.min.js` |
85
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@4.2.0/bsv.bundle.js` |
86
- | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@4.2.0/bsv-smartcontract.min.js` |
87
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@4.2.0/bsv-covenant.min.js` |
88
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@4.2.0/bsv-script-helper.min.js` |
89
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@4.2.0/bsv-security.min.js` |
90
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@4.2.0/bsv-ecies.min.js` |
91
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@4.2.0/bsv-message.min.js` |
92
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@4.2.0/bsv-mnemonic.min.js` |
93
- | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@4.2.0/bsv-shamir.min.js` |
94
- | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@4.2.0/bsv-gdaf.min.js` |
95
- | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@4.2.0/bsv-ltp.min.js` |
84
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js` |
85
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@4.2.1/bsv.bundle.js` |
86
+ | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@4.2.1/bsv-smartcontract.min.js` |
87
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@4.2.1/bsv-covenant.min.js` |
88
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@4.2.1/bsv-script-helper.min.js` |
89
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@4.2.1/bsv-security.min.js` |
90
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@4.2.1/bsv-ecies.min.js` |
91
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@4.2.1/bsv-message.min.js` |
92
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@4.2.1/bsv-mnemonic.min.js` |
93
+ | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@4.2.1/bsv-shamir.min.js` |
94
+ | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@4.2.1/bsv-gdaf.min.js` |
95
+ | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@4.2.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@4.2.0/bsv.min.js"></script>
104
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-script-helper.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
104
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.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@4.2.0/bsv.min.js"></script>
110
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-covenant.min.js"></script>
111
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-smartcontract.min.js"></script>
109
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
110
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-covenant.min.js"></script>
111
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.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@4.2.0/bsv.min.js"></script>
117
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-ltp.min.js"></script>
118
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-gdaf.min.js"></script>
116
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
117
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-ltp.min.js"></script>
118
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.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@4.2.0/bsv.min.js"></script>
136
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-security.min.js"></script>
137
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-shamir.min.js"></script>
135
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-security.min.js"></script>
137
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.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@4.2.0/bsv.bundle.js"></script>
149
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.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@4.2.0/bsv.min.js"></script>
725
+ <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@4.2.1/bsv.min.js"></script>
726
726
  </head>
727
727
  <body>
728
728
  <script>
@@ -12,10 +12,10 @@ SmartLedger-BSV offers multiple installation methods to suit different developme
12
12
  npm install @smartledger/bsv
13
13
 
14
14
  # Install specific version
15
- npm install @smartledger/bsv@4.2.0
15
+ npm install @smartledger/bsv@4.2.1
16
16
 
17
17
  # Install with exact version lock
18
- npm install --save-exact @smartledger/bsv@4.2.0
18
+ npm install --save-exact @smartledger/bsv@4.2.1
19
19
  ```
20
20
 
21
21
  ### **Usage in Node.js**
@@ -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@4.2.0/bsv.min.js"></script>
51
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.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@4.2.0/bsv.bundle.js"></script>
61
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.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@4.2.0/bsv.min.js"></script>
75
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-covenant.min.js"></script>
76
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-smartcontract.min.js"></script>
74
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
75
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-covenant.min.js"></script>
76
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.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@4.2.0/bsv.min.js"></script>
86
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-ltp.min.js"></script>
87
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-gdaf.min.js"></script>
85
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
86
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-ltp.min.js"></script>
87
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.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@4.2.0/bsv.min.js"></script>
102
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-security.min.js"></script>
103
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-shamir.min.js"></script>
101
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
102
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-security.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.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@4.2.0/bsv.min.js` |
118
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@4.2.0/bsv.bundle.js` |
119
- | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@4.2.0/bsv-smartcontract.min.js` |
120
- | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@4.2.0/bsv-ltp.min.js` |
121
- | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@4.2.0/bsv-gdaf.min.js` |
122
- | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@4.2.0/bsv-shamir.min.js` |
123
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@4.2.0/bsv-security.min.js` |
124
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@4.2.0/bsv-mnemonic.min.js` |
125
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@4.2.0/bsv-ecies.min.js` |
126
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@4.2.0/bsv-covenant.min.js` |
127
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@4.2.0/bsv-script-helper.min.js` |
128
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@4.2.0/bsv-message.min.js` |
117
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js` |
118
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@4.2.1/bsv.bundle.js` |
119
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@4.2.1/bsv-smartcontract.min.js` |
120
+ | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@4.2.1/bsv-ltp.min.js` |
121
+ | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@4.2.1/bsv-gdaf.min.js` |
122
+ | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@4.2.1/bsv-shamir.min.js` |
123
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@4.2.1/bsv-security.min.js` |
124
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@4.2.1/bsv-mnemonic.min.js` |
125
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@4.2.1/bsv-ecies.min.js` |
126
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@4.2.1/bsv-covenant.min.js` |
127
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@4.2.1/bsv-script-helper.min.js` |
128
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@4.2.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@4.2.0/bsv.min.js"></script>
17
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
18
18
 
19
19
  <!-- Everything included (937KB) -->
20
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv.bundle.js"></script>
20
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.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@4.2.0/bsv.min.js"></script>
130
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
131
131
 
132
132
  <!-- Smart contracts (937KB) -->
133
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-smartcontract.min.js"></script>
133
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-smartcontract.min.js"></script>
134
134
 
135
135
  <!-- Legal tokens (1.16MB) -->
136
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-ltp.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-ltp.min.js"></script>
137
137
 
138
138
  <!-- Digital identity (1.16MB) -->
139
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-gdaf.min.js"></script>
139
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-gdaf.min.js"></script>
140
140
 
141
141
  <!-- Everything (937KB) -->
142
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv.bundle.js"></script>
142
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.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@4.2.0/bsv.min.js"></script>
162
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.min.js"></script>
163
163
 
164
164
  <!-- Add smart contracts when ready -->
165
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-smartcontract.min.js"></script>
165
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-smartcontract.min.js"></script>
166
166
 
167
167
  <!-- Add advanced features as needed -->
168
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-ltp.min.js"></script>
169
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv-gdaf.min.js"></script>
168
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-ltp.min.js"></script>
169
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv-gdaf.min.js"></script>
170
170
 
171
171
  <!-- Everything in one file -->
172
- <script src="https://unpkg.com/@smartledger/bsv@4.2.0/bsv.bundle.js"></script>
172
+ <script src="https://unpkg.com/@smartledger/bsv@4.2.1/bsv.bundle.js"></script>
173
173
  ```
174
174
 
175
175
  ## 🔍 **Testing Your Migration**
@@ -701,7 +701,7 @@ Interpreter.prototype.step = function () {
701
701
  return true
702
702
  }
703
703
  break
704
-
704
+
705
705
  // Monolith opcodes are now enabled by default in SmartLedger BSV
706
706
  // These were activated in May 2018 and are part of standard BSV consensus
707
707
  case Opcode.OP_DIV:
@@ -715,7 +715,7 @@ Interpreter.prototype.step = function () {
715
715
  case Opcode.OP_NUM2BIN:
716
716
  // These opcodes are now always enabled - no flag required
717
717
  return false
718
-
718
+
719
719
  default:
720
720
  break
721
721
  }
@@ -1757,6 +1757,56 @@ Interpreter.prototype.step = function () {
1757
1757
  this.stack[this.stack.length - 1] = n1.slice(position)
1758
1758
  break
1759
1759
 
1760
+ case Opcode.OP_LEFT:
1761
+ case Opcode.OP_RIGHT:
1762
+ // (in size -- out) OP_LEFT keeps the first `size` bytes; OP_RIGHT the last.
1763
+ // Re-enabled string opcodes (BSV Chronicle). Original Satoshi semantics.
1764
+ if (this.stack.length < 2) {
1765
+ this.errstr = 'SCRIPT_ERR_INVALID_STACK_OPERATION'
1766
+ return false
1767
+ }
1768
+ buf1 = stacktop(-2)
1769
+ n = BN.fromScriptNumBuffer(stacktop(-1), fRequireMinimal).toNumber()
1770
+ if (n < 0) {
1771
+ this.errstr = 'SCRIPT_ERR_INVALID_NUMBER_RANGE'
1772
+ return false
1773
+ }
1774
+ if (n > buf1.length) {
1775
+ n = buf1.length
1776
+ }
1777
+ this.stack.pop()
1778
+ if (opcodenum === Opcode.OP_LEFT) {
1779
+ this.stack[this.stack.length - 1] = Buffer.from(buf1).slice(0, n)
1780
+ } else {
1781
+ this.stack[this.stack.length - 1] = Buffer.from(buf1).slice(buf1.length - n)
1782
+ }
1783
+ break
1784
+
1785
+ case Opcode.OP_SUBSTR:
1786
+ // (in begin size -- out) out = in[begin : begin + size]
1787
+ // Re-enabled string opcode (BSV Chronicle). Original Satoshi semantics.
1788
+ if (this.stack.length < 3) {
1789
+ this.errstr = 'SCRIPT_ERR_INVALID_STACK_OPERATION'
1790
+ return false
1791
+ }
1792
+ buf1 = stacktop(-3)
1793
+ var subSize = BN.fromScriptNumBuffer(stacktop(-1), fRequireMinimal).toNumber()
1794
+ var subBegin = BN.fromScriptNumBuffer(stacktop(-2), fRequireMinimal).toNumber()
1795
+ if (subBegin < 0 || subSize < 0) {
1796
+ this.errstr = 'SCRIPT_ERR_INVALID_NUMBER_RANGE'
1797
+ return false
1798
+ }
1799
+ if (subBegin > buf1.length) {
1800
+ subBegin = buf1.length
1801
+ }
1802
+ if (subBegin + subSize > buf1.length) {
1803
+ subSize = buf1.length - subBegin
1804
+ }
1805
+ this.stack.pop()
1806
+ this.stack.pop()
1807
+ this.stack[this.stack.length - 1] = Buffer.from(buf1).slice(subBegin, subBegin + subSize)
1808
+ break
1809
+
1760
1810
  //
1761
1811
  // Conversion operations
1762
1812
  //
@@ -18,13 +18,14 @@ var Signature = require('../crypto/signature')
18
18
  var SIGHASH = Signature.SIGHASH_ALL | Signature.SIGHASH_FORKID // 0x41
19
19
 
20
20
  // Post-Genesis consensus flags (big numbers, OP_CAT/OP_SPLIT/OP_MUL, FORKID,
21
- // CLTV/CSV). LOW_S is intentionally omitted so the in-script OP_PUSH_TX
22
- // signature (which may be high-S) verifies.
21
+ // CLTV/CSV). LOW_S is enforced: the OP_PUSH_TX grind produces a canonical
22
+ // (low-S) in-script signature, so these covenants meet mainnet standardness.
23
23
  function flags () {
24
24
  var I = bsv.Script.Interpreter
25
25
  return I.SCRIPT_VERIFY_P2SH |
26
26
  I.SCRIPT_VERIFY_STRICTENC |
27
27
  I.SCRIPT_VERIFY_DERSIG |
28
+ I.SCRIPT_VERIFY_LOW_S |
28
29
  I.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY |
29
30
  I.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY |
30
31
  I.SCRIPT_ENABLE_SIGHASH_FORKID |
@@ -44,8 +44,7 @@ function pelsCovenant (fee) {
44
44
 
45
45
  // 3. value (8B @ offsetFromEnd 52); newValue = value - fee, as 8-byte LE
46
46
  s.add(Opcode.OP_OVER)
47
- s.add(Opcode.OP_SIZE).add(n(52)).add(Opcode.OP_SUB).add(Opcode.OP_SPLIT).add(Opcode.OP_NIP)
48
- s.add(n(8)).add(Opcode.OP_SPLIT).add(Opcode.OP_DROP)
47
+ s.add(n(52)).add(Opcode.OP_RIGHT).add(n(8)).add(Opcode.OP_LEFT) // last 52 bytes, first 8 = value
49
48
  s.add(Opcode.OP_BIN2NUM).add(n(fee)).add(Opcode.OP_SUB)
50
49
  s.add(n(8)).add(Opcode.OP_NUM2BIN)
51
50
 
@@ -59,10 +59,18 @@ function pushTxCore (script) {
59
59
  script.add(gxLe).add(Opcode.OP_ADD) // e + Gx
60
60
  script.add(N_LE).add(Opcode.OP_MOD) // s = (e + Gx) mod n
61
61
  script.add(scriptNum(32)).add(Opcode.OP_NUM2BIN) // s -> 32-byte LE
62
- reverseBytes(script, 32) // -> big-endian (DER INTEGER body)
63
- script.add(DER_PREFIX).add(Opcode.OP_SWAP).add(Opcode.OP_CAT) // PREFIX || s
62
+ reverseBytes(script, 32) // -> big-endian (DER INTEGER body) ; stack: [s_be]
63
+ // Build the DER signature and the pubkey from a SINGLE Gx push (Gx is both the
64
+ // r-value inside the DER prefix and the body of the 02||Gx pubkey). Sharing it
65
+ // via the altstack saves a 32-byte constant vs. embedding Gx twice.
66
+ script.add(Gx).add(Opcode.OP_DUP) // [s_be, Gx, Gx]
67
+ script.add(Buffer.from([0x02])).add(Opcode.OP_SWAP).add(Opcode.OP_CAT) // pubkey = 02||Gx
68
+ script.add(Opcode.OP_TOALTSTACK) // park pubkey ; [s_be, Gx]
69
+ script.add(Buffer.from([0x30, 0x44, 0x02, 0x20])).add(Opcode.OP_SWAP).add(Opcode.OP_CAT) // 30440220||Gx
70
+ script.add(Buffer.from([0x02, 0x20])).add(Opcode.OP_CAT) // ||0220 => DER prefix
71
+ script.add(Opcode.OP_SWAP).add(Opcode.OP_CAT) // DER prefix || s_be
64
72
  script.add(SIGHASH_BYTE).add(Opcode.OP_CAT) // || sighash flag => full DER sig
65
- script.add(PUBKEY).add(Opcode.OP_CHECKSIG) // verify against P = G
73
+ script.add(Opcode.OP_FROMALTSTACK).add(Opcode.OP_CHECKSIG) // pubkey ; verify against P = G
66
74
  return script
67
75
  }
68
76
 
@@ -73,9 +81,8 @@ function authenticator () {
73
81
 
74
82
  /** Extract the committed hashOutputs (item 9, offsetFromEnd 40, len 32) from a preimage on-stack. */
75
83
  function extractHashOutputs (script) {
76
- script.add(Opcode.OP_SIZE).add(scriptNum(40)).add(Opcode.OP_SUB)
77
- .add(Opcode.OP_SPLIT).add(Opcode.OP_NIP)
78
- .add(scriptNum(32)).add(Opcode.OP_SPLIT).add(Opcode.OP_DROP)
84
+ // last 40 bytes, then the first 32 of those = hashOutputs. (BSV string opcodes.)
85
+ script.add(scriptNum(40)).add(Opcode.OP_RIGHT).add(scriptNum(32)).add(Opcode.OP_LEFT)
79
86
  return script
80
87
  }
81
88
 
@@ -98,12 +105,22 @@ function valueCovenant (expectedHashOutputs) {
98
105
  return script
99
106
  }
100
107
 
101
- /** Compute s = (HASH256(preimage)+Gx) mod n; return its 32-byte BE form, or null if not a clean DER template. */
108
+ // floor(n/2) the canonical low-S boundary (matches Signature.hasLowS()).
109
+ var HALF_N = new BN('7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0', 'hex')
110
+
111
+ /**
112
+ * Compute s = (HASH256(preimage)+Gx) mod n; return its 32-byte BE form, or null
113
+ * if the resulting signature would not be a clean, CANONICAL (low-S) DER.
114
+ * Requiring s <= n/2 makes the in-script signature non-malleable and standard,
115
+ * so it passes nodes enforcing SCRIPT_VERIFY_LOW_S — at zero script-size cost
116
+ * (the burden is on the spender's grind, not extra opcodes).
117
+ */
102
118
  function sFromPreimage (preimage) {
103
119
  var z = Hash.sha256sha256(preimage)
104
120
  var s = new BN(z).add(new BN(Gx)).mod(N)
121
+ if (s.gt(HALF_N)) return null // enforce low-S (canonical / non-malleable)
105
122
  var sBE = s.toBuffer('be', 32)
106
- return (sBE[0] >= 0x01 && sBE[0] <= 0x7f) ? sBE : null
123
+ return (sBE[0] >= 0x01) ? sBE : null // s <= n/2 already guarantees sBE[0] <= 0x7f
107
124
  }
108
125
 
109
126
  /**
@@ -41,17 +41,15 @@ function ownershipToken (fee, ownerHash) {
41
41
 
42
42
  // park value (8B @ offsetFromEnd 52) and hashOutputs (32B @ offsetFromEnd 40)
43
43
  s.add(Opcode.OP_DUP)
44
- .add(Opcode.OP_SIZE).add(n(52)).add(Opcode.OP_SUB).add(Opcode.OP_SPLIT).add(Opcode.OP_NIP)
45
- .add(n(8)).add(Opcode.OP_SPLIT).add(Opcode.OP_DROP).add(Opcode.OP_TOALTSTACK) // alt:[value8]
44
+ .add(n(52)).add(Opcode.OP_RIGHT).add(n(8)).add(Opcode.OP_LEFT).add(Opcode.OP_TOALTSTACK) // alt:[value8]
46
45
  s.add(Opcode.OP_DUP); P.extractHashOutputs(s); s.add(Opcode.OP_TOALTSTACK) // alt:[value8, hashOutputs]
47
46
 
48
47
  // scriptChunk = preimage[104 : len-52] (consumes preimage)
49
48
  s.add(n(104)).add(Opcode.OP_SPLIT).add(Opcode.OP_NIP)
50
49
  .add(Opcode.OP_SIZE).add(n(52)).add(Opcode.OP_SUB).add(Opcode.OP_SPLIT).add(Opcode.OP_DROP)
51
50
 
52
- // owner authorization: SHA256(ownerSecret) == ownerHash (chunk[4:36])
53
- s.add(Opcode.OP_DUP).add(n(4)).add(Opcode.OP_SPLIT).add(Opcode.OP_NIP)
54
- .add(n(32)).add(Opcode.OP_SPLIT).add(Opcode.OP_DROP)
51
+ // owner authorization: SHA256(ownerSecret) == ownerHash = chunk[4:36] (OP_SUBSTR)
52
+ s.add(Opcode.OP_DUP).add(n(4)).add(n(32)).add(Opcode.OP_SUBSTR)
55
53
  s.add(n(3)).add(Opcode.OP_ROLL)
56
54
  s.add(Opcode.OP_SHA256).add(Opcode.OP_EQUALVERIFY) // [newOwnerHash, scriptChunk]
57
55
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smartledger-bsv",
3
- "version": "4.2.0",
3
+ "version": "4.4.0",
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",