@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.
- package/CHANGELOG.md +147 -0
- package/README.md +289 -55
- package/architecture_demo.js +247 -0
- package/bsv-covenant.min.js +10 -0
- package/bsv-gdaf.min.js +37 -0
- package/bsv-ltp.min.js +37 -0
- package/bsv-script-helper.min.js +10 -0
- package/bsv-security.min.js +31 -0
- package/bsv-shamir.min.js +12 -0
- package/bsv-smartcontract.min.js +37 -0
- package/bsv.bundle.js +9 -9
- package/bsv.min.js +3 -3
- package/build/bsv-covenant.min.js +10 -0
- package/build/bsv-script-helper.min.js +10 -0
- package/build/bsv-security.min.js +31 -0
- package/build/bsv-smartcontract.min.js +39 -0
- package/build/bsv.bundle.js +39 -0
- package/build/bsv.min.js +39 -0
- package/build/webpack.bundle.config.js +22 -0
- package/build/webpack.config.js +18 -0
- package/build/webpack.covenant.config.js +27 -0
- package/build/webpack.gdaf.config.js +54 -0
- package/build/webpack.ltp.config.js +17 -0
- package/build/webpack.script-helper.config.js +27 -0
- package/build/webpack.security.config.js +23 -0
- package/build/webpack.smartcontract.config.js +25 -0
- package/build/webpack.subproject.config.js +6 -0
- package/bundle-entry.js +341 -0
- package/complete_ltp_demo.js +511 -0
- package/covenant-entry.js +44 -0
- package/docs/pushtx-key-insights.md +106 -0
- package/gdaf-entry.js +54 -0
- package/index.js +272 -5
- package/lib/crypto/shamir.js +360 -0
- package/lib/gdaf/attestation-signer.js +461 -0
- package/lib/gdaf/attestation-verifier.js +600 -0
- package/lib/gdaf/did-resolver.js +382 -0
- package/lib/gdaf/index.js +471 -0
- package/lib/gdaf/schema-validator.js +682 -0
- package/lib/gdaf/smartledger-anchor.js +486 -0
- package/lib/gdaf/zk-prover.js +507 -0
- package/lib/ltp/anchor.js +438 -0
- package/lib/ltp/claim.js +1026 -0
- package/lib/ltp/index.js +470 -0
- package/lib/ltp/obligation.js +945 -0
- package/lib/ltp/proof.js +828 -0
- package/lib/ltp/registry.js +702 -0
- package/lib/ltp/right.js +765 -0
- package/lib/smart_contract/API_REFERENCE.md +1 -1
- package/lib/smart_contract/EXAMPLES.md +2 -2
- package/lib/smart_contract/QUICK_START.md +2 -2
- package/lib/smart_contract/README.md +1 -1
- package/lib/smart_contract/index.js +4 -0
- package/ltp-entry.js +92 -0
- package/package.json +91 -20
- package/script-helper-entry.js +49 -0
- package/security-entry.js +70 -0
- package/shamir-entry.js +173 -0
- package/shamir_demo.js +121 -0
- package/simple_demo.js +204 -0
- package/smartcontract-entry.js +133 -0
- package/test_shamir.js +221 -0
- package/test_standalone_shamir.html +83 -0
- package/tests/bundle-completeness-test.html +131 -0
- package/tests/bundle-demo.html +476 -0
- package/tests/smartcontract-test.html +239 -0
- package/tests/standalone-modules-test.html +260 -0
- package/tests/test.html +612 -0
- package/tests/unpkg-demo.html +194 -0
- package/docs/nchain.md +0 -958
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>BSV Shamir Secret Sharing - Standalone Test</title>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<h1>BSV Shamir Secret Sharing - Standalone Module Test</h1>
|
|
9
|
+
<div id="output"></div>
|
|
10
|
+
|
|
11
|
+
<script src="bsv-shamir.min.js"></script>
|
|
12
|
+
<script>
|
|
13
|
+
function log(message) {
|
|
14
|
+
document.getElementById('output').innerHTML += message + '<br>';
|
|
15
|
+
console.log(message);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
log('=== BSV Shamir Standalone Module Test ===');
|
|
19
|
+
log('');
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
if (typeof bsvShamir === 'undefined') {
|
|
23
|
+
log('❌ bsvShamir not available');
|
|
24
|
+
} else {
|
|
25
|
+
log('✅ bsvShamir loaded successfully');
|
|
26
|
+
log('Version: ' + bsvShamir.version);
|
|
27
|
+
log('Algorithm: ' + bsvShamir.algorithm);
|
|
28
|
+
log('');
|
|
29
|
+
|
|
30
|
+
// Test basic functionality
|
|
31
|
+
var secret = 'Hello from Browser!';
|
|
32
|
+
var threshold = 2;
|
|
33
|
+
var shares = 4;
|
|
34
|
+
|
|
35
|
+
log('🔐 Testing secret splitting...');
|
|
36
|
+
log('Secret: ' + secret);
|
|
37
|
+
log('Threshold: ' + threshold + ', Total shares: ' + shares);
|
|
38
|
+
|
|
39
|
+
var splitShares = bsvShamir.split(secret, threshold, shares);
|
|
40
|
+
log('✅ Split into ' + splitShares.length + ' shares');
|
|
41
|
+
|
|
42
|
+
// Test reconstruction
|
|
43
|
+
log('');
|
|
44
|
+
log('🔓 Testing secret reconstruction...');
|
|
45
|
+
var reconstructed = bsvShamir.combine(splitShares.slice(0, threshold));
|
|
46
|
+
var reconstructedSecret = reconstructed.toString();
|
|
47
|
+
|
|
48
|
+
log('Reconstructed: ' + reconstructedSecret);
|
|
49
|
+
|
|
50
|
+
if (reconstructedSecret === secret) {
|
|
51
|
+
log('✅ Reconstruction successful!');
|
|
52
|
+
} else {
|
|
53
|
+
log('❌ Reconstruction failed');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Test share verification
|
|
57
|
+
log('');
|
|
58
|
+
log('🔍 Testing share verification...');
|
|
59
|
+
var validShares = 0;
|
|
60
|
+
for (var i = 0; i < splitShares.length; i++) {
|
|
61
|
+
if (bsvShamir.verifyShare(splitShares[i])) {
|
|
62
|
+
validShares++;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
log('Valid shares: ' + validShares + '/' + splitShares.length);
|
|
66
|
+
|
|
67
|
+
// Run demo
|
|
68
|
+
log('');
|
|
69
|
+
log('🚀 Running demo...');
|
|
70
|
+
var demoResult = bsvShamir.demo();
|
|
71
|
+
log('Demo completed: ' + (demoResult.success ? 'SUCCESS' : 'FAILED'));
|
|
72
|
+
|
|
73
|
+
log('');
|
|
74
|
+
log('🎉 All tests completed successfully!');
|
|
75
|
+
log('📦 BSV Shamir Secret Sharing standalone module is working correctly.');
|
|
76
|
+
}
|
|
77
|
+
} catch (error) {
|
|
78
|
+
log('❌ Error: ' + error.message);
|
|
79
|
+
console.error('Full error:', error);
|
|
80
|
+
}
|
|
81
|
+
</script>
|
|
82
|
+
</body>
|
|
83
|
+
</html>
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>BSV Bundle Completeness Test</title>
|
|
5
|
+
<style>
|
|
6
|
+
body { font-family: Arial; margin: 20px; }
|
|
7
|
+
.success { color: green; }
|
|
8
|
+
.error { color: red; }
|
|
9
|
+
.warning { color: orange; }
|
|
10
|
+
.module-test { margin: 10px 0; padding: 10px; border: 1px solid #ccc; }
|
|
11
|
+
</style>
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<h1>🔬 BSV Bundle Completeness Test</h1>
|
|
15
|
+
<p>Testing that our bundle includes all modules from the main library...</p>
|
|
16
|
+
|
|
17
|
+
<div id="results"></div>
|
|
18
|
+
|
|
19
|
+
<script src="bsv.bundle.js"></script>
|
|
20
|
+
<script>
|
|
21
|
+
const results = document.getElementById('results');
|
|
22
|
+
|
|
23
|
+
function log(message, className = '') {
|
|
24
|
+
const div = document.createElement('div');
|
|
25
|
+
div.className = className;
|
|
26
|
+
div.innerHTML = message;
|
|
27
|
+
results.appendChild(div);
|
|
28
|
+
console.log(message);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function testModule(name, accessor, required = true) {
|
|
32
|
+
const div = document.createElement('div');
|
|
33
|
+
div.className = 'module-test';
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const module = accessor();
|
|
37
|
+
if (module) {
|
|
38
|
+
div.innerHTML = `<span class="success">✅ ${name}: Available</span>`;
|
|
39
|
+
if (typeof module === 'function') {
|
|
40
|
+
div.innerHTML += ` (Constructor)`;
|
|
41
|
+
} else if (typeof module === 'object') {
|
|
42
|
+
const keys = Object.keys(module);
|
|
43
|
+
div.innerHTML += ` (${keys.length} properties: ${keys.slice(0, 3).join(', ')}${keys.length > 3 ? '...' : ''})`;
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
div.innerHTML = `<span class="${required ? 'error' : 'warning'}">${required ? '❌' : '⚠️'} ${name}: Not available</span>`;
|
|
47
|
+
}
|
|
48
|
+
} catch (e) {
|
|
49
|
+
div.innerHTML = `<span class="${required ? 'error' : 'warning'}">${required ? '❌' : '⚠️'} ${name}: Error - ${e.message}</span>`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
results.appendChild(div);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Test all modules that should be in the bundle
|
|
56
|
+
log('<h2>Core BSV Library</h2>');
|
|
57
|
+
testModule('bsv', () => bsv);
|
|
58
|
+
testModule('bsv.version', () => bsv.version);
|
|
59
|
+
testModule('bsv.PrivateKey', () => bsv.PrivateKey);
|
|
60
|
+
testModule('bsv.PublicKey', () => bsv.PublicKey);
|
|
61
|
+
testModule('bsv.Address', () => bsv.Address);
|
|
62
|
+
testModule('bsv.Transaction', () => bsv.Transaction);
|
|
63
|
+
testModule('bsv.Script', () => bsv.Script);
|
|
64
|
+
|
|
65
|
+
log('<h2>Crypto Modules</h2>');
|
|
66
|
+
testModule('bsv.crypto.Hash', () => bsv.crypto.Hash);
|
|
67
|
+
testModule('bsv.crypto.ECDSA', () => bsv.crypto.ECDSA);
|
|
68
|
+
testModule('bsv.crypto.Signature', () => bsv.crypto.Signature);
|
|
69
|
+
testModule('bsv.crypto.SmartVerify', () => bsv.crypto.SmartVerify);
|
|
70
|
+
testModule('bsv.crypto.EllipticFixed', () => bsv.crypto.EllipticFixed);
|
|
71
|
+
|
|
72
|
+
log('<h2>SmartLedger Security</h2>');
|
|
73
|
+
testModule('bsv.SmartLedger', () => bsv.SmartLedger);
|
|
74
|
+
testModule('bsv.SmartVerify', () => bsv.SmartVerify);
|
|
75
|
+
testModule('bsv.EllipticFixed', () => bsv.EllipticFixed);
|
|
76
|
+
|
|
77
|
+
log('<h2>Additional Modules</h2>');
|
|
78
|
+
testModule('bsv.Message', () => bsv.Message);
|
|
79
|
+
testModule('bsv.Mnemonic', () => bsv.Mnemonic, false); // May not work in browser
|
|
80
|
+
testModule('bsv.ECIES', () => bsv.ECIES);
|
|
81
|
+
|
|
82
|
+
log('<h2>SmartContract Framework</h2>');
|
|
83
|
+
testModule('bsv.SmartContract', () => bsv.SmartContract);
|
|
84
|
+
if (bsv.SmartContract) {
|
|
85
|
+
testModule('SmartContract.interpretScript', () => bsv.SmartContract.interpretScript);
|
|
86
|
+
testModule('SmartContract.getScriptMetrics', () => bsv.SmartContract.getScriptMetrics);
|
|
87
|
+
testModule('SmartContract.examineStack', () => bsv.SmartContract.examineStack);
|
|
88
|
+
testModule('SmartContract.optimizeScript', () => bsv.SmartContract.optimizeScript);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
log('<h2>NEW: Advanced Development Tools</h2>');
|
|
92
|
+
testModule('bsv.CovenantInterface', () => bsv.CovenantInterface);
|
|
93
|
+
testModule('bsv.CustomScriptHelper', () => bsv.CustomScriptHelper);
|
|
94
|
+
testModule('bsv.Transaction.sighash', () => bsv.Transaction.sighash);
|
|
95
|
+
|
|
96
|
+
log('<h2>Bundle Information</h2>');
|
|
97
|
+
testModule('bsv.bundle', () => bsv.bundle);
|
|
98
|
+
testModule('bsv.SmartLedgerBundle', () => bsv.SmartLedgerBundle);
|
|
99
|
+
|
|
100
|
+
// Test bundle convenience methods
|
|
101
|
+
log('<h2>Bundle Convenience Methods</h2>');
|
|
102
|
+
if (bsv.SmartLedgerBundle) {
|
|
103
|
+
testModule('generateKeys()', () => bsv.SmartLedgerBundle.generateKeys);
|
|
104
|
+
testModule('createMessage()', () => bsv.SmartLedgerBundle.createMessage);
|
|
105
|
+
testModule('encrypt()', () => bsv.SmartLedgerBundle.encrypt);
|
|
106
|
+
testModule('examineScript()', () => bsv.SmartLedgerBundle.examineScript);
|
|
107
|
+
testModule('createCovenant()', () => bsv.SmartLedgerBundle.createCovenant);
|
|
108
|
+
testModule('createCustomSignature()', () => bsv.SmartLedgerBundle.createCustomSignature);
|
|
109
|
+
testModule('calculateSighash()', () => bsv.SmartLedgerBundle.calculateSighash);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Show bundle info
|
|
113
|
+
if (bsv.bundle) {
|
|
114
|
+
log('<h2>Bundle Contents</h2>');
|
|
115
|
+
log(`<div>Version: ${bsv.bundle.version}</div>`);
|
|
116
|
+
log(`<div>Type: ${bsv.bundle.type}</div>`);
|
|
117
|
+
log(`<div>Includes: ${bsv.bundle.includes.join(', ')}</div>`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Final summary
|
|
121
|
+
log('<h2>Summary</h2>');
|
|
122
|
+
const successCount = document.querySelectorAll('.success').length;
|
|
123
|
+
const errorCount = document.querySelectorAll('.error').length;
|
|
124
|
+
const warningCount = document.querySelectorAll('.warning').length;
|
|
125
|
+
|
|
126
|
+
log(`<div><strong>✅ Successful: ${successCount}</strong></div>`);
|
|
127
|
+
if (errorCount > 0) log(`<div><strong>❌ Errors: ${errorCount}</strong></div>`);
|
|
128
|
+
if (warningCount > 0) log(`<div><strong>⚠️ Warnings: ${warningCount}</strong></div>`);
|
|
129
|
+
</script>
|
|
130
|
+
</body>
|
|
131
|
+
</html>
|