@smartledger/bsv 7.0.2 → 7.2.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.
- package/CHANGELOG.md +224 -0
- package/README.md +38 -38
- package/bsv-gdaf.min.js +46 -46
- package/bsv-ltp.min.js +46 -46
- package/bsv-smartcontract.min.js +15 -15
- package/bsv.bundle.js +46 -46
- package/bsv.d.ts +17 -1
- package/bsv.min.js +46 -46
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/getting-started/INSTALLATION.md +23 -23
- package/docs/getting-started/QUICK_START.md +7 -7
- package/docs/migration/FROM_BSV_1_5_6.md +5 -5
- package/lib/crypto/ecdsa.js +24 -2
- package/lib/crypto/signature.js +33 -6
- package/lib/crypto/smartledger_verify.js +5 -6
- package/lib/ltp/claim.js +2 -3
- package/lib/ltp/obligation.js +2 -6
- package/lib/ltp/registry.js +7 -6
- package/lib/ltp/right.js +2 -6
- package/lib/ordinals/README.md +24 -1
- package/lib/ordinals/inscription.js +113 -23
- package/lib/ordinals/ordlock.js +1 -0
- package/lib/util/id.js +48 -0
- package/package.json +1 -1
- package/test/build/esm_wrapper.js +10 -3
- package/test/crypto/ecdsa.js +73 -0
- package/test/crypto/security.js +51 -2
- package/test/crypto/signature.js +81 -0
- package/test/ltp/ids.js +74 -0
- package/test/ordinals/inscription.js +154 -0
- package/test/script/script.js +4 -2
- package/test/util/id.js +72 -0
- package/version.js +1 -1
|
@@ -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.0
|
|
58
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@7.2.0/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.0
|
|
64
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@7.2.0/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.0
|
|
70
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@7.2.0/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.0
|
|
85
|
-
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.0
|
|
86
|
-
| **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.0
|
|
87
|
-
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.0
|
|
88
|
-
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.0
|
|
89
|
-
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.0
|
|
90
|
-
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.0
|
|
91
|
-
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.0
|
|
92
|
-
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.0
|
|
93
|
-
| **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.0
|
|
94
|
-
| **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.0
|
|
95
|
-
| **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.0
|
|
84
|
+
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js` |
|
|
85
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.2.0/bsv.bundle.js` |
|
|
86
|
+
| **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.2.0/bsv-smartcontract.min.js` |
|
|
87
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.2.0/bsv-covenant.min.js` |
|
|
88
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.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@7.2.0/bsv-security.min.js` |
|
|
90
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.2.0/bsv-ecies.min.js` |
|
|
91
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.2.0/bsv-message.min.js` |
|
|
92
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.2.0/bsv-mnemonic.min.js` |
|
|
93
|
+
| **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.2.0/bsv-shamir.min.js` |
|
|
94
|
+
| **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.2.0/bsv-gdaf.min.js` |
|
|
95
|
+
| **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.2.0/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.0
|
|
104
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
|
|
104
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/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.0
|
|
110
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
111
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
109
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
|
|
110
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-covenant.min.js"></script>
|
|
111
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/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.0
|
|
117
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
118
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
116
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
|
|
117
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-ltp.min.js"></script>
|
|
118
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/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.0
|
|
136
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
137
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
135
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-security.min.js"></script>
|
|
137
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/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.0
|
|
149
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/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.0
|
|
725
|
+
<script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@7.2.0/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.0
|
|
51
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/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.0
|
|
61
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/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.0
|
|
75
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
76
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
74
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
|
|
75
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-covenant.min.js"></script>
|
|
76
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/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.0
|
|
86
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
87
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
85
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
|
|
86
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-ltp.min.js"></script>
|
|
87
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/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.0
|
|
102
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
103
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
101
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
|
|
102
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-security.min.js"></script>
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/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.0
|
|
118
|
-
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.0
|
|
119
|
-
| **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.0
|
|
120
|
-
| **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.0
|
|
121
|
-
| **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.0
|
|
122
|
-
| **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.0
|
|
123
|
-
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.0
|
|
124
|
-
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.0
|
|
125
|
-
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.0
|
|
126
|
-
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.0
|
|
127
|
-
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.0
|
|
128
|
-
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.0
|
|
117
|
+
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js` |
|
|
118
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.2.0/bsv.bundle.js` |
|
|
119
|
+
| **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.2.0/bsv-smartcontract.min.js` |
|
|
120
|
+
| **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.2.0/bsv-ltp.min.js` |
|
|
121
|
+
| **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.2.0/bsv-gdaf.min.js` |
|
|
122
|
+
| **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.2.0/bsv-shamir.min.js` |
|
|
123
|
+
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.2.0/bsv-security.min.js` |
|
|
124
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.2.0/bsv-mnemonic.min.js` |
|
|
125
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.2.0/bsv-ecies.min.js` |
|
|
126
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.2.0/bsv-covenant.min.js` |
|
|
127
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.2.0/bsv-script-helper.min.js` |
|
|
128
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.2.0/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.0
|
|
17
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
|
|
18
18
|
|
|
19
19
|
<!-- Everything included (937KB) -->
|
|
20
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
20
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/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.0
|
|
130
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
|
|
131
131
|
|
|
132
132
|
<!-- Smart contracts (937KB) -->
|
|
133
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
133
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-smartcontract.min.js"></script>
|
|
134
134
|
|
|
135
135
|
<!-- Legal tokens (1.16MB) -->
|
|
136
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-ltp.min.js"></script>
|
|
137
137
|
|
|
138
138
|
<!-- Digital identity (1.16MB) -->
|
|
139
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
139
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-gdaf.min.js"></script>
|
|
140
140
|
|
|
141
141
|
<!-- Everything (937KB) -->
|
|
142
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
142
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/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.0
|
|
162
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.min.js"></script>
|
|
163
163
|
|
|
164
164
|
<!-- Add smart contracts when ready -->
|
|
165
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
165
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-smartcontract.min.js"></script>
|
|
166
166
|
|
|
167
167
|
<!-- Add advanced features as needed -->
|
|
168
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
169
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
168
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-ltp.min.js"></script>
|
|
169
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-gdaf.min.js"></script>
|
|
170
170
|
|
|
171
171
|
<!-- Everything in one file -->
|
|
172
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.0
|
|
172
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.bundle.js"></script>
|
|
173
173
|
```
|
|
174
174
|
|
|
175
175
|
## 🔍 **Testing Your Migration**
|
package/lib/crypto/ecdsa.js
CHANGED
|
@@ -18,6 +18,21 @@ var ECDSA = function ECDSA (obj) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
// A nonce may be consumed by at most one signature: signing two messages under
|
|
22
|
+
// one k reveals the private key. Assigning k marks it fresh; _findSignature
|
|
23
|
+
// marks it stale once used, and derives a new RFC 6979 nonce when it is stale.
|
|
24
|
+
Object.defineProperty(ECDSA.prototype, 'k', {
|
|
25
|
+
get: function () {
|
|
26
|
+
return this._k
|
|
27
|
+
},
|
|
28
|
+
set: function (k) {
|
|
29
|
+
this._k = k
|
|
30
|
+
this._kFresh = true
|
|
31
|
+
},
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true
|
|
34
|
+
})
|
|
35
|
+
|
|
21
36
|
ECDSA.prototype.set = function (obj) {
|
|
22
37
|
this.hashbuf = obj.hashbuf || this.hashbuf
|
|
23
38
|
this.endian = obj.endian || this.endian // the endianness of hashbuf
|
|
@@ -39,7 +54,11 @@ ECDSA.prototype.set = function (obj) {
|
|
|
39
54
|
this.sig = this.sig
|
|
40
55
|
}
|
|
41
56
|
|
|
42
|
-
this.k = obj.k || this.k
|
|
57
|
+
// Must not be `this.k = obj.k || this.k`: that re-runs the setter and would
|
|
58
|
+
// re-mark an already-spent nonce as fresh.
|
|
59
|
+
if (obj.k) {
|
|
60
|
+
this.k = obj.k
|
|
61
|
+
}
|
|
43
62
|
this.verified = obj.verified || this.verified
|
|
44
63
|
return this
|
|
45
64
|
}
|
|
@@ -226,7 +245,8 @@ ECDSA.prototype._findSignature = function (d, e) {
|
|
|
226
245
|
var badrs = 0
|
|
227
246
|
var k, Q, r, s
|
|
228
247
|
do {
|
|
229
|
-
|
|
248
|
+
// A spent nonce (!this._kFresh) must never be reused for a second message.
|
|
249
|
+
if (!this.k || !this._kFresh || badrs > 0) {
|
|
230
250
|
this.deterministicK(badrs)
|
|
231
251
|
}
|
|
232
252
|
badrs++
|
|
@@ -236,6 +256,8 @@ ECDSA.prototype._findSignature = function (d, e) {
|
|
|
236
256
|
s = k.invm(N).mul(e.add(d.mul(r))).umod(N)
|
|
237
257
|
} while (r.cmp(BN.Zero) <= 0 || s.cmp(BN.Zero) <= 0)
|
|
238
258
|
|
|
259
|
+
this._kFresh = false
|
|
260
|
+
|
|
239
261
|
s = ECDSA.toLowS(s)
|
|
240
262
|
return {
|
|
241
263
|
s: s,
|
package/lib/crypto/signature.js
CHANGED
|
@@ -82,8 +82,26 @@ Signature.fromString = function (str) {
|
|
|
82
82
|
return Signature.fromDER(buf)
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* A DER INTEGER carrying r or s must be non-empty, positive (high bit clear,
|
|
87
|
+
* since ECDSA r/s are unsigned), and minimally padded — a leading 0x00 is
|
|
88
|
+
* permitted only to clear the high bit of the byte that follows. Anything else
|
|
89
|
+
* is a second encoding of the same number, i.e. a malleable signature.
|
|
90
|
+
*/
|
|
91
|
+
function checkCanonicalInt (name, ibuf) {
|
|
92
|
+
$.checkArgument(ibuf.length > 0, new Error('Length of ' + name + ' is zero'))
|
|
93
|
+
$.checkArgument(!(ibuf[0] & 0x80), new Error('Value of ' + name + ' is negative'))
|
|
94
|
+
$.checkArgument(!(ibuf.length > 1 && ibuf[0] === 0x00 && !(ibuf[1] & 0x80)),
|
|
95
|
+
new Error('Value of ' + name + ' is excessively padded'))
|
|
96
|
+
}
|
|
97
|
+
|
|
85
98
|
/**
|
|
86
99
|
* In order to mimic the non-strict DER encoding of OpenSSL, set strict = false.
|
|
100
|
+
*
|
|
101
|
+
* Non-strict is required to parse the non-canonical signatures already on chain
|
|
102
|
+
* and is what fromTxFormat uses; consensus-level canonicality is enforced
|
|
103
|
+
* separately by isTxDER under the interpreter's flags. Strict is the default and
|
|
104
|
+
* is what application-level callers (fromDER/fromString) get.
|
|
87
105
|
*/
|
|
88
106
|
Signature.parseDER = function (buf, strict) {
|
|
89
107
|
$.checkArgument(Buffer.isBuffer(buf), new Error('DER formatted signature should be a buffer'))
|
|
@@ -115,12 +133,17 @@ Signature.parseDER = function (buf, strict) {
|
|
|
115
133
|
var slength = buf[2 + 2 + rlength + 1]
|
|
116
134
|
var sbuf = buf.slice(2 + 2 + rlength + 2, 2 + 2 + rlength + 2 + slength)
|
|
117
135
|
var s = BN.fromBuffer(sbuf)
|
|
118
|
-
var sneg = buf[2 + 2 + rlength + 2
|
|
136
|
+
var sneg = buf[2 + 2 + rlength + 2] === 0x00
|
|
119
137
|
$.checkArgument(slength === sbuf.length, new Error('Length of s incorrect'))
|
|
120
138
|
|
|
121
139
|
var sumlength = 2 + 2 + rlength + 2 + slength
|
|
122
140
|
$.checkArgument(length === sumlength - 2, new Error('Length of signature incorrect'))
|
|
123
141
|
|
|
142
|
+
if (strict) {
|
|
143
|
+
checkCanonicalInt('r', rbuf)
|
|
144
|
+
checkCanonicalInt('s', sbuf)
|
|
145
|
+
}
|
|
146
|
+
|
|
124
147
|
var obj = {
|
|
125
148
|
header: header,
|
|
126
149
|
length: length,
|
|
@@ -384,24 +407,28 @@ Signature.prototype.isValid = function () {
|
|
|
384
407
|
}
|
|
385
408
|
|
|
386
409
|
/**
|
|
387
|
-
*
|
|
410
|
+
* Assert that this signature is safe to accept: r and s in (0, n) and s
|
|
411
|
+
* canonical (low-S). Throws if not; returns `this` for chaining.
|
|
412
|
+
*
|
|
413
|
+
* This asserts rather than rewrites. Silently replacing a high-S s with n-s
|
|
414
|
+
* cannot protect against malleability — ECDSA accepts s and n-s equally, so the
|
|
415
|
+
* rewritten signature verifies exactly as the original did, and the only effect
|
|
416
|
+
* is to hide from the caller that they were handed a malleated signature. Use
|
|
417
|
+
* toCanonical() to deliberately normalize one.
|
|
388
418
|
*/
|
|
389
419
|
Signature.prototype.applySecurityPatches = function () {
|
|
390
420
|
var Point = require('./point')
|
|
391
421
|
var n = Point.getN()
|
|
392
422
|
var nh = n.shrn(1) // n/2
|
|
393
423
|
|
|
394
|
-
// Security validation
|
|
395
424
|
if (this.r.isZero() || this.s.isZero()) {
|
|
396
425
|
throw new Error('Invalid signature: zero r or s')
|
|
397
426
|
}
|
|
398
427
|
if (this.r.gte(n) || this.s.gte(n)) {
|
|
399
428
|
throw new Error('Invalid signature: out of range')
|
|
400
429
|
}
|
|
401
|
-
|
|
402
|
-
// Canonicalize s value (anti-malleability)
|
|
403
430
|
if (this.s.gt(nh)) {
|
|
404
|
-
|
|
431
|
+
throw new Error('Invalid signature: non-canonical (high) s')
|
|
405
432
|
}
|
|
406
433
|
|
|
407
434
|
return this
|
|
@@ -59,20 +59,19 @@ function smartVerify (msgHash, sig, pubkey) {
|
|
|
59
59
|
return false
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
//
|
|
63
|
-
|
|
62
|
+
// Reject high-S rather than canonicalizing it: ECDSA accepts s and n-s
|
|
63
|
+
// equally, so verifying a rewritten s would report every malleated signature
|
|
64
|
+
// as valid — the outcome this module exists to prevent.
|
|
64
65
|
if (s.gt(nh)) {
|
|
65
|
-
|
|
66
|
+
return false
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
// Create canonicalized signature object for ECDSA verify
|
|
69
69
|
const Signature = require('./signature')
|
|
70
70
|
const canonicalSig = new Signature({
|
|
71
71
|
r: r,
|
|
72
|
-
s:
|
|
72
|
+
s: s
|
|
73
73
|
})
|
|
74
74
|
|
|
75
|
-
// Use BSV's ECDSA verify with canonical signature object
|
|
76
75
|
return ECDSA.verify(msgHash, canonicalSig, pubkey)
|
|
77
76
|
}
|
|
78
77
|
|
package/lib/ltp/claim.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var bsv = require('../../')
|
|
4
4
|
var Hash = bsv.crypto.Hash
|
|
5
5
|
var $ = bsv.util.preconditions
|
|
6
|
+
var Id = require('../util/id')
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Legal Token Protocol - Claim Preparation Primitives
|
|
@@ -691,9 +692,7 @@ var ClaimValidator = {
|
|
|
691
692
|
* @private
|
|
692
693
|
*/
|
|
693
694
|
_generateBatchId: function() {
|
|
694
|
-
|
|
695
|
-
var data = 'batch_' + Date.now() + '_' + Math.random()
|
|
696
|
-
return Hash.sha256(Buffer.from(data)).toString('hex').substring(0, 16)
|
|
695
|
+
return Id.randomHex(16)
|
|
697
696
|
},
|
|
698
697
|
|
|
699
698
|
/**
|
package/lib/ltp/obligation.js
CHANGED
|
@@ -6,6 +6,7 @@ var ECDSA = bsv.crypto.ECDSA
|
|
|
6
6
|
var Signature = bsv.crypto.Signature
|
|
7
7
|
var PrivateKey = bsv.PrivateKey
|
|
8
8
|
var $ = bsv.util.preconditions
|
|
9
|
+
var Id = require('../util/id')
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Resolve the AUTHORITATIVE signer public key for a token: the issuer's key,
|
|
@@ -976,12 +977,7 @@ var ObligationToken = {
|
|
|
976
977
|
* @private
|
|
977
978
|
*/
|
|
978
979
|
_generateUUID: function() {
|
|
979
|
-
|
|
980
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
981
|
-
var r = Math.random() * 16 | 0
|
|
982
|
-
var v = c === 'x' ? r : (r & 0x3 | 0x8)
|
|
983
|
-
return v.toString(16)
|
|
984
|
-
})
|
|
980
|
+
return Id.uuid4()
|
|
985
981
|
}
|
|
986
982
|
}
|
|
987
983
|
|
package/lib/ltp/registry.js
CHANGED
|
@@ -5,6 +5,7 @@ var Hash = bsv.crypto.Hash
|
|
|
5
5
|
var Address = bsv.Address
|
|
6
6
|
var Transaction = bsv.Transaction
|
|
7
7
|
var $ = bsv.util.preconditions
|
|
8
|
+
var Id = require('../util/id')
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Legal Token Protocol - Registry Primitives
|
|
@@ -552,9 +553,7 @@ var LTPRegistry = {
|
|
|
552
553
|
* @private
|
|
553
554
|
*/
|
|
554
555
|
_generateRegistryId: function() {
|
|
555
|
-
|
|
556
|
-
var data = 'reg_' + Date.now() + '_' + Math.random()
|
|
557
|
-
return 'reg_' + Hash.sha256(Buffer.from(data)).toString('hex').substring(0, 16)
|
|
556
|
+
return 'reg_' + Id.randomHex(16)
|
|
558
557
|
},
|
|
559
558
|
|
|
560
559
|
/**
|
|
@@ -686,9 +685,11 @@ var LTPRegistry = {
|
|
|
686
685
|
* @private
|
|
687
686
|
*/
|
|
688
687
|
_generateAuditId: function() {
|
|
689
|
-
//
|
|
690
|
-
|
|
691
|
-
|
|
688
|
+
// 128 bits. Audit entries are minted per action and retained for years, and
|
|
689
|
+
// a collision silently overwrites a record in a Map-keyed store, so this is
|
|
690
|
+
// sized to close the birthday question outright rather than to match the
|
|
691
|
+
// per-registry ids above (which are minted once each).
|
|
692
|
+
return 'audit_' + Id.randomHex(32)
|
|
692
693
|
},
|
|
693
694
|
|
|
694
695
|
/**
|
package/lib/ltp/right.js
CHANGED
|
@@ -7,6 +7,7 @@ var Signature = bsv.crypto.Signature
|
|
|
7
7
|
var PrivateKey = bsv.PrivateKey
|
|
8
8
|
var $ = bsv.util.preconditions
|
|
9
9
|
var _ = require('../util/_')
|
|
10
|
+
var Id = require('../util/id')
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Resolve the AUTHORITATIVE signer public key for a token: the issuer's key.
|
|
@@ -925,12 +926,7 @@ var RightToken = {
|
|
|
925
926
|
* @private
|
|
926
927
|
*/
|
|
927
928
|
_generateUUID: function() {
|
|
928
|
-
|
|
929
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
930
|
-
var r = Math.random() * 16 | 0
|
|
931
|
-
var v = c === 'x' ? r : (r & 0x3 | 0x8)
|
|
932
|
-
return v.toString(16)
|
|
933
|
-
})
|
|
929
|
+
return Id.uuid4()
|
|
934
930
|
}
|
|
935
931
|
}
|
|
936
932
|
|
package/lib/ordinals/README.md
CHANGED
|
@@ -29,7 +29,8 @@ var script = Ord.buildInscription({
|
|
|
29
29
|
})
|
|
30
30
|
var output = Ord.createInscriptionOutput({ address: ownerAddress, contentType: 'image/png', content: pngBuffer })
|
|
31
31
|
|
|
32
|
-
// Parse it back.
|
|
32
|
+
// Parse it back. `lock` is the whole script minus the envelope: the 1Sat spec allows the
|
|
33
|
+
// locking script to be prepended OR appended, and both are recovered.
|
|
33
34
|
var insc = Ord.parseInscription(script) // { contentType, content, contentText, lock }
|
|
34
35
|
Ord.isInscription(script) // true
|
|
35
36
|
|
|
@@ -40,6 +41,28 @@ var outs = Ord.batchInscriptionOutputs([
|
|
|
40
41
|
])
|
|
41
42
|
```
|
|
42
43
|
|
|
44
|
+
### Arguments are checked, because an inscription is permanent
|
|
45
|
+
|
|
46
|
+
`content` may be any data — a string or a `Buffer` of arbitrary bytes, under any MIME
|
|
47
|
+
type. What the builder will not do is guess, because every guess it used to make wrote
|
|
48
|
+
something other than what the caller asked for onto a permanent record:
|
|
49
|
+
|
|
50
|
+
| Call | Before | Now |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| `content` omitted | built a valid-looking script inscribing **nothing** | throws, and names the field you passed instead (`data`, `body`, `payload`, …) |
|
|
53
|
+
| `content: {…}` or a number | inscribed `[object Object]` / `"42"` | throws; encode it yourself (`JSON.stringify`, `Buffer.from`) |
|
|
54
|
+
| `Buffer` content, no `contentType` | labelled it `text/plain` | throws — bytes carry no hint about what they are |
|
|
55
|
+
| empty `lock` | emitted an **anyone-can-spend** ordinal | throws unless you pass `allowEmptyLock: true` |
|
|
56
|
+
| both `lock` and `address` | silently used `lock` | throws — they name different owners |
|
|
57
|
+
| `satoshis: 0` | built a 0-sat output carrying no ordinal | throws; must be a positive integer |
|
|
58
|
+
|
|
59
|
+
Deliberate cases are still expressible: pass `content: ''` for an empty payload, and
|
|
60
|
+
`allowEmptyLock: true` when you are appending the envelope to a lock you supply yourself
|
|
61
|
+
(this is how the OrdLock listing carries its inline inscription).
|
|
62
|
+
|
|
63
|
+
The default `contentType` of `text/plain` still applies to **string** content, which is
|
|
64
|
+
the common case and is truthfully described by it.
|
|
65
|
+
|
|
43
66
|
## Marketplace: the OrdLock covenant
|
|
44
67
|
|
|
45
68
|
A listing locks the 1-sat ordinal behind a script with two spend paths:
|