@smartledger/bsv 3.2.1 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/README.md +289 -55
  3. package/architecture_demo.js +247 -0
  4. package/bsv-covenant.min.js +10 -0
  5. package/bsv-gdaf.min.js +37 -0
  6. package/bsv-ltp.min.js +37 -0
  7. package/bsv-script-helper.min.js +10 -0
  8. package/bsv-security.min.js +31 -0
  9. package/bsv-shamir.min.js +12 -0
  10. package/bsv-smartcontract.min.js +37 -0
  11. package/bsv.bundle.js +9 -9
  12. package/bsv.min.js +3 -3
  13. package/build/bsv-covenant.min.js +10 -0
  14. package/build/bsv-script-helper.min.js +10 -0
  15. package/build/bsv-security.min.js +31 -0
  16. package/build/bsv-smartcontract.min.js +39 -0
  17. package/build/bsv.bundle.js +39 -0
  18. package/build/bsv.min.js +39 -0
  19. package/build/webpack.bundle.config.js +22 -0
  20. package/build/webpack.config.js +18 -0
  21. package/build/webpack.covenant.config.js +27 -0
  22. package/build/webpack.gdaf.config.js +54 -0
  23. package/build/webpack.ltp.config.js +17 -0
  24. package/build/webpack.script-helper.config.js +27 -0
  25. package/build/webpack.security.config.js +23 -0
  26. package/build/webpack.smartcontract.config.js +25 -0
  27. package/build/webpack.subproject.config.js +6 -0
  28. package/bundle-entry.js +341 -0
  29. package/complete_ltp_demo.js +511 -0
  30. package/covenant-entry.js +44 -0
  31. package/docs/pushtx-key-insights.md +106 -0
  32. package/gdaf-entry.js +54 -0
  33. package/index.js +272 -5
  34. package/lib/crypto/shamir.js +360 -0
  35. package/lib/gdaf/attestation-signer.js +461 -0
  36. package/lib/gdaf/attestation-verifier.js +600 -0
  37. package/lib/gdaf/did-resolver.js +382 -0
  38. package/lib/gdaf/index.js +471 -0
  39. package/lib/gdaf/schema-validator.js +682 -0
  40. package/lib/gdaf/smartledger-anchor.js +486 -0
  41. package/lib/gdaf/zk-prover.js +507 -0
  42. package/lib/ltp/anchor.js +438 -0
  43. package/lib/ltp/claim.js +1026 -0
  44. package/lib/ltp/index.js +470 -0
  45. package/lib/ltp/obligation.js +945 -0
  46. package/lib/ltp/proof.js +828 -0
  47. package/lib/ltp/registry.js +702 -0
  48. package/lib/ltp/right.js +765 -0
  49. package/lib/smart_contract/API_REFERENCE.md +1 -1
  50. package/lib/smart_contract/EXAMPLES.md +2 -2
  51. package/lib/smart_contract/QUICK_START.md +2 -2
  52. package/lib/smart_contract/README.md +1 -1
  53. package/lib/smart_contract/index.js +4 -0
  54. package/ltp-entry.js +92 -0
  55. package/package.json +91 -20
  56. package/script-helper-entry.js +49 -0
  57. package/security-entry.js +70 -0
  58. package/shamir-entry.js +173 -0
  59. package/shamir_demo.js +121 -0
  60. package/simple_demo.js +204 -0
  61. package/smartcontract-entry.js +133 -0
  62. package/test_shamir.js +221 -0
  63. package/test_standalone_shamir.html +83 -0
  64. package/tests/bundle-completeness-test.html +131 -0
  65. package/tests/bundle-demo.html +476 -0
  66. package/tests/smartcontract-test.html +239 -0
  67. package/tests/standalone-modules-test.html +260 -0
  68. package/tests/test.html +612 -0
  69. package/tests/unpkg-demo.html +194 -0
  70. package/docs/nchain.md +0 -958
