@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,22 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
entry: path.join(__dirname, '/bundle-entry.js'),
|
|
5
|
+
output: {
|
|
6
|
+
library: 'bsv',
|
|
7
|
+
libraryTarget: 'umd',
|
|
8
|
+
globalObject: 'typeof self !== \'undefined\' ? self : this',
|
|
9
|
+
path: path.join(__dirname, '/'),
|
|
10
|
+
filename: 'bsv.bundle.js'
|
|
11
|
+
},
|
|
12
|
+
node: {
|
|
13
|
+
crypto: 'empty',
|
|
14
|
+
stream: 'empty',
|
|
15
|
+
Buffer: true
|
|
16
|
+
},
|
|
17
|
+
mode: 'production',
|
|
18
|
+
optimization: {
|
|
19
|
+
minimize: true
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var path = require('path')
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
entry: path.join(__dirname, '/index.js'),
|
|
5
|
+
output: {
|
|
6
|
+
library: 'bsv',
|
|
7
|
+
libraryTarget: 'umd',
|
|
8
|
+
globalObject: 'typeof self !== \'undefined\' ? self : this',
|
|
9
|
+
path: path.join(__dirname, '/'),
|
|
10
|
+
filename: 'bsv.min.js'
|
|
11
|
+
},
|
|
12
|
+
node: {
|
|
13
|
+
crypto: 'empty',
|
|
14
|
+
stream: 'empty',
|
|
15
|
+
Buffer: true
|
|
16
|
+
},
|
|
17
|
+
mode: 'production'
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
mode: 'production',
|
|
5
|
+
entry: './covenant-entry.js',
|
|
6
|
+
output: {
|
|
7
|
+
path: path.resolve(__dirname, '.'),
|
|
8
|
+
filename: 'bsv-covenant.min.js',
|
|
9
|
+
library: 'bsvCovenant',
|
|
10
|
+
libraryTarget: 'var'
|
|
11
|
+
},
|
|
12
|
+
externals: {
|
|
13
|
+
// Don't bundle BSV - it should be loaded separately
|
|
14
|
+
'../index.js': 'bsv'
|
|
15
|
+
},
|
|
16
|
+
node: {
|
|
17
|
+
fs: 'empty',
|
|
18
|
+
path: 'empty',
|
|
19
|
+
crypto: 'empty',
|
|
20
|
+
stream: 'empty',
|
|
21
|
+
assert: 'empty',
|
|
22
|
+
http: 'empty',
|
|
23
|
+
https: 'empty',
|
|
24
|
+
os: 'empty',
|
|
25
|
+
url: 'empty'
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
mode: 'production',
|
|
5
|
+
entry: './gdaf-entry.js',
|
|
6
|
+
output: {
|
|
7
|
+
path: path.resolve(__dirname, 'build'),
|
|
8
|
+
filename: 'bsv-gdaf.min.js',
|
|
9
|
+
library: 'GDAF',
|
|
10
|
+
libraryTarget: 'umd',
|
|
11
|
+
globalObject: 'this'
|
|
12
|
+
},
|
|
13
|
+
resolve: {
|
|
14
|
+
fallback: {
|
|
15
|
+
crypto: require.resolve('crypto-browserify'),
|
|
16
|
+
stream: require.resolve('stream-browserify'),
|
|
17
|
+
buffer: require.resolve('buffer'),
|
|
18
|
+
util: require.resolve('util'),
|
|
19
|
+
assert: require.resolve('assert'),
|
|
20
|
+
url: require.resolve('url'),
|
|
21
|
+
zlib: false,
|
|
22
|
+
http: false,
|
|
23
|
+
https: false,
|
|
24
|
+
os: false,
|
|
25
|
+
path: false,
|
|
26
|
+
fs: false
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
module: {
|
|
30
|
+
rules: [
|
|
31
|
+
{
|
|
32
|
+
test: /\.js$/,
|
|
33
|
+
exclude: /node_modules/,
|
|
34
|
+
use: {
|
|
35
|
+
loader: 'babel-loader',
|
|
36
|
+
options: {
|
|
37
|
+
presets: ['@babel/preset-env'],
|
|
38
|
+
plugins: ['@babel/plugin-transform-runtime']
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
plugins: [
|
|
45
|
+
new (require('webpack').ProvidePlugin)({
|
|
46
|
+
Buffer: ['buffer', 'Buffer'],
|
|
47
|
+
process: 'process/browser'
|
|
48
|
+
})
|
|
49
|
+
],
|
|
50
|
+
optimization: {
|
|
51
|
+
minimize: true
|
|
52
|
+
},
|
|
53
|
+
target: 'web'
|
|
54
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
entry: './ltp-entry.js',
|
|
5
|
+
mode: 'production',
|
|
6
|
+
optimization: {
|
|
7
|
+
minimize: true
|
|
8
|
+
},
|
|
9
|
+
output: {
|
|
10
|
+
path: path.resolve(__dirname, '../'),
|
|
11
|
+
filename: 'bsv-ltp.min.js',
|
|
12
|
+
library: 'bsvLTP',
|
|
13
|
+
libraryTarget: 'umd',
|
|
14
|
+
globalObject: 'this'
|
|
15
|
+
},
|
|
16
|
+
target: 'web'
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
mode: 'production',
|
|
5
|
+
entry: './script-helper-entry.js',
|
|
6
|
+
output: {
|
|
7
|
+
path: path.resolve(__dirname, '.'),
|
|
8
|
+
filename: 'bsv-script-helper.min.js',
|
|
9
|
+
library: 'bsvScriptHelper',
|
|
10
|
+
libraryTarget: 'var'
|
|
11
|
+
},
|
|
12
|
+
externals: {
|
|
13
|
+
// Don't bundle BSV - it should be loaded separately
|
|
14
|
+
'../index.js': 'bsv'
|
|
15
|
+
},
|
|
16
|
+
node: {
|
|
17
|
+
fs: 'empty',
|
|
18
|
+
path: 'empty',
|
|
19
|
+
crypto: 'empty',
|
|
20
|
+
stream: 'empty',
|
|
21
|
+
assert: 'empty',
|
|
22
|
+
http: 'empty',
|
|
23
|
+
https: 'empty',
|
|
24
|
+
os: 'empty',
|
|
25
|
+
url: 'empty'
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
mode: 'production',
|
|
5
|
+
entry: './security-entry.js',
|
|
6
|
+
output: {
|
|
7
|
+
path: path.resolve(__dirname, '.'),
|
|
8
|
+
filename: 'bsv-security.min.js',
|
|
9
|
+
library: 'bsvSecurity',
|
|
10
|
+
libraryTarget: 'var'
|
|
11
|
+
},
|
|
12
|
+
node: {
|
|
13
|
+
fs: 'empty',
|
|
14
|
+
path: 'empty',
|
|
15
|
+
crypto: 'empty',
|
|
16
|
+
stream: 'empty',
|
|
17
|
+
assert: 'empty',
|
|
18
|
+
http: 'empty',
|
|
19
|
+
https: 'empty',
|
|
20
|
+
os: 'empty',
|
|
21
|
+
url: 'empty'
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
entry: path.join(__dirname, '/smartcontract-entry.js'),
|
|
5
|
+
output: {
|
|
6
|
+
library: 'bsvSmartContract',
|
|
7
|
+
libraryTarget: 'umd',
|
|
8
|
+
globalObject: 'typeof self !== \'undefined\' ? self : this',
|
|
9
|
+
path: path.join(__dirname, '/'),
|
|
10
|
+
filename: 'bsv-smartcontract.min.js'
|
|
11
|
+
},
|
|
12
|
+
externals: {
|
|
13
|
+
// Don't bundle BSV - expect it to be loaded separately
|
|
14
|
+
'./index.js': 'bsv'
|
|
15
|
+
},
|
|
16
|
+
node: {
|
|
17
|
+
crypto: 'empty',
|
|
18
|
+
stream: 'empty',
|
|
19
|
+
Buffer: true
|
|
20
|
+
},
|
|
21
|
+
mode: 'production',
|
|
22
|
+
optimization: {
|
|
23
|
+
minimize: true
|
|
24
|
+
}
|
|
25
|
+
}
|
package/bundle-entry.js
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SmartLedger BSV Complete Bundle
|
|
3
|
+
*
|
|
4
|
+
* This bundle includes:
|
|
5
|
+
* - Core BSV library with all cryptographic functions
|
|
6
|
+
* - Message signing and verification
|
|
7
|
+
* - HD wallets and mnemonic generation
|
|
8
|
+
* - ECIES encryption/decryption
|
|
9
|
+
* - SmartLedger security enhancements
|
|
10
|
+
* - All dependencies bundled for standalone usage
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* <script src="bsv.bundle.js"></script>
|
|
14
|
+
* <script>
|
|
15
|
+
* // Everything available under 'bsv' namespace
|
|
16
|
+
* const key = new bsv.PrivateKey();
|
|
17
|
+
* const message = new bsv.Message('hello');
|
|
18
|
+
* const mnemonic = new bsv.Mnemonic();
|
|
19
|
+
* const encrypted = bsv.ECIES.encrypt(data, publicKey);
|
|
20
|
+
* </script>
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
'use strict'
|
|
24
|
+
|
|
25
|
+
// Load main BSV library
|
|
26
|
+
var bsv = require('./index.js')
|
|
27
|
+
|
|
28
|
+
// Attach Message functionality
|
|
29
|
+
try {
|
|
30
|
+
const Message = require('./lib/message/message.js')
|
|
31
|
+
bsv.Message = Message
|
|
32
|
+
|
|
33
|
+
// Make it available globally for consistency with separate modules
|
|
34
|
+
if (typeof window !== 'undefined') {
|
|
35
|
+
window.bsvMessage = Message
|
|
36
|
+
}
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.warn('Message module not available:', e.message)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Attach Mnemonic functionality with browser crypto polyfill
|
|
42
|
+
try {
|
|
43
|
+
// Provide crypto polyfill for browser environment
|
|
44
|
+
if (typeof window !== 'undefined' && typeof crypto !== 'undefined' && crypto.subtle) {
|
|
45
|
+
// Browser environment - provide HMAC polyfill
|
|
46
|
+
const originalCrypto = require('crypto')
|
|
47
|
+
if (!originalCrypto.createHmac) {
|
|
48
|
+
originalCrypto.createHmac = function(algorithm, key) {
|
|
49
|
+
return {
|
|
50
|
+
update: function(data) { this._data = data; return this; },
|
|
51
|
+
digest: function(encoding) {
|
|
52
|
+
// Simple fallback - in production you'd want proper HMAC
|
|
53
|
+
const hash = bsv.crypto.Hash.sha256(Buffer.concat([
|
|
54
|
+
Buffer.isBuffer(key) ? key : Buffer.from(key),
|
|
55
|
+
Buffer.isBuffer(this._data) ? this._data : Buffer.from(this._data)
|
|
56
|
+
]));
|
|
57
|
+
return encoding === 'hex' ? hash.toString('hex') : hash;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const Mnemonic = require('./lib/mnemonic/mnemonic.js')
|
|
65
|
+
bsv.Mnemonic = Mnemonic
|
|
66
|
+
|
|
67
|
+
// Make it available globally for consistency with separate modules
|
|
68
|
+
if (typeof window !== 'undefined') {
|
|
69
|
+
window.bsvMnemonic = Mnemonic
|
|
70
|
+
}
|
|
71
|
+
} catch (e) {
|
|
72
|
+
console.warn('Mnemonic module not available:', e.message)
|
|
73
|
+
console.warn('This is expected in browser environments without crypto polyfills')
|
|
74
|
+
|
|
75
|
+
// Provide a minimal mnemonic alternative for browsers
|
|
76
|
+
if (typeof window !== 'undefined') {
|
|
77
|
+
bsv.Mnemonic = function() {
|
|
78
|
+
throw new Error('Full mnemonic functionality requires Node.js crypto. Use separate bsv-mnemonic.min.js for browser support.');
|
|
79
|
+
};
|
|
80
|
+
bsv.Mnemonic.fromString = function() {
|
|
81
|
+
throw new Error('Full mnemonic functionality requires Node.js crypto. Use separate bsv-mnemonic.min.js for browser support.');
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Attach ECIES functionality
|
|
87
|
+
try {
|
|
88
|
+
const ECIES = require('./lib/ecies/index.js')
|
|
89
|
+
bsv.ECIES = ECIES
|
|
90
|
+
bsv.crypto.ECIES = ECIES
|
|
91
|
+
|
|
92
|
+
// Make it available globally for consistency with separate modules
|
|
93
|
+
if (typeof window !== 'undefined') {
|
|
94
|
+
window.bsvEcies = ECIES
|
|
95
|
+
}
|
|
96
|
+
} catch (e) {
|
|
97
|
+
console.warn('ECIES module not available:', e.message)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Include SmartContract interface with debug tools (forced for bundle)
|
|
101
|
+
try {
|
|
102
|
+
const SmartContract = require('./lib/smart_contract')
|
|
103
|
+
bsv.SmartContract = SmartContract
|
|
104
|
+
console.log('SmartContract interface loaded in bundle with', Object.keys(SmartContract).length, 'methods')
|
|
105
|
+
} catch (e) {
|
|
106
|
+
console.warn('SmartContract module not available:', e.message)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Include CovenantInterface for advanced covenant development
|
|
110
|
+
try {
|
|
111
|
+
const CovenantInterface = require('./lib/covenant-interface.js')
|
|
112
|
+
bsv.CovenantInterface = CovenantInterface
|
|
113
|
+
console.log('CovenantInterface loaded in bundle')
|
|
114
|
+
} catch (e) {
|
|
115
|
+
console.warn('CovenantInterface module not available:', e.message)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Include CustomScriptHelper for simplified script development
|
|
119
|
+
try {
|
|
120
|
+
const CustomScriptHelper = require('./lib/custom-script-helper.js')
|
|
121
|
+
bsv.CustomScriptHelper = CustomScriptHelper
|
|
122
|
+
console.log('CustomScriptHelper loaded in bundle')
|
|
123
|
+
} catch (e) {
|
|
124
|
+
console.warn('CustomScriptHelper module not available:', e.message)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Include Legal Token Protocol (LTP) - NEW v3.3.0
|
|
128
|
+
try {
|
|
129
|
+
const LTP = require('./lib/ltp')
|
|
130
|
+
bsv.LTP = LTP
|
|
131
|
+
console.log('Legal Token Protocol (LTP) loaded in bundle with', Object.keys(LTP).length, 'methods')
|
|
132
|
+
} catch (e) {
|
|
133
|
+
console.warn('LTP module not available:', e.message)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Include Global Digital Attestation Framework (GDAF) - NEW v3.3.0
|
|
137
|
+
try {
|
|
138
|
+
const GDAF = require('./lib/gdaf')
|
|
139
|
+
bsv.GDAF = GDAF
|
|
140
|
+
console.log('Global Digital Attestation Framework (GDAF) loaded in bundle')
|
|
141
|
+
} catch (e) {
|
|
142
|
+
console.warn('GDAF module not available:', e.message)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Include Shamir Secret Sharing - NEW v3.3.0
|
|
146
|
+
try {
|
|
147
|
+
const Shamir = require('./lib/crypto/shamir')
|
|
148
|
+
bsv.crypto.Shamir = Shamir
|
|
149
|
+
bsv.Shamir = Shamir
|
|
150
|
+
console.log('Shamir Secret Sharing loaded in bundle')
|
|
151
|
+
} catch (e) {
|
|
152
|
+
console.warn('Shamir module not available:', e.message)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// SmartLedger security modules (matching index.js structure)
|
|
156
|
+
bsv.SmartLedger = {
|
|
157
|
+
version: bsv.version,
|
|
158
|
+
hardenedBy: bsv.hardenedBy,
|
|
159
|
+
baseVersion: bsv.baseVersion,
|
|
160
|
+
securityFeatures: bsv.securityFeatures,
|
|
161
|
+
SmartVerify: bsv.crypto.SmartVerify,
|
|
162
|
+
EllipticFixed: bsv.crypto.EllipticFixed
|
|
163
|
+
}
|
|
164
|
+
bsv.SmartVerify = bsv.crypto.SmartVerify
|
|
165
|
+
bsv.EllipticFixed = bsv.crypto.EllipticFixed
|
|
166
|
+
|
|
167
|
+
// Internal usage, exposed for testing/advanced tweaking (matching index.js)
|
|
168
|
+
if (bsv.Transaction && bsv.Transaction.sighash === undefined) {
|
|
169
|
+
try {
|
|
170
|
+
bsv.Transaction.sighash = require('./lib/transaction/sighash')
|
|
171
|
+
} catch (e) {
|
|
172
|
+
console.warn('Transaction.sighash not available:', e.message)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Enhanced bundle information
|
|
177
|
+
bsv.bundle = {
|
|
178
|
+
version: bsv.version,
|
|
179
|
+
includes: [
|
|
180
|
+
'core-bsv',
|
|
181
|
+
'message-signing',
|
|
182
|
+
'hd-wallets',
|
|
183
|
+
'mnemonic-generation',
|
|
184
|
+
'ecies-encryption',
|
|
185
|
+
'smartledger-security',
|
|
186
|
+
'smartcontract-interface',
|
|
187
|
+
'debug-tools',
|
|
188
|
+
'covenant-interface',
|
|
189
|
+
'custom-script-helper',
|
|
190
|
+
'advanced-sighash',
|
|
191
|
+
'legal-token-protocol-ltp',
|
|
192
|
+
'global-digital-attestation-gdaf',
|
|
193
|
+
'shamir-secret-sharing'
|
|
194
|
+
],
|
|
195
|
+
size: 'complete',
|
|
196
|
+
type: 'all-in-one'
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// SmartLedger bundle namespace
|
|
200
|
+
bsv.SmartLedgerBundle = {
|
|
201
|
+
version: bsv.version,
|
|
202
|
+
hardenedBy: bsv.hardenedBy,
|
|
203
|
+
bundleIncludes: bsv.bundle.includes,
|
|
204
|
+
|
|
205
|
+
// Quick access methods
|
|
206
|
+
generateKeys: function() {
|
|
207
|
+
const privateKey = new bsv.PrivateKey()
|
|
208
|
+
return {
|
|
209
|
+
privateKey: privateKey,
|
|
210
|
+
publicKey: privateKey.toPublicKey(),
|
|
211
|
+
address: privateKey.toAddress()
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
generateMnemonic: function() {
|
|
216
|
+
if (!bsv.Mnemonic) {
|
|
217
|
+
throw new Error('Mnemonic functionality not available in bundle')
|
|
218
|
+
}
|
|
219
|
+
// Generate 24-word mnemonic by default (256-bit entropy)
|
|
220
|
+
return new bsv.Mnemonic(256)
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
createMessage: function(text) {
|
|
224
|
+
if (!bsv.Message) {
|
|
225
|
+
throw new Error('Message functionality not available in bundle')
|
|
226
|
+
}
|
|
227
|
+
return new bsv.Message(text)
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
encrypt: function(data, publicKey) {
|
|
231
|
+
if (!bsv.ECIES) {
|
|
232
|
+
throw new Error('ECIES functionality not available in bundle')
|
|
233
|
+
}
|
|
234
|
+
return bsv.ECIES.encrypt(data, publicKey)
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
// SmartContract debug tools (NEW v3.2.1)
|
|
238
|
+
examineScript: function(scriptASM) {
|
|
239
|
+
if (!bsv.SmartContract || !bsv.SmartContract.examineStack) {
|
|
240
|
+
throw new Error('SmartContract debug tools not available in bundle')
|
|
241
|
+
}
|
|
242
|
+
const script = bsv.Script.fromASM(scriptASM)
|
|
243
|
+
return bsv.SmartContract.examineStack(script)
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
interpretScript: function(scriptASM) {
|
|
247
|
+
if (!bsv.SmartContract || !bsv.SmartContract.interpretScript) {
|
|
248
|
+
throw new Error('SmartContract debug tools not available in bundle')
|
|
249
|
+
}
|
|
250
|
+
const script = bsv.Script.fromASM(scriptASM)
|
|
251
|
+
return bsv.SmartContract.interpretScript(script)
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
getScriptMetrics: function(scriptASM) {
|
|
255
|
+
if (!bsv.SmartContract || !bsv.SmartContract.getScriptMetrics) {
|
|
256
|
+
throw new Error('SmartContract metrics not available in bundle')
|
|
257
|
+
}
|
|
258
|
+
const script = bsv.Script.fromASM(scriptASM)
|
|
259
|
+
return bsv.SmartContract.getScriptMetrics(script)
|
|
260
|
+
},
|
|
261
|
+
|
|
262
|
+
optimizeScript: function(scriptASM) {
|
|
263
|
+
if (!bsv.SmartContract || !bsv.SmartContract.optimizeScript) {
|
|
264
|
+
throw new Error('SmartContract optimizer not available in bundle')
|
|
265
|
+
}
|
|
266
|
+
const script = bsv.Script.fromASM(scriptASM)
|
|
267
|
+
return bsv.SmartContract.optimizeScript(script)
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
// Covenant development (NEW v3.2.1)
|
|
271
|
+
createCovenant: function(config) {
|
|
272
|
+
if (!bsv.CovenantInterface) {
|
|
273
|
+
throw new Error('CovenantInterface not available in bundle')
|
|
274
|
+
}
|
|
275
|
+
const covenantInterface = new bsv.CovenantInterface()
|
|
276
|
+
return covenantInterface.createCovenantTransaction(config)
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
// Custom script development (NEW v3.2.1)
|
|
280
|
+
createCustomSignature: function(transaction, privateKey, inputIndex, lockingScript, satoshis, sighashType) {
|
|
281
|
+
if (!bsv.CustomScriptHelper) {
|
|
282
|
+
throw new Error('CustomScriptHelper not available in bundle')
|
|
283
|
+
}
|
|
284
|
+
return bsv.CustomScriptHelper.createSignature(transaction, privateKey, inputIndex, lockingScript, satoshis, sighashType)
|
|
285
|
+
},
|
|
286
|
+
|
|
287
|
+
// Advanced sighash access (NEW v3.2.1)
|
|
288
|
+
calculateSighash: function(transaction, sighashType, inputNumber, subscript, satoshisBN) {
|
|
289
|
+
if (!bsv.Transaction || !bsv.Transaction.sighash) {
|
|
290
|
+
throw new Error('Advanced sighash functionality not available in bundle')
|
|
291
|
+
}
|
|
292
|
+
return bsv.Transaction.sighash.sighash(transaction, sighashType, inputNumber, subscript, satoshisBN)
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
// Legal Token Protocol methods (NEW v3.3.0)
|
|
296
|
+
createRightToken: function(type, issuerDID, subjectDID, claim, privateKey, options) {
|
|
297
|
+
if (!bsv.LTP) {
|
|
298
|
+
throw new Error('Legal Token Protocol (LTP) not available in bundle')
|
|
299
|
+
}
|
|
300
|
+
return bsv.LTP.prepareRightToken(type, issuerDID, subjectDID, claim, privateKey, options)
|
|
301
|
+
},
|
|
302
|
+
|
|
303
|
+
verifyRightToken: function(token) {
|
|
304
|
+
if (!bsv.LTP) {
|
|
305
|
+
throw new Error('Legal Token Protocol (LTP) not available in bundle')
|
|
306
|
+
}
|
|
307
|
+
return bsv.LTP.prepareRightTokenVerification(token)
|
|
308
|
+
},
|
|
309
|
+
|
|
310
|
+
// GDAF identity methods (NEW v3.3.0)
|
|
311
|
+
createDID: function(publicKey) {
|
|
312
|
+
if (!bsv.GDAF) {
|
|
313
|
+
throw new Error('Global Digital Attestation Framework (GDAF) not available in bundle')
|
|
314
|
+
}
|
|
315
|
+
return bsv.GDAF.createDID(publicKey)
|
|
316
|
+
},
|
|
317
|
+
|
|
318
|
+
issueCredential: function(issuerWIF, payload) {
|
|
319
|
+
if (!bsv.GDAF) {
|
|
320
|
+
throw new Error('Global Digital Attestation Framework (GDAF) not available in bundle')
|
|
321
|
+
}
|
|
322
|
+
return bsv.GDAF.issueVC(issuerWIF, payload)
|
|
323
|
+
},
|
|
324
|
+
|
|
325
|
+
// Shamir Secret Sharing methods (NEW v3.3.0)
|
|
326
|
+
splitSecret: function(secret, n, k) {
|
|
327
|
+
if (!bsv.Shamir) {
|
|
328
|
+
throw new Error('Shamir Secret Sharing not available in bundle')
|
|
329
|
+
}
|
|
330
|
+
return bsv.Shamir.split(secret, n, k)
|
|
331
|
+
},
|
|
332
|
+
|
|
333
|
+
reconstructSecret: function(shares) {
|
|
334
|
+
if (!bsv.Shamir) {
|
|
335
|
+
throw new Error('Shamir Secret Sharing not available in bundle')
|
|
336
|
+
}
|
|
337
|
+
return bsv.Shamir.reconstruct(shares)
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
module.exports = bsv
|