smartledger-bsv 3.3.2 → 3.3.4
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 +220 -79
- package/README.md +283 -71
- package/bsv-covenant.min.js +26 -3
- package/bsv-gdaf.min.js +11 -9
- package/bsv-ltp.min.js +10 -8
- package/bsv-mnemonic.min.js +4 -4
- package/bsv-script-helper.min.js +2 -2
- package/bsv-security.min.js +3 -24
- package/bsv-shamir.min.js +2 -2
- package/bsv-smartcontract.min.js +10 -8
- package/bsv.bundle.js +9 -9
- package/bsv.min.js +10 -8
- package/build/webpack.bundle.config.js +2 -2
- package/build/webpack.config.js +2 -2
- package/build/webpack.covenant.config.js +2 -2
- package/build/webpack.gdaf.config.js +6 -43
- package/build/webpack.script-helper.config.js +2 -2
- package/build/webpack.security.config.js +2 -2
- package/build/webpack.smartcontract.config.js +2 -2
- package/bundle-entry.js +1 -341
- package/covenant-entry.js +1 -44
- package/demos/README.md +188 -0
- package/{architecture_demo.js → demos/architecture_demo.js} +2 -2
- package/demos/bsv_wallet_demo.js +242 -0
- package/{complete_ltp_demo.js → demos/complete_ltp_demo.js} +1 -1
- package/demos/debug_tools_demo.js +87 -0
- package/demos/demo_features.js +123 -0
- package/demos/easy_interface_demo.js +109 -0
- package/demos/ecies_demo.js +182 -0
- package/demos/gdaf_core_test.js +131 -0
- package/demos/gdaf_demo.js +237 -0
- package/demos/ltp_demo.js +361 -0
- package/demos/ltp_primitives_demo.js +403 -0
- package/demos/message_demo.js +209 -0
- package/demos/preimage_separation_demo.js +383 -0
- package/demos/script_helper_demo.js +289 -0
- package/demos/security_demo.js +287 -0
- package/{shamir_demo.js → demos/shamir_demo.js} +1 -1
- package/{simple_demo.js → demos/simple_demo.js} +1 -1
- package/demos/simple_p2pkh_demo.js +169 -0
- package/demos/simple_utxo_preimage_demo.js +196 -0
- package/demos/smart_contract_demo.html +1347 -0
- package/demos/smart_contract_demo.js +910 -0
- package/demos/utxo_generator_demo.js +244 -0
- package/demos/validation_pipeline_demo.js +155 -0
- package/demos/web3keys.html +740 -0
- package/docs/BUNDLE_UPDATE_SUMMARY.md +40 -0
- package/docs/DOCUMENTATION_REVIEW_REPORT.md +295 -0
- package/docs/FIX_CREATEHMAC_ISSUE.md +91 -0
- package/docs/MODULE_REFERENCE_COMPLETE.md +330 -0
- package/docs/README.md +107 -79
- package/docs/SMARTLEDGER_BSV_USAGE_ANSWERS.md +477 -0
- package/docs/SMARTLEDGER_BSV_USAGE_EXAMPLES.js +372 -0
- package/docs/SMARTLEDGER_BSV_USAGE_GUIDE.md +555 -0
- package/docs/SMART_CONTRACT_DEVELOPMENT_GUIDE.md +1459 -0
- package/docs/advanced/LEGAL_TOKEN_PROTOCOL.md +411 -0
- package/docs/advanced/SMART_CONTRACT_GUIDE.md +1255 -0
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +851 -0
- package/docs/api/LTP.md +334 -0
- package/docs/getting-started/INSTALLATION.md +410 -0
- package/docs/getting-started/QUICK_START.md +180 -0
- package/docs/migration/FROM_BSV_1_5_6.md +260 -0
- package/docs/technical/GDAF_DEVELOPER_INTERFACE.md +187 -0
- package/docs/technical/GDAF_IMPLEMENTATION_COMPLETE.md +190 -0
- package/docs/technical/SHAMIR_INTEGRATION_SUMMARY.md +165 -0
- package/docs/technical/roadmap.md +1250 -0
- package/docs/technical/trust_law.md +142 -0
- package/examples/complete_workflow_demo.js +783 -0
- package/examples/definitive_working_demo.js +261 -0
- package/examples/final_working_contracts.js +338 -0
- package/examples/smart_contract_templates.js +718 -0
- package/examples/working_smart_contracts.js +348 -0
- package/gdaf-entry.js +2 -54
- package/index.js +32 -0
- package/lib/mnemonic/pbkdf2.browser.js +69 -0
- package/lib/mnemonic/pbkdf2.js +2 -68
- package/lib/mnemonic/pbkdf2.node.js +68 -0
- package/ltp-entry.js +2 -92
- package/package.json +21 -8
- package/script-helper-entry.js +1 -49
- package/security-entry.js +1 -70
- package/shamir-entry.js +1 -173
- package/smartcontract-entry.js +1 -133
- package/tests/browser-compatibility/README.md +35 -0
- package/tests/browser-compatibility/test-cdn-vs-local.html +186 -0
- package/tests/browser-compatibility/test-pbkdf2.html +51 -0
- package/tests/test_builtin_verify.js +117 -0
- package/tests/test_debug_integration.js +71 -0
- package/tests/test_ecdsa_little.js +70 -0
- package/tests/test_smartverify_der.js +110 -0
- package/utilities/blockchain-state.js +155 -155
- package/utilities/blockchain-state.json +103293 -5244
- package/utilities/miner-simulator.js +354 -358
- package/utilities/mock-utxo-generator.js +54 -54
- package/utilities/raw-tx-examples.js +120 -122
- package/utilities/success-demo.js +104 -105
- package/utilities/transaction-examples.js +188 -188
- package/utilities/utxo-manager.js +91 -91
- package/utilities/wallet-setup.js +79 -80
- package/utilities/working-signature-demo.js +108 -110
- package/SECURITY.md +0 -75
- package/build/bsv-covenant.min.js +0 -10
- package/build/bsv-script-helper.min.js +0 -10
- package/build/bsv-security.min.js +0 -31
- package/build/bsv-smartcontract.min.js +0 -39
- package/build/bsv.bundle.js +0 -39
- package/build/bsv.min.js +0 -39
- package/validation_test.js +0 -97
- /package/docs/{ADVANCED_COVENANT_DEVELOPMENT.md → advanced/ADVANCED_COVENANT_DEVELOPMENT.md} +0 -0
- /package/docs/{CUSTOM_SCRIPT_DEVELOPMENT.md → advanced/CUSTOM_SCRIPT_DEVELOPMENT.md} +0 -0
- /package/docs/{block.md → api/BLOCKS.md} +0 -0
- /package/docs/{ecies.md → api/ECIES.md} +0 -0
- /package/docs/{networks.md → api/NETWORKS.md} +0 -0
- /package/docs/{script.md → api/SCRIPTS.md} +0 -0
- /package/docs/{transaction.md → api/TRANSACTIONS.md} +0 -0
- /package/docs/{unspentoutput.md → api/UTXO.md} +0 -0
- /package/{test_shamir.js → tests/test_shamir.js} +0 -0
- /package/{test_standalone_shamir.html → tests/test_standalone_shamir.html} +0 -0
package/ltp-entry.js
CHANGED
|
@@ -1,92 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* This entry point provides the complete Legal Token Protocol framework
|
|
5
|
-
* as a standalone module for browser and Node.js environments.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Complete LTP primitives-only architecture
|
|
9
|
-
* - Legal claim validation and attestation
|
|
10
|
-
* - Right and obligation token management
|
|
11
|
-
* - Cryptographic proof generation
|
|
12
|
-
* - Registry and blockchain anchoring preparation
|
|
13
|
-
* - Full W3C compatibility and legal compliance
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
const bsv = require('./index.js')
|
|
17
|
-
|
|
18
|
-
// Export LTP functionality as standalone module
|
|
19
|
-
module.exports = {
|
|
20
|
-
// Core BSV functionality needed for LTP
|
|
21
|
-
PrivateKey: bsv.PrivateKey,
|
|
22
|
-
PublicKey: bsv.PublicKey,
|
|
23
|
-
Address: bsv.Address,
|
|
24
|
-
Transaction: bsv.Transaction,
|
|
25
|
-
Script: bsv.Script,
|
|
26
|
-
crypto: bsv.crypto,
|
|
27
|
-
|
|
28
|
-
// Complete LTP framework
|
|
29
|
-
LTP: bsv.LTP,
|
|
30
|
-
|
|
31
|
-
// Right Token Primitives
|
|
32
|
-
prepareRightToken: bsv.prepareRightToken,
|
|
33
|
-
prepareRightTokenVerification: bsv.prepareRightTokenVerification,
|
|
34
|
-
prepareRightTokenTransfer: bsv.prepareRightTokenTransfer,
|
|
35
|
-
prepareRightTypeValidation: bsv.prepareRightTypeValidation,
|
|
36
|
-
|
|
37
|
-
// Obligation Token Primitives
|
|
38
|
-
prepareObligationToken: bsv.prepareObligationToken,
|
|
39
|
-
prepareObligationVerification: bsv.prepareObligationVerification,
|
|
40
|
-
prepareObligationFulfillment: bsv.prepareObligationFulfillment,
|
|
41
|
-
prepareObligationBreachAssessment: bsv.prepareObligationBreachAssessment,
|
|
42
|
-
prepareObligationMonitoringReport: bsv.prepareObligationMonitoringReport,
|
|
43
|
-
|
|
44
|
-
// Claim Validation Primitives
|
|
45
|
-
prepareClaimValidation: bsv.prepareClaimValidation,
|
|
46
|
-
prepareClaimAttestation: bsv.prepareClaimAttestation,
|
|
47
|
-
prepareClaimDispute: bsv.prepareClaimDispute,
|
|
48
|
-
prepareBulkClaimValidation: bsv.prepareBulkClaimValidation,
|
|
49
|
-
prepareClaimTemplate: bsv.prepareClaimTemplate,
|
|
50
|
-
|
|
51
|
-
// Proof Generation Primitives
|
|
52
|
-
prepareSignatureProof: bsv.prepareSignatureProof,
|
|
53
|
-
prepareSignatureVerification: bsv.prepareSignatureVerification,
|
|
54
|
-
prepareSelectiveDisclosure: bsv.prepareSelectiveDisclosure,
|
|
55
|
-
prepareSelectiveDisclosureVerification: bsv.prepareSelectiveDisclosureVerification,
|
|
56
|
-
prepareLegalValidityProof: bsv.prepareLegalValidityProof,
|
|
57
|
-
prepareZeroKnowledgeProof: bsv.prepareZeroKnowledgeProof,
|
|
58
|
-
|
|
59
|
-
// Registry Management Primitives
|
|
60
|
-
prepareRegistry: bsv.prepareRegistry,
|
|
61
|
-
prepareTokenRegistration: bsv.prepareTokenRegistration,
|
|
62
|
-
prepareTokenApproval: bsv.prepareTokenApproval,
|
|
63
|
-
prepareTokenRevocation: bsv.prepareTokenRevocation,
|
|
64
|
-
prepareTokenStatusQuery: bsv.prepareTokenStatusQuery,
|
|
65
|
-
prepareTokenSearch: bsv.prepareTokenSearch,
|
|
66
|
-
prepareStatisticsQuery: bsv.prepareStatisticsQuery,
|
|
67
|
-
prepareAuditLogQuery: bsv.prepareAuditLogQuery,
|
|
68
|
-
|
|
69
|
-
// Blockchain Anchoring Primitives
|
|
70
|
-
prepareTokenCommitment: bsv.prepareTokenCommitment,
|
|
71
|
-
prepareBatchCommitment: bsv.prepareBatchCommitment,
|
|
72
|
-
verifyTokenAnchor: bsv.verifyTokenAnchor,
|
|
73
|
-
formatRevocation: bsv.formatRevocation,
|
|
74
|
-
|
|
75
|
-
// Utility Functions
|
|
76
|
-
getRightTypes: bsv.getRightTypes,
|
|
77
|
-
getObligationTypes: bsv.getObligationTypes,
|
|
78
|
-
getObligationPriority: bsv.getObligationPriority,
|
|
79
|
-
getObligationStatus: bsv.getObligationStatus,
|
|
80
|
-
getClaimSchemas: bsv.getClaimSchemas,
|
|
81
|
-
getClaimSchemaNames: bsv.getClaimSchemaNames,
|
|
82
|
-
getClaimSchema: bsv.getClaimSchema,
|
|
83
|
-
createClaimTemplate: bsv.createClaimTemplate,
|
|
84
|
-
canonicalizeClaim: bsv.canonicalizeClaim,
|
|
85
|
-
hashClaim: bsv.hashClaim,
|
|
86
|
-
addCustomClaimSchema: bsv.addCustomClaimSchema,
|
|
87
|
-
|
|
88
|
-
// Version and metadata
|
|
89
|
-
version: '3.3.0',
|
|
90
|
-
framework: 'Legal Token Protocol',
|
|
91
|
-
architecture: 'primitives-only'
|
|
92
|
-
}
|
|
1
|
+
// LTP module placeholder - will be implemented in future release
|
|
2
|
+
module.exports = require('./lib/smart_contract');
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smartledger-bsv",
|
|
3
|
-
"version": "3.3.
|
|
4
|
-
"description": "🚀 Complete Bitcoin SV development framework with Legal Token Protocol (LTP), Global Digital Attestation Framework (GDAF), Shamir Secret Sharing, and
|
|
3
|
+
"version": "3.3.4",
|
|
4
|
+
"description": "🚀 Complete Bitcoin SV development framework with Legal Token Protocol (LTP), Global Digital Attestation Framework (GDAF), Shamir Secret Sharing, and 12 flexible loading options. Includes primitives-only architecture for maximum integration flexibility, SmartContract framework, covenant builder, and comprehensive Bitcoin SV API. Perfect for legal tokens, 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",
|
|
7
7
|
"bugs": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"main": "index.js",
|
|
11
11
|
"scripts": {
|
|
12
12
|
"lint": "standard",
|
|
13
|
-
"test": "
|
|
13
|
+
"test": "mocha",
|
|
14
14
|
"test:ltp": "node complete_ltp_demo.js",
|
|
15
15
|
"test:ltp-primitives": "node simple_demo.js",
|
|
16
16
|
"test:architecture": "node architecture_demo.js",
|
|
@@ -21,12 +21,27 @@
|
|
|
21
21
|
"test:basic": "node examples/basic/transaction-creation.js",
|
|
22
22
|
"test:all": "npm test && npm run test:covenants && npm run test:scripts",
|
|
23
23
|
"coverage": "nyc --reporter=text npm run test",
|
|
24
|
+
"demo": "node demos/smart_contract_demo.js",
|
|
25
|
+
"demo:web": "echo '🌐 Open demos/smart_contract_demo.html in your browser'",
|
|
26
|
+
"demo:basics": "node demos/smart_contract_demo.js --feature basics",
|
|
27
|
+
"demo:covenant": "node demos/smart_contract_demo.js --feature covenant",
|
|
28
|
+
"demo:preimage": "node demos/smart_contract_demo.js --feature preimage",
|
|
29
|
+
"demo:utxo": "node demos/smart_contract_demo.js --feature utxo",
|
|
30
|
+
"demo:scripts": "node demos/smart_contract_demo.js --feature scripts",
|
|
31
|
+
"demo:legacy": "npm run test:covenants",
|
|
32
|
+
"demo:legacy:basic": "npm run test:basic",
|
|
33
|
+
"demo:legacy:scripts": "npm run test:scripts",
|
|
34
|
+
"demo:legacy:preimage": "echo '🧠 BIP-143 Preimage Extractor Demo' && node examples/preimage/extract_preimage_bidirectional.js",
|
|
35
|
+
"smart-contracts": "node examples/smart_contract_templates.js",
|
|
36
|
+
"smart-contracts:working": "node examples/final_working_contracts.js",
|
|
37
|
+
"workflow": "node examples/complete_workflow_demo.js",
|
|
24
38
|
"build-bsv": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack index.js --config build/webpack.config.js",
|
|
25
39
|
"build-ecies": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack ecies/index.js --config build/webpack.subproject.config.js --output-library bsvEcies -o bsv-ecies.min.js",
|
|
26
40
|
"build-message": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack message/index.js --config build/webpack.subproject.config.js --output-library bsvMessage -o bsv-message.min.js",
|
|
27
41
|
"build-mnemonic": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack mnemonic/index.js --config build/webpack.subproject.config.js --output-library bsvMnemonic -o bsv-mnemonic.min.js",
|
|
28
42
|
"build-shamir": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack shamir-entry.js --config build/webpack.subproject.config.js --output-library bsvShamir -o bsv-shamir.min.js",
|
|
29
43
|
"build-ltp": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack ltp-entry.js --config build/webpack.ltp.config.js",
|
|
44
|
+
"build-gdaf": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack gdaf-entry.js --config build/webpack.gdaf.config.js",
|
|
30
45
|
"build-smartcontract": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack smartcontract-entry.js --config build/webpack.smartcontract.config.js",
|
|
31
46
|
"build-covenant": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack covenant-entry.js --config build/webpack.covenant.config.js",
|
|
32
47
|
"build-script-helper": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack script-helper-entry.js --config build/webpack.script-helper.config.js",
|
|
@@ -34,13 +49,10 @@
|
|
|
34
49
|
"build-bundle": "NODE_OPTIONS=\"--openssl-legacy-provider\" webpack bundle-entry.js --config build/webpack.bundle.config.js",
|
|
35
50
|
"build": "npm run build-bsv && npm run build-ecies && npm run build-message && npm run build-mnemonic && npm run build-shamir && npm run build-smartcontract",
|
|
36
51
|
"build-specialized": "npm run build-covenant && npm run build-script-helper && npm run build-security",
|
|
37
|
-
"build-
|
|
52
|
+
"build-advanced": "npm run build-ltp && npm run build-gdaf",
|
|
53
|
+
"build-all": "npm run build && npm run build-bundle && npm run build-specialized && npm run build-advanced",
|
|
38
54
|
"test:browser": "echo 'Open tests/standalone-modules-test.html in browser for comprehensive testing'",
|
|
39
55
|
"test:bundle": "echo 'Open tests/bundle-completeness-test.html in browser to verify bundle completeness'",
|
|
40
|
-
"demo": "npm run test:covenants",
|
|
41
|
-
"demo:basic": "npm run test:basic",
|
|
42
|
-
"demo:scripts": "npm run test:scripts",
|
|
43
|
-
"demo:preimage": "echo '🧠 BIP-143 Preimage Extractor Demo' && node examples/preimage/extract_preimage_bidirectional.js",
|
|
44
56
|
"preimage:extract": "node examples/preimage/extract_preimage_bidirectional.js",
|
|
45
57
|
"prepublishOnly": "NODE_OPTIONS=\"--openssl-legacy-provider\" npm run build"
|
|
46
58
|
},
|
|
@@ -78,6 +90,7 @@
|
|
|
78
90
|
"architecture_demo.js",
|
|
79
91
|
"test_standalone_shamir.html",
|
|
80
92
|
"docs/",
|
|
93
|
+
"demos/",
|
|
81
94
|
"examples/",
|
|
82
95
|
"LICENSE",
|
|
83
96
|
"README.md",
|
package/script-helper-entry.js
CHANGED
|
@@ -1,49 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* SmartLedger BSV Custom Script Helper - Standalone Module
|
|
3
|
-
*
|
|
4
|
-
* Simplified API for custom script development and signing
|
|
5
|
-
* Requires main BSV library to be loaded first.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* <script src="bsv.min.js"></script>
|
|
9
|
-
* <script src="bsv-script-helper.min.js"></script>
|
|
10
|
-
* <script>
|
|
11
|
-
* const sig = bsvScriptHelper.createSignature(tx, key, 0, script, sats);
|
|
12
|
-
* </script>
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
'use strict'
|
|
16
|
-
|
|
17
|
-
// Verify BSV library is available
|
|
18
|
-
if (typeof bsv === 'undefined') {
|
|
19
|
-
throw new Error('CustomScriptHelper requires BSV library. Load bsv.min.js first.');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Load CustomScriptHelper
|
|
23
|
-
const CustomScriptHelper = require('./lib/custom-script-helper.js');
|
|
24
|
-
|
|
25
|
-
// Browser compatibility
|
|
26
|
-
if (typeof window !== 'undefined') {
|
|
27
|
-
window.bsvScriptHelper = {
|
|
28
|
-
CustomScriptHelper: CustomScriptHelper,
|
|
29
|
-
createSignature: CustomScriptHelper.createSignature,
|
|
30
|
-
verifySignature: CustomScriptHelper.verifySignature,
|
|
31
|
-
createMultisigSignature: CustomScriptHelper.createMultisigSignature,
|
|
32
|
-
version: bsv.version || 'unknown'
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// Also attach to main bsv object if available
|
|
36
|
-
if (typeof bsv !== 'undefined') {
|
|
37
|
-
bsv.CustomScriptHelper = CustomScriptHelper;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
console.log('CustomScriptHelper standalone module loaded');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
module.exports = {
|
|
44
|
-
CustomScriptHelper: CustomScriptHelper,
|
|
45
|
-
createSignature: CustomScriptHelper.createSignature,
|
|
46
|
-
verifySignature: CustomScriptHelper.verifySignature,
|
|
47
|
-
createMultisigSignature: CustomScriptHelper.createMultisigSignature,
|
|
48
|
-
version: bsv.version || 'unknown'
|
|
49
|
-
};
|
|
1
|
+
module.exports = require('./lib/custom-script-helper');
|
package/security-entry.js
CHANGED
|
@@ -1,70 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* SmartLedger BSV Security Module - Standalone Module
|
|
3
|
-
*
|
|
4
|
-
* SmartLedger security enhancements and elliptic curve fixes
|
|
5
|
-
* Can be used standalone or with main BSV library.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* <script src="bsv-security.min.js"></script>
|
|
9
|
-
* <script>
|
|
10
|
-
* const verified = bsvSecurity.SmartVerify.verify(sig, hash, pubkey);
|
|
11
|
-
* </script>
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
'use strict'
|
|
15
|
-
|
|
16
|
-
// Load security modules
|
|
17
|
-
const SmartVerify = require('./lib/crypto/smartledger_verify');
|
|
18
|
-
const EllipticFixed = require('./lib/crypto/elliptic-fixed');
|
|
19
|
-
|
|
20
|
-
// Browser compatibility
|
|
21
|
-
if (typeof window !== 'undefined') {
|
|
22
|
-
window.bsvSecurity = {
|
|
23
|
-
SmartVerify: SmartVerify,
|
|
24
|
-
EllipticFixed: EllipticFixed,
|
|
25
|
-
SmartLedger: {
|
|
26
|
-
version: 'v3.2.1',
|
|
27
|
-
hardenedBy: 'SmartLedger',
|
|
28
|
-
baseVersion: 'v1.5.6',
|
|
29
|
-
securityFeatures: [
|
|
30
|
-
'canonical-signatures',
|
|
31
|
-
'malleability-protection',
|
|
32
|
-
'enhanced-validation',
|
|
33
|
-
'elliptic-patches'
|
|
34
|
-
],
|
|
35
|
-
SmartVerify: SmartVerify,
|
|
36
|
-
EllipticFixed: EllipticFixed
|
|
37
|
-
},
|
|
38
|
-
version: 'v3.2.1'
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// Also attach to main bsv object if available
|
|
42
|
-
if (typeof bsv !== 'undefined') {
|
|
43
|
-
bsv.SmartVerify = SmartVerify;
|
|
44
|
-
bsv.EllipticFixed = EllipticFixed;
|
|
45
|
-
if (!bsv.SmartLedger) {
|
|
46
|
-
bsv.SmartLedger = window.bsvSecurity.SmartLedger;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
console.log('SmartLedger Security standalone module loaded');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
module.exports = {
|
|
54
|
-
SmartVerify: SmartVerify,
|
|
55
|
-
EllipticFixed: EllipticFixed,
|
|
56
|
-
SmartLedger: {
|
|
57
|
-
version: 'v3.2.1',
|
|
58
|
-
hardenedBy: 'SmartLedger',
|
|
59
|
-
baseVersion: 'v1.5.6',
|
|
60
|
-
securityFeatures: [
|
|
61
|
-
'canonical-signatures',
|
|
62
|
-
'malleability-protection',
|
|
63
|
-
'enhanced-validation',
|
|
64
|
-
'elliptic-patches'
|
|
65
|
-
],
|
|
66
|
-
SmartVerify: SmartVerify,
|
|
67
|
-
EllipticFixed: EllipticFixed
|
|
68
|
-
},
|
|
69
|
-
version: 'v3.2.1'
|
|
70
|
-
};
|
|
1
|
+
module.exports = require('./lib/smartminer');
|
package/shamir-entry.js
CHANGED
|
@@ -1,173 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* BSV Shamir Secret Sharing - Standalone Module
|
|
5
|
-
* Secure secret distribution using Shamir's Secret Sharing algorithm
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* // Split a secret into shares
|
|
9
|
-
* var shares = bsvShamir.split('my secret', 3, 5) // 3-of-5 threshold
|
|
10
|
-
*
|
|
11
|
-
* // Reconstruct secret from shares
|
|
12
|
-
* var secret = bsvShamir.combine(shares.slice(0, 3))
|
|
13
|
-
*
|
|
14
|
-
* Features:
|
|
15
|
-
* - Cryptographically secure threshold secret sharing
|
|
16
|
-
* - Support for any threshold (k) and total shares (n) where k <= n
|
|
17
|
-
* - Handles arbitrary secret sizes through chunking
|
|
18
|
-
* - Share verification and integrity checking
|
|
19
|
-
* - Compatible with BSV cryptographic ecosystem
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
// Initialize dependencies for browser compatibility
|
|
23
|
-
var deps = {}
|
|
24
|
-
try {
|
|
25
|
-
deps.bnjs = require('bn.js')
|
|
26
|
-
deps.Buffer = (typeof Buffer !== 'undefined') ? Buffer : null
|
|
27
|
-
} catch (e) {
|
|
28
|
-
// Browser environment - dependencies should be available globally
|
|
29
|
-
if (typeof window !== 'undefined') {
|
|
30
|
-
deps.bnjs = window.BN || (window.bsv && window.bsv.deps && window.bsv.deps.bnjs)
|
|
31
|
-
deps.Buffer = window.Buffer || (window.bsv && window.bsv.deps && window.bsv.deps.Buffer)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Ensure we have required dependencies
|
|
36
|
-
if (!deps.bnjs) {
|
|
37
|
-
throw new Error('BN.js dependency not found. Please include bn.js or bsv.min.js')
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (!deps.Buffer) {
|
|
41
|
-
// Provide minimal Buffer polyfill for basic operations
|
|
42
|
-
deps.Buffer = {
|
|
43
|
-
isBuffer: function(obj) { return obj && obj.constructor && obj.constructor.name === 'Buffer' },
|
|
44
|
-
from: function(data, encoding) {
|
|
45
|
-
if (typeof data === 'string') {
|
|
46
|
-
if (encoding === 'hex') {
|
|
47
|
-
return new Uint8Array(data.match(/.{2}/g).map(byte => parseInt(byte, 16)))
|
|
48
|
-
}
|
|
49
|
-
return new Uint8Array(Array.from(data).map(c => c.charCodeAt(0)))
|
|
50
|
-
}
|
|
51
|
-
return new Uint8Array(data)
|
|
52
|
-
},
|
|
53
|
-
concat: function(arrays) {
|
|
54
|
-
var totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0)
|
|
55
|
-
var result = new Uint8Array(totalLength)
|
|
56
|
-
var offset = 0
|
|
57
|
-
for (var i = 0; i < arrays.length; i++) {
|
|
58
|
-
result.set(arrays[i], offset)
|
|
59
|
-
offset += arrays[i].length
|
|
60
|
-
}
|
|
61
|
-
return result
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Import the core Shamir implementation
|
|
67
|
-
var Shamir = require('./lib/crypto/shamir')
|
|
68
|
-
|
|
69
|
-
// Create standalone module interface
|
|
70
|
-
var bsvShamir = {
|
|
71
|
-
/**
|
|
72
|
-
* Split a secret into threshold shares
|
|
73
|
-
* @param {String|Buffer} secret - Secret to split
|
|
74
|
-
* @param {Number} threshold - Minimum shares needed to reconstruct
|
|
75
|
-
* @param {Number} shares - Total shares to generate
|
|
76
|
-
* @returns {Array} Array of share objects
|
|
77
|
-
*/
|
|
78
|
-
split: function(secret, threshold, shares) {
|
|
79
|
-
return Shamir.split(secret, threshold, shares)
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Combine shares to reconstruct secret
|
|
84
|
-
* @param {Array} shares - Array of share objects
|
|
85
|
-
* @returns {Buffer} Reconstructed secret
|
|
86
|
-
*/
|
|
87
|
-
combine: function(shares) {
|
|
88
|
-
return Shamir.combine(shares)
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Verify if a share is valid
|
|
93
|
-
* @param {Object} share - Share to verify
|
|
94
|
-
* @returns {Boolean} True if valid
|
|
95
|
-
*/
|
|
96
|
-
verifyShare: function(share) {
|
|
97
|
-
return Shamir.verifyShare(share)
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Generate test vectors for validation
|
|
102
|
-
* @returns {Object} Test data with secret, shares, and reconstruction
|
|
103
|
-
*/
|
|
104
|
-
generateTestVectors: function() {
|
|
105
|
-
return Shamir.generateTestVectors()
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Create a simple demo showing basic usage
|
|
110
|
-
* @returns {Object} Demo results
|
|
111
|
-
*/
|
|
112
|
-
demo: function() {
|
|
113
|
-
console.log('=== BSV Shamir Secret Sharing Demo ===')
|
|
114
|
-
|
|
115
|
-
var originalSecret = 'Bitcoin SV is the original Bitcoin!'
|
|
116
|
-
var threshold = 3
|
|
117
|
-
var totalShares = 5
|
|
118
|
-
|
|
119
|
-
console.log('Original secret:', originalSecret)
|
|
120
|
-
console.log('Creating', totalShares, 'shares with threshold of', threshold)
|
|
121
|
-
|
|
122
|
-
// Split the secret
|
|
123
|
-
var shares = bsvShamir.split(originalSecret, threshold, totalShares)
|
|
124
|
-
console.log('Generated', shares.length, 'shares')
|
|
125
|
-
|
|
126
|
-
// Show first share structure (truncated for display)
|
|
127
|
-
var displayShare = JSON.parse(JSON.stringify(shares[0]))
|
|
128
|
-
if (displayShare.chunks && displayShare.chunks.length > 0) {
|
|
129
|
-
displayShare.chunks = displayShare.chunks.slice(0, 1) // Show only first chunk
|
|
130
|
-
displayShare.chunks[0].y = displayShare.chunks[0].y.substring(0, 20) + '...'
|
|
131
|
-
}
|
|
132
|
-
console.log('Sample share structure:', displayShare)
|
|
133
|
-
|
|
134
|
-
// Reconstruct with minimum shares
|
|
135
|
-
var minShares = shares.slice(0, threshold)
|
|
136
|
-
var reconstructed = bsvShamir.combine(minShares)
|
|
137
|
-
var reconstructedSecret = reconstructed.toString('utf8')
|
|
138
|
-
|
|
139
|
-
console.log('Reconstructed secret:', reconstructedSecret)
|
|
140
|
-
console.log('Reconstruction successful:', originalSecret === reconstructedSecret)
|
|
141
|
-
|
|
142
|
-
return {
|
|
143
|
-
original: originalSecret,
|
|
144
|
-
threshold: threshold,
|
|
145
|
-
totalShares: totalShares,
|
|
146
|
-
shares: shares,
|
|
147
|
-
reconstructed: reconstructedSecret,
|
|
148
|
-
success: originalSecret === reconstructedSecret
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
// Expose version and metadata
|
|
153
|
-
version: '3.2.2',
|
|
154
|
-
algorithm: 'Shamir Secret Sharing',
|
|
155
|
-
description: 'Threshold cryptography for secure secret distribution'
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Browser compatibility
|
|
159
|
-
if (typeof window !== 'undefined') {
|
|
160
|
-
window.bsvShamir = bsvShamir
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Node.js compatibility
|
|
164
|
-
if (typeof module !== 'undefined' && module.exports) {
|
|
165
|
-
module.exports = bsvShamir
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// AMD compatibility
|
|
169
|
-
if (typeof define === 'function' && define.amd) {
|
|
170
|
-
define(function() {
|
|
171
|
-
return bsvShamir
|
|
172
|
-
})
|
|
173
|
-
}
|
|
1
|
+
module.exports = require('./lib/crypto/shamir');
|
package/smartcontract-entry.js
CHANGED
|
@@ -1,133 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* SmartLedger BSV - SmartContract Interface
|
|
3
|
-
*
|
|
4
|
-
* Standalone SmartContract interface with debug tools for browser use.
|
|
5
|
-
* This module provides the complete SmartContract development framework
|
|
6
|
-
* including covenant builders, script debuggers, and testing tools.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* <script src="bsv.min.js"></script>
|
|
10
|
-
* <script src="bsv-smartcontract.min.js"></script>
|
|
11
|
-
* <script>
|
|
12
|
-
* // SmartContract interface available under bsv.SmartContract
|
|
13
|
-
* const script = bsv.Script.fromASM('OP_1 OP_2 OP_ADD');
|
|
14
|
-
* const result = bsv.SmartContract.examineStack(script);
|
|
15
|
-
* const metrics = bsv.SmartContract.getScriptMetrics(script);
|
|
16
|
-
* </script>
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
'use strict'
|
|
20
|
-
|
|
21
|
-
// Check if BSV library is available
|
|
22
|
-
if (typeof window !== 'undefined' && typeof window.bsv === 'undefined') {
|
|
23
|
-
throw new Error('SmartContract interface requires BSV library. Load bsv.min.js first.')
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Get BSV reference (works in both Node.js and browser)
|
|
27
|
-
var bsv = (typeof window !== 'undefined') ? window.bsv : require('./index.js')
|
|
28
|
-
|
|
29
|
-
if (!bsv) {
|
|
30
|
-
throw new Error('BSV library not found. Ensure bsv.min.js is loaded before bsv-smartcontract.min.js')
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Load SmartContract interface
|
|
34
|
-
var SmartContract
|
|
35
|
-
try {
|
|
36
|
-
SmartContract = require('./lib/smart_contract')
|
|
37
|
-
} catch (e) {
|
|
38
|
-
throw new Error('SmartContract module not found: ' + e.message)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Attach to BSV library
|
|
42
|
-
bsv.SmartContract = SmartContract
|
|
43
|
-
|
|
44
|
-
// Make available globally for browser usage
|
|
45
|
-
if (typeof window !== 'undefined') {
|
|
46
|
-
window.bsvSmartContract = SmartContract
|
|
47
|
-
|
|
48
|
-
// Also ensure it's on the global bsv object
|
|
49
|
-
if (window.bsv) {
|
|
50
|
-
window.bsv.SmartContract = SmartContract
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Add debug tools information
|
|
55
|
-
if (SmartContract) {
|
|
56
|
-
SmartContract.version = bsv.version || '3.2.1'
|
|
57
|
-
SmartContract.standalone = true
|
|
58
|
-
SmartContract.debugToolsAvailable = {
|
|
59
|
-
examineStack: !!SmartContract.examineStack,
|
|
60
|
-
interpretScript: !!SmartContract.interpretScript,
|
|
61
|
-
getScriptMetrics: !!SmartContract.getScriptMetrics,
|
|
62
|
-
optimizeScript: !!SmartContract.optimizeScript
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Convenience method to check if debug tools are working
|
|
66
|
-
SmartContract.testDebugTools = function() {
|
|
67
|
-
try {
|
|
68
|
-
if (!bsv.Script) {
|
|
69
|
-
return { success: false, error: 'BSV Script class not available' }
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const testScript = bsv.Script.fromASM('OP_1 OP_2 OP_ADD')
|
|
73
|
-
const results = {}
|
|
74
|
-
|
|
75
|
-
if (SmartContract.examineStack) {
|
|
76
|
-
try {
|
|
77
|
-
results.examineStack = SmartContract.examineStack(testScript)
|
|
78
|
-
results.examineStackWorking = true
|
|
79
|
-
} catch (e) {
|
|
80
|
-
results.examineStackWorking = false
|
|
81
|
-
results.examineStackError = e.message
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (SmartContract.interpretScript) {
|
|
86
|
-
try {
|
|
87
|
-
results.interpretScript = SmartContract.interpretScript(testScript)
|
|
88
|
-
results.interpretScriptWorking = true
|
|
89
|
-
} catch (e) {
|
|
90
|
-
results.interpretScriptWorking = false
|
|
91
|
-
results.interpretScriptError = e.message
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (SmartContract.getScriptMetrics) {
|
|
96
|
-
try {
|
|
97
|
-
results.scriptMetrics = SmartContract.getScriptMetrics(testScript)
|
|
98
|
-
results.scriptMetricsWorking = true
|
|
99
|
-
} catch (e) {
|
|
100
|
-
results.scriptMetricsWorking = false
|
|
101
|
-
results.scriptMetricsError = e.message
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (SmartContract.optimizeScript) {
|
|
106
|
-
try {
|
|
107
|
-
results.optimizeScript = SmartContract.optimizeScript(testScript)
|
|
108
|
-
results.optimizeScriptWorking = true
|
|
109
|
-
} catch (e) {
|
|
110
|
-
results.optimizeScriptWorking = false
|
|
111
|
-
results.optimizeScriptError = e.message
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
success: true,
|
|
117
|
-
testScript: 'OP_1 OP_2 OP_ADD',
|
|
118
|
-
results: results,
|
|
119
|
-
methodCount: Object.keys(SmartContract).length
|
|
120
|
-
}
|
|
121
|
-
} catch (e) {
|
|
122
|
-
return { success: false, error: e.message }
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
console.log('SmartContract interface loaded:', !!SmartContract)
|
|
128
|
-
if (SmartContract) {
|
|
129
|
-
console.log('SmartContract methods available:', Object.keys(SmartContract).length)
|
|
130
|
-
console.log('Debug tools available:', SmartContract.debugToolsAvailable)
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
module.exports = SmartContract
|
|
1
|
+
module.exports = require('./lib/smart_contract');
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Browser Compatibility Tests
|
|
2
|
+
|
|
3
|
+
This directory contains test files for verifying browser compatibility fixes.
|
|
4
|
+
|
|
5
|
+
## Test Files
|
|
6
|
+
|
|
7
|
+
### `test-cdn-vs-local.html`
|
|
8
|
+
Comprehensive test that compares CDN bundles vs local bundles to verify the `createHmac` fix.
|
|
9
|
+
|
|
10
|
+
**Usage:**
|
|
11
|
+
1. Open in browser
|
|
12
|
+
2. Click "Test CDN Version" - should show `createHmac` error (if using unfixed CDN)
|
|
13
|
+
3. Click "Test Local Version" - should work with fixed bundles
|
|
14
|
+
4. View summary to confirm fix effectiveness
|
|
15
|
+
|
|
16
|
+
### `test-pbkdf2.html`
|
|
17
|
+
Simple test focused specifically on PBKDF2 functionality.
|
|
18
|
+
|
|
19
|
+
**Usage:**
|
|
20
|
+
1. Open in browser
|
|
21
|
+
2. Tests mnemonic generation using PBKDF2
|
|
22
|
+
3. Shows detailed error information if PBKDF2 fails
|
|
23
|
+
|
|
24
|
+
## Background
|
|
25
|
+
|
|
26
|
+
These tests were created to verify the fix for issue where CDN users experienced:
|
|
27
|
+
- `createHmac is not a function` errors
|
|
28
|
+
- Failed mnemonic generation
|
|
29
|
+
- Failed HD wallet key derivation
|
|
30
|
+
|
|
31
|
+
The fix implemented browser-compatible PBKDF2 using BSV's crypto modules instead of Node.js crypto.
|
|
32
|
+
|
|
33
|
+
## Fix Details
|
|
34
|
+
|
|
35
|
+
See `docs/FIX_CREATEHMAC_ISSUE.md` for complete technical details.
|