@@ -0,0 +1,194 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>SmartLedger BSV - unpkg CDN Demo</title>
7
+ <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ max-width: 800px;
11
+ margin: 0 auto;
12
+ padding: 20px;
13
+ background: #f5f5f5;
14
+ }
15
+ .demo-section {
16
+ background: white;
17
+ padding: 20px;
18
+ margin: 20px 0;
19
+ border-radius: 8px;
20
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
21
+ }
22
+ h1 { color: #6B46C1; }
23
+ h2 { color: #4C1D95; }
24
+ .result {
25
+ background: #f8f9fa;
26
+ padding: 10px;
27
+ border-left: 4px solid #6B46C1;
28
+ margin: 10px 0;
29
+ font-family: monospace;
30
+ }
31
+ .button {
32
+ background: #6B46C1;
33
+ color: white;
34
+ border: none;
35
+ padding: 10px 20px;
36
+ border-radius: 4px;
37
+ cursor: pointer;
38
+ margin: 5px;
39
+ }
40
+ .button:hover { background: #4C1D95; }
41
+ </style>
42
+ </head>
43
+ <body>
44
+ <h1>🚀 SmartLedger BSV v3.0 - unpkg CDN Demo</h1>
45
+
46
+ <div class="demo-section">
47
+ <h2>📦 Loaded from unpkg CDN</h2>
48
+ <p>This page demonstrates SmartLedger BSV loaded directly from unpkg:</p>
49
+ <div class="result">
50
+ <strong>CDN URL:</strong> https://unpkg.com/smartledger-bsv@3.0.0/bsv.min.js<br>
51
+ <strong>Package:</strong> smartledger-bsv@3.0.0<br>
52
+ <strong>Size:</strong> ~349KB (minified)
53
+ </div>
54
+ </div>
55
+
56
+ <div class="demo-section">
57
+ <h2>🔐 Security Information</h2>
58
+ <div id="security-info" class="result">Loading...</div>
59
+ </div>
60
+
61
+ <div class="demo-section">
62
+ <h2>🔑 Generate Bitcoin SV Keys</h2>
63
+ <button class="button" onclick="generateKeys()">Generate New Keys</button>
64
+ <div id="key-results" class="result">Click button to generate keys...</div>
65
+ </div>
66
+
67
+ <div class="demo-section">
68
+ <h2>💬 Message Signing (Requires Message Module)</h2>
69
+ <button class="button" onclick="loadMessageModule()">Load Message Module</button>
70
+ <button class="button" onclick="signMessage()">Sign Message</button>
71
+ <div id="message-results" class="result">Load message module first...</div>
72
+ </div>
73
+
74
+ <div class="demo-section">
75
+ <h2>🎲 HD Wallet & Mnemonic (Requires Mnemonic Module)</h2>
76
+ <button class="button" onclick="loadMnemonicModule()">Load Mnemonic Module</button>
77
+ <button class="button" onclick="generateMnemonic()">Generate Mnemonic</button>
78
+ <div id="mnemonic-results" class="result">Load mnemonic module first...</div>
79
+ </div>
80
+
81
+ <!-- Main BSV library from unpkg -->
82
+ <script src="https://unpkg.com/smartledger-bsv@3.0.0/bsv.min.js"></script>
83
+
84
+ <script>
85
+ // Display security information
86
+ function showSecurityInfo() {
87
+ const info = document.getElementById('security-info');
88
+ info.innerHTML = `
89
+ <strong>Library:</strong> ${bsv.hardenedBy} BSV ${bsv.version}<br>
90
+ <strong>Base Version:</strong> ${bsv.baseVersion}<br>
91
+ <strong>Security Features:</strong> ${bsv.securityFeatures.join(', ')}<br>
92
+ <strong>Hardened:</strong> ${bsv.isHardened ? 'Yes' : 'No'}<br>
93
+ <strong>SmartLedger Available:</strong> ${bsv.SmartLedger ? 'Yes' : 'No'}
94
+ `;
95
+ }
96
+
97
+ // Generate BSV keys
98
+ function generateKeys() {
99
+ try {
100
+ const privateKey = new bsv.PrivateKey();
101
+ const publicKey = privateKey.toPublicKey();
102
+ const address = privateKey.toAddress();
103
+
104
+ document.getElementById('key-results').innerHTML = `
105
+ <strong>Private Key:</strong> ${privateKey.toString()}<br>
106
+ <strong>Public Key:</strong> ${publicKey.toString()}<br>
107
+ <strong>Address:</strong> ${address.toString()}<br>
108
+ <strong>Network:</strong> ${address.network.name}
109
+ `;
110
+ } catch (error) {
111
+ document.getElementById('key-results').innerHTML = `Error: ${error.message}`;
112
+ }
113
+ }
114
+
115
+ // Load message module dynamically
116
+ function loadMessageModule() {
117
+ const script = document.createElement('script');
118
+ script.src = 'https://unpkg.com/smartledger-bsv@3.0.0/bsv-message.min.js';
119
+ script.onload = () => {
120
+ document.getElementById('message-results').innerHTML = 'Message module loaded! Click "Sign Message" to test.';
121
+ };
122
+ script.onerror = () => {
123
+ document.getElementById('message-results').innerHTML = 'Failed to load message module.';
124
+ };
125
+ document.head.appendChild(script);
126
+ }
127
+
128
+ // Sign a message
129
+ function signMessage() {
130
+ try {
131
+ if (typeof bsvMessage === 'undefined') {
132
+ document.getElementById('message-results').innerHTML = 'Message module not loaded yet.';
133
+ return;
134
+ }
135
+
136
+ const privateKey = new bsv.PrivateKey();
137
+ const message = new bsvMessage('Hello SmartLedger BSV from unpkg!');
138
+ const signature = message.sign(privateKey);
139
+
140
+ document.getElementById('message-results').innerHTML = `
141
+ <strong>Message:</strong> "Hello SmartLedger BSV from unpkg!"<br>
142
+ <strong>Signature:</strong> ${signature}<br>
143
+ <strong>Address:</strong> ${privateKey.toAddress().toString()}<br>
144
+ <strong>Verified:</strong> ${message.verify(privateKey.toAddress(), signature) ? 'Yes' : 'No'}
145
+ `;
146
+ } catch (error) {
147
+ document.getElementById('message-results').innerHTML = `Error: ${error.message}`;
148
+ }
149
+ }
150
+
151
+ // Load mnemonic module dynamically
152
+ function loadMnemonicModule() {
153
+ const script = document.createElement('script');
154
+ script.src = 'https://unpkg.com/smartledger-bsv@3.0.0/bsv-mnemonic.min.js';
155
+ script.onload = () => {
156
+ document.getElementById('mnemonic-results').innerHTML = 'Mnemonic module loaded! Click "Generate Mnemonic" to test.';
157
+ };
158
+ script.onerror = () => {
159
+ document.getElementById('mnemonic-results').innerHTML = 'Failed to load mnemonic module.';
160
+ };
161
+ document.head.appendChild(script);
162
+ }
163
+
164
+ // Generate mnemonic
165
+ function generateMnemonic() {
166
+ try {
167
+ if (typeof bsvMnemonic === 'undefined') {
168
+ document.getElementById('mnemonic-results').innerHTML = 'Mnemonic module not loaded yet.';
169
+ return;
170
+ }
171
+
172
+ const mnemonic = new bsvMnemonic();
173
+ const hdPrivateKey = mnemonic.toHDPrivateKey();
174
+ const firstAddress = hdPrivateKey.deriveChild(0).privateKey.toAddress();
175
+
176
+ document.getElementById('mnemonic-results').innerHTML = `
177
+ <strong>Mnemonic:</strong> ${mnemonic.toString()}<br>
178
+ <strong>Word Count:</strong> ${mnemonic.toString().split(' ').length}<br>
179
+ <strong>HD Master Key:</strong> ${hdPrivateKey.toString().substring(0, 50)}...<br>
180
+ <strong>First Address:</strong> ${firstAddress.toString()}
181
+ `;
182
+ } catch (error) {
183
+ document.getElementById('mnemonic-results').innerHTML = `Error: ${error.message}`;
184
+ }
185
+ }
186
+
187
+ // Initialize on page load
188
+ window.addEventListener('load', () => {
189
+ showSecurityInfo();
190
+ console.log('SmartLedger BSV loaded from unpkg:', bsv);
191
+ });
192
+ </script>
193
+ </body>
194
+ </html>