From f0962c9f8f73ef7a1617a9484f3429d87889da08 Mon Sep 17 00:00:00 2001 From: Dhananjay Hire Date: Sat, 21 Nov 2026 10:04:57 +0000 Subject: [PATCH 1/6] perf: drop BigInt from Keccak, share Base58 decoder; add missing tests Performance (npm run benchmark, Node 24): - ethereum validation ~3.9k/s -> ~42k/s (Keccak-f on 32-bit lane halves) - EVM detection ~3.2k/s -> ~13.8k/s - solana validation ~187k/s -> ~329k/s (typed-array Base58 decoder) - bitcoin / tron ~80k/s -> ~100k/s (hoisted SHA-256 constants) Ripple now reuses the shared Base58 decoder via createBase58Decoder instead of a duplicated copy (-230 B gzip on the ripple chunk). Tests (220 -> 275, branch coverage 91.8% -> 95.4%): - Cosmos family had no unit tests; add per-chain prefix, 20/32-byte length policy, Bech32m, padding, and operator-prefix cases - Cardano Shelley: CIP-19 pointer/enterprise vectors, pointer varint edge cases, header/prefix mismatches; fold cardano_debug test in - Network policy (network/allowTestnet/NETWORK_MISMATCH details) - Aptos formatting, Keccak block boundaries vs @noble/hashes, Base58/Base58Check error paths Tooling: test:package falls back to Playwright's bundled Chromium when system Chrome is absent. Remove stale tracked coverage/ output and old lint/command logs; fix the `.txt` gitignore entry. --- .gitignore | 2 +- commands.txt | 31 - coverage/clover.xml | 865 ------- coverage/coverage-summary.json | 18 - coverage/lcov-report/base.css | 224 -- coverage/lcov-report/block-navigation.js | 87 - .../detectors/chain-detector.ts.html | 316 --- coverage/lcov-report/detectors/index.html | 116 - coverage/lcov-report/favicon.png | Bin 445 -> 0 bytes coverage/lcov-report/formatters/index.html | 116 - coverage/lcov-report/formatters/index.ts.html | 163 -- coverage/lcov-report/index.html | 176 -- coverage/lcov-report/prettify.css | 1 - coverage/lcov-report/prettify.js | 2 - coverage/lcov-report/security/index.html | 116 - .../lcov-report/security/sanitizer.ts.html | 172 -- coverage/lcov-report/sort-arrow-sprite.png | Bin 138 -> 0 bytes coverage/lcov-report/sorter.js | 210 -- .../src/detectors/chain-detector.js.html | 181 -- .../src/detectors/chain-detector.ts.html | 190 -- coverage/lcov-report/src/detectors/index.html | 131 -- .../lcov-report/src/formatters/index.html | 131 -- .../lcov-report/src/formatters/index.js.html | 172 -- .../lcov-report/src/formatters/index.ts.html | 166 -- coverage/lcov-report/src/index.html | 131 -- coverage/lcov-report/src/index.js.html | 202 -- coverage/lcov-report/src/index.ts.html | 232 -- coverage/lcov-report/src/security/index.html | 131 -- .../src/security/sanitizer.js.html | 175 -- .../src/security/sanitizer.ts.html | 172 -- coverage/lcov-report/src/types.js.html | 142 -- coverage/lcov-report/src/types.ts.html | 205 -- coverage/lcov-report/src/utils/base58.js.html | 478 ---- coverage/lcov-report/src/utils/base58.ts.html | 517 ----- coverage/lcov-report/src/utils/bech32.js.html | 289 --- coverage/lcov-report/src/utils/bech32.ts.html | 316 --- coverage/lcov-report/src/utils/hex.js.html | 154 -- coverage/lcov-report/src/utils/hex.ts.html | 151 -- coverage/lcov-report/src/utils/index.html | 206 -- .../lcov-report/src/utils/keccak256.js.html | 1915 --------------- .../lcov-report/src/utils/keccak256.ts.html | 2053 ----------------- coverage/lcov-report/src/utils/sha256.ts.html | 385 ---- .../lcov-report/src/validators/base.js.html | 175 -- .../lcov-report/src/validators/base.ts.html | 166 -- .../src/validators/bitcoin.js.html | 430 ---- .../src/validators/bitcoin.ts.html | 385 ---- .../src/validators/ethereum.js.html | 376 --- .../src/validators/ethereum.ts.html | 385 ---- .../lcov-report/src/validators/index.html | 251 -- .../src/validators/polygon.js.html | 187 -- .../src/validators/polygon.ts.html | 121 - .../lcov-report/src/validators/solana.js.html | 280 --- .../lcov-report/src/validators/solana.ts.html | 220 -- coverage/lcov-report/utils/base58.ts.html | 517 ----- coverage/lcov-report/utils/bech32.ts.html | 316 --- coverage/lcov-report/utils/hex.ts.html | 151 -- coverage/lcov-report/utils/index.html | 146 -- coverage/lcov-report/utils/keccak256.ts.html | 2020 ---------------- coverage/lcov-report/utils/sha256.ts.html | 385 ---- coverage/lcov-report/validators/base.ts.html | 172 -- .../lcov-report/validators/bitcoin.ts.html | 385 ---- .../lcov-report/validators/cardano.ts.html | 265 --- .../lcov-report/validators/dogecoin.ts.html | 223 -- .../lcov-report/validators/ethereum.ts.html | 385 ---- coverage/lcov-report/validators/evm.ts.html | 241 -- coverage/lcov-report/validators/index.html | 251 -- .../lcov-report/validators/litecoin.ts.html | 352 --- .../lcov-report/validators/polygon.ts.html | 121 - .../lcov-report/validators/ripple.ts.html | 391 ---- .../lcov-report/validators/solana.ts.html | 220 -- coverage/lcov.info | 938 -------- final_lint_check.txt | 0 lint_output.txt | 6 - scripts/test-package.mjs | 3 +- src/utils/base58.ts | 72 +- src/utils/keccak256.ts | 107 +- src/utils/sha256.ts | 25 +- src/validators/ethereum.ts | 5 +- src/validators/ripple.ts | 57 +- tests/cardano.test.ts | 51 + tests/cardano_debug.test.ts | 5 - tests/cosmos.test.ts | 62 + tests/network-policy.test.ts | 56 + tests/utils.test.ts | 45 +- 84 files changed, 341 insertions(+), 22048 deletions(-) delete mode 100644 commands.txt delete mode 100644 coverage/clover.xml delete mode 100644 coverage/coverage-summary.json delete mode 100644 coverage/lcov-report/base.css delete mode 100644 coverage/lcov-report/block-navigation.js delete mode 100644 coverage/lcov-report/detectors/chain-detector.ts.html delete mode 100644 coverage/lcov-report/detectors/index.html delete mode 100644 coverage/lcov-report/favicon.png delete mode 100644 coverage/lcov-report/formatters/index.html delete mode 100644 coverage/lcov-report/formatters/index.ts.html delete mode 100644 coverage/lcov-report/index.html delete mode 100644 coverage/lcov-report/prettify.css delete mode 100644 coverage/lcov-report/prettify.js delete mode 100644 coverage/lcov-report/security/index.html delete mode 100644 coverage/lcov-report/security/sanitizer.ts.html delete mode 100644 coverage/lcov-report/sort-arrow-sprite.png delete mode 100644 coverage/lcov-report/sorter.js delete mode 100644 coverage/lcov-report/src/detectors/chain-detector.js.html delete mode 100644 coverage/lcov-report/src/detectors/chain-detector.ts.html delete mode 100644 coverage/lcov-report/src/detectors/index.html delete mode 100644 coverage/lcov-report/src/formatters/index.html delete mode 100644 coverage/lcov-report/src/formatters/index.js.html delete mode 100644 coverage/lcov-report/src/formatters/index.ts.html delete mode 100644 coverage/lcov-report/src/index.html delete mode 100644 coverage/lcov-report/src/index.js.html delete mode 100644 coverage/lcov-report/src/index.ts.html delete mode 100644 coverage/lcov-report/src/security/index.html delete mode 100644 coverage/lcov-report/src/security/sanitizer.js.html delete mode 100644 coverage/lcov-report/src/security/sanitizer.ts.html delete mode 100644 coverage/lcov-report/src/types.js.html delete mode 100644 coverage/lcov-report/src/types.ts.html delete mode 100644 coverage/lcov-report/src/utils/base58.js.html delete mode 100644 coverage/lcov-report/src/utils/base58.ts.html delete mode 100644 coverage/lcov-report/src/utils/bech32.js.html delete mode 100644 coverage/lcov-report/src/utils/bech32.ts.html delete mode 100644 coverage/lcov-report/src/utils/hex.js.html delete mode 100644 coverage/lcov-report/src/utils/hex.ts.html delete mode 100644 coverage/lcov-report/src/utils/index.html delete mode 100644 coverage/lcov-report/src/utils/keccak256.js.html delete mode 100644 coverage/lcov-report/src/utils/keccak256.ts.html delete mode 100644 coverage/lcov-report/src/utils/sha256.ts.html delete mode 100644 coverage/lcov-report/src/validators/base.js.html delete mode 100644 coverage/lcov-report/src/validators/base.ts.html delete mode 100644 coverage/lcov-report/src/validators/bitcoin.js.html delete mode 100644 coverage/lcov-report/src/validators/bitcoin.ts.html delete mode 100644 coverage/lcov-report/src/validators/ethereum.js.html delete mode 100644 coverage/lcov-report/src/validators/ethereum.ts.html delete mode 100644 coverage/lcov-report/src/validators/index.html delete mode 100644 coverage/lcov-report/src/validators/polygon.js.html delete mode 100644 coverage/lcov-report/src/validators/polygon.ts.html delete mode 100644 coverage/lcov-report/src/validators/solana.js.html delete mode 100644 coverage/lcov-report/src/validators/solana.ts.html delete mode 100644 coverage/lcov-report/utils/base58.ts.html delete mode 100644 coverage/lcov-report/utils/bech32.ts.html delete mode 100644 coverage/lcov-report/utils/hex.ts.html delete mode 100644 coverage/lcov-report/utils/index.html delete mode 100644 coverage/lcov-report/utils/keccak256.ts.html delete mode 100644 coverage/lcov-report/utils/sha256.ts.html delete mode 100644 coverage/lcov-report/validators/base.ts.html delete mode 100644 coverage/lcov-report/validators/bitcoin.ts.html delete mode 100644 coverage/lcov-report/validators/cardano.ts.html delete mode 100644 coverage/lcov-report/validators/dogecoin.ts.html delete mode 100644 coverage/lcov-report/validators/ethereum.ts.html delete mode 100644 coverage/lcov-report/validators/evm.ts.html delete mode 100644 coverage/lcov-report/validators/index.html delete mode 100644 coverage/lcov-report/validators/litecoin.ts.html delete mode 100644 coverage/lcov-report/validators/polygon.ts.html delete mode 100644 coverage/lcov-report/validators/ripple.ts.html delete mode 100644 coverage/lcov-report/validators/solana.ts.html delete mode 100644 coverage/lcov.info delete mode 100644 final_lint_check.txt delete mode 100644 lint_output.txt delete mode 100644 tests/cardano_debug.test.ts create mode 100644 tests/cosmos.test.ts create mode 100644 tests/network-policy.test.ts diff --git a/.gitignore b/.gitignore index 16ef528..b126573 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,6 @@ dist build_error.txt *.log .DS_Store -.txt .coverage/ *.tgz +coverage/ diff --git a/commands.txt b/commands.txt deleted file mode 100644 index 58ed1e4..0000000 --- a/commands.txt +++ /dev/null @@ -1,31 +0,0 @@ -# Testing and Coverage Commands for validator0x - -## Standard Testing -Run the entire test suite once: -```bash -npm test -``` - -Run tests in watch mode (useful during active development, only runs tests for changed files): -```bash -npm run test:watch -``` - -Run a specific test file: -```bash -npx jest tests/cardano.test.ts -``` - -Run a specific test case within a file (e.g., matching a description): -```bash -npx jest -t "should validate valid Solana address" -``` - -## Coverage Reports -Run the test suite and generate a detailed code coverage report: -```bash -npm run test:coverage -``` -This command will output a table in your terminal showing coverage for Statements, Branches, Functions, and Lines. - -**Note on viewing reports:** When you run the coverage command, Jest generates a `coverage/` directory (if configured, or outputs directly). You can often view an interactive HTML report by opening `coverage/lcov-report/index.html` in your browser. diff --git a/coverage/clover.xml b/coverage/clover.xml deleted file mode 100644 index 6ed4316..0000000 --- a/coverage/clover.xml +++ /dev/null @@ -1,865 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/coverage/coverage-summary.json b/coverage/coverage-summary.json deleted file mode 100644 index b3b8694..0000000 --- a/coverage/coverage-summary.json +++ /dev/null @@ -1,18 +0,0 @@ -{"total": {"lines":{"total":470,"covered":434,"skipped":0,"pct":92.34},"statements":{"total":498,"covered":456,"skipped":0,"pct":91.56},"functions":{"total":47,"covered":46,"skipped":0,"pct":97.87},"branches":{"total":230,"covered":194,"skipped":0,"pct":84.34},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}} -,"C:\\PC\\Codes\\validator0x\\src\\detectors\\chain-detector.ts": {"lines":{"total":30,"covered":30,"skipped":0,"pct":100},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":30,"covered":30,"skipped":0,"pct":100},"branches":{"total":30,"covered":30,"skipped":0,"pct":100}} -,"C:\\PC\\Codes\\validator0x\\src\\formatters\\index.ts": {"lines":{"total":13,"covered":13,"skipped":0,"pct":100},"functions":{"total":3,"covered":3,"skipped":0,"pct":100},"statements":{"total":14,"covered":14,"skipped":0,"pct":100},"branches":{"total":10,"covered":10,"skipped":0,"pct":100}} -,"C:\\PC\\Codes\\validator0x\\src\\security\\sanitizer.ts": {"lines":{"total":12,"covered":12,"skipped":0,"pct":100},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":12,"covered":12,"skipped":0,"pct":100},"branches":{"total":6,"covered":6,"skipped":0,"pct":100}} -,"C:\\PC\\Codes\\validator0x\\src\\utils\\base58.ts": {"lines":{"total":53,"covered":52,"skipped":0,"pct":98.11},"functions":{"total":3,"covered":3,"skipped":0,"pct":100},"statements":{"total":64,"covered":61,"skipped":0,"pct":95.31},"branches":{"total":9,"covered":7,"skipped":0,"pct":77.77}} -,"C:\\PC\\Codes\\validator0x\\src\\utils\\bech32.ts": {"lines":{"total":39,"covered":39,"skipped":0,"pct":100},"functions":{"total":5,"covered":5,"skipped":0,"pct":100},"statements":{"total":47,"covered":46,"skipped":0,"pct":97.87},"branches":{"total":17,"covered":16,"skipped":0,"pct":94.11}} -,"C:\\PC\\Codes\\validator0x\\src\\utils\\hex.ts": {"lines":{"total":10,"covered":9,"skipped":0,"pct":90},"functions":{"total":3,"covered":3,"skipped":0,"pct":100},"statements":{"total":11,"covered":9,"skipped":0,"pct":81.81},"branches":{"total":10,"covered":7,"skipped":0,"pct":70}} -,"C:\\PC\\Codes\\validator0x\\src\\validators\\base.ts": {"lines":{"total":11,"covered":10,"skipped":0,"pct":90.9},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":11,"covered":10,"skipped":0,"pct":90.9},"branches":{"total":3,"covered":2,"skipped":0,"pct":66.66}} -,"C:\\PC\\Codes\\validator0x\\src\\validators\\bitcoin.ts": {"lines":{"total":52,"covered":40,"skipped":0,"pct":76.92},"functions":{"total":4,"covered":4,"skipped":0,"pct":100},"statements":{"total":52,"covered":40,"skipped":0,"pct":76.92},"branches":{"total":30,"covered":19,"skipped":0,"pct":63.33}} -,"C:\\PC\\Codes\\validator0x\\src\\validators\\cardano.ts": {"lines":{"total":28,"covered":21,"skipped":0,"pct":75},"functions":{"total":4,"covered":3,"skipped":0,"pct":75},"statements":{"total":28,"covered":21,"skipped":0,"pct":75},"branches":{"total":19,"covered":14,"skipped":0,"pct":73.68}} -,"C:\\PC\\Codes\\validator0x\\src\\validators\\dogecoin.ts": {"lines":{"total":25,"covered":24,"skipped":0,"pct":96},"functions":{"total":2,"covered":2,"skipped":0,"pct":100},"statements":{"total":25,"covered":24,"skipped":0,"pct":96},"branches":{"total":16,"covered":16,"skipped":0,"pct":100}} -,"C:\\PC\\Codes\\validator0x\\src\\validators\\ethereum.ts": {"lines":{"total":42,"covered":39,"skipped":0,"pct":92.85},"functions":{"total":5,"covered":5,"skipped":0,"pct":100},"statements":{"total":44,"covered":40,"skipped":0,"pct":90.9},"branches":{"total":20,"covered":17,"skipped":0,"pct":85}} -,"C:\\PC\\Codes\\validator0x\\src\\validators\\evm.ts": {"lines":{"total":26,"covered":26,"skipped":0,"pct":100},"functions":{"total":5,"covered":5,"skipped":0,"pct":100},"statements":{"total":26,"covered":26,"skipped":0,"pct":100},"branches":{"total":5,"covered":5,"skipped":0,"pct":100}} -,"C:\\PC\\Codes\\validator0x\\src\\validators\\litecoin.ts": {"lines":{"total":46,"covered":36,"skipped":0,"pct":78.26},"functions":{"total":4,"covered":4,"skipped":0,"pct":100},"statements":{"total":46,"covered":36,"skipped":0,"pct":78.26},"branches":{"total":27,"covered":19,"skipped":0,"pct":70.37}} -,"C:\\PC\\Codes\\validator0x\\src\\validators\\polygon.ts": {"lines":{"total":6,"covered":6,"skipped":0,"pct":100},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":6,"covered":6,"skipped":0,"pct":100},"branches":{"total":1,"covered":1,"skipped":0,"pct":100}} -,"C:\\PC\\Codes\\validator0x\\src\\validators\\ripple.ts": {"lines":{"total":58,"covered":58,"skipped":0,"pct":100},"functions":{"total":3,"covered":3,"skipped":0,"pct":100},"statements":{"total":63,"covered":62,"skipped":0,"pct":98.41},"branches":{"total":18,"covered":17,"skipped":0,"pct":94.44}} -,"C:\\PC\\Codes\\validator0x\\src\\validators\\solana.ts": {"lines":{"total":19,"covered":19,"skipped":0,"pct":100},"functions":{"total":2,"covered":2,"skipped":0,"pct":100},"statements":{"total":19,"covered":19,"skipped":0,"pct":100},"branches":{"total":9,"covered":8,"skipped":0,"pct":88.88}} -} diff --git a/coverage/lcov-report/base.css b/coverage/lcov-report/base.css deleted file mode 100644 index f418035..0000000 --- a/coverage/lcov-report/base.css +++ /dev/null @@ -1,224 +0,0 @@ -body, html { - margin:0; padding: 0; - height: 100%; -} -body { - font-family: Helvetica Neue, Helvetica, Arial; - font-size: 14px; - color:#333; -} -.small { font-size: 12px; } -*, *:after, *:before { - -webkit-box-sizing:border-box; - -moz-box-sizing:border-box; - box-sizing:border-box; - } -h1 { font-size: 20px; margin: 0;} -h2 { font-size: 14px; } -pre { - font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; - margin: 0; - padding: 0; - -moz-tab-size: 2; - -o-tab-size: 2; - tab-size: 2; -} -a { color:#0074D9; text-decoration:none; } -a:hover { text-decoration:underline; } -.strong { font-weight: bold; } -.space-top1 { padding: 10px 0 0 0; } -.pad2y { padding: 20px 0; } -.pad1y { padding: 10px 0; } -.pad2x { padding: 0 20px; } -.pad2 { padding: 20px; } -.pad1 { padding: 10px; } -.space-left2 { padding-left:55px; } -.space-right2 { padding-right:20px; } -.center { text-align:center; } -.clearfix { display:block; } -.clearfix:after { - content:''; - display:block; - height:0; - clear:both; - visibility:hidden; - } -.fl { float: left; } -@media only screen and (max-width:640px) { - .col3 { width:100%; max-width:100%; } - .hide-mobile { display:none!important; } -} - -.quiet { - color: #7f7f7f; - color: rgba(0,0,0,0.5); -} -.quiet a { opacity: 0.7; } - -.fraction { - font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; - font-size: 10px; - color: #555; - background: #E8E8E8; - padding: 4px 5px; - border-radius: 3px; - vertical-align: middle; -} - -div.path a:link, div.path a:visited { color: #333; } -table.coverage { - border-collapse: collapse; - margin: 10px 0 0 0; - padding: 0; -} - -table.coverage td { - margin: 0; - padding: 0; - vertical-align: top; -} -table.coverage td.line-count { - text-align: right; - padding: 0 5px 0 20px; -} -table.coverage td.line-coverage { - text-align: right; - padding-right: 10px; - min-width:20px; -} - -table.coverage td span.cline-any { - display: inline-block; - padding: 0 5px; - width: 100%; -} -.missing-if-branch { - display: inline-block; - margin-right: 5px; - border-radius: 3px; - position: relative; - padding: 0 4px; - background: #333; - color: yellow; -} - -.skip-if-branch { - display: none; - margin-right: 10px; - position: relative; - padding: 0 4px; - background: #ccc; - color: white; -} -.missing-if-branch .typ, .skip-if-branch .typ { - color: inherit !important; -} -.coverage-summary { - border-collapse: collapse; - width: 100%; -} -.coverage-summary tr { border-bottom: 1px solid #bbb; } -.keyline-all { border: 1px solid #ddd; } -.coverage-summary td, .coverage-summary th { padding: 10px; } -.coverage-summary tbody { border: 1px solid #bbb; } -.coverage-summary td { border-right: 1px solid #bbb; } -.coverage-summary td:last-child { border-right: none; } -.coverage-summary th { - text-align: left; - font-weight: normal; - white-space: nowrap; -} -.coverage-summary th.file { border-right: none !important; } -.coverage-summary th.pct { } -.coverage-summary th.pic, -.coverage-summary th.abs, -.coverage-summary td.pct, -.coverage-summary td.abs { text-align: right; } -.coverage-summary td.file { white-space: nowrap; } -.coverage-summary td.pic { min-width: 120px !important; } -.coverage-summary tfoot td { } - -.coverage-summary .sorter { - height: 10px; - width: 7px; - display: inline-block; - margin-left: 0.5em; - background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; -} -.coverage-summary .sorted .sorter { - background-position: 0 -20px; -} -.coverage-summary .sorted-desc .sorter { - background-position: 0 -10px; -} -.status-line { height: 10px; } -/* yellow */ -.cbranch-no { background: yellow !important; color: #111; } -/* dark red */ -.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } -.low .chart { border:1px solid #C21F39 } -.highlighted, -.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ - background: #C21F39 !important; -} -/* medium red */ -.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } -/* light red */ -.low, .cline-no { background:#FCE1E5 } -/* light green */ -.high, .cline-yes { background:rgb(230,245,208) } -/* medium green */ -.cstat-yes { background:rgb(161,215,106) } -/* dark green */ -.status-line.high, .high .cover-fill { background:rgb(77,146,33) } -.high .chart { border:1px solid rgb(77,146,33) } -/* dark yellow (gold) */ -.status-line.medium, .medium .cover-fill { background: #f9cd0b; } -.medium .chart { border:1px solid #f9cd0b; } -/* light yellow */ -.medium { background: #fff4c2; } - -.cstat-skip { background: #ddd; color: #111; } -.fstat-skip { background: #ddd; color: #111 !important; } -.cbranch-skip { background: #ddd !important; color: #111; } - -span.cline-neutral { background: #eaeaea; } - -.coverage-summary td.empty { - opacity: .5; - padding-top: 4px; - padding-bottom: 4px; - line-height: 1; - color: #888; -} - -.cover-fill, .cover-empty { - display:inline-block; - height: 12px; -} -.chart { - line-height: 0; -} -.cover-empty { - background: white; -} -.cover-full { - border-right: none !important; -} -pre.prettyprint { - border: none !important; - padding: 0 !important; - margin: 0 !important; -} -.com { color: #999 !important; } -.ignore-none { color: #999; font-weight: normal; } - -.wrapper { - min-height: 100%; - height: auto !important; - height: 100%; - margin: 0 auto -48px; -} -.footer, .push { - height: 48px; -} diff --git a/coverage/lcov-report/block-navigation.js b/coverage/lcov-report/block-navigation.js deleted file mode 100644 index 530d1ed..0000000 --- a/coverage/lcov-report/block-navigation.js +++ /dev/null @@ -1,87 +0,0 @@ -/* eslint-disable */ -var jumpToCode = (function init() { - // Classes of code we would like to highlight in the file view - var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; - - // Elements to highlight in the file listing view - var fileListingElements = ['td.pct.low']; - - // We don't want to select elements that are direct descendants of another match - var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` - - // Selector that finds elements on the page to which we can jump - var selector = - fileListingElements.join(', ') + - ', ' + - notSelector + - missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` - - // The NodeList of matching elements - var missingCoverageElements = document.querySelectorAll(selector); - - var currentIndex; - - function toggleClass(index) { - missingCoverageElements - .item(currentIndex) - .classList.remove('highlighted'); - missingCoverageElements.item(index).classList.add('highlighted'); - } - - function makeCurrent(index) { - toggleClass(index); - currentIndex = index; - missingCoverageElements.item(index).scrollIntoView({ - behavior: 'smooth', - block: 'center', - inline: 'center' - }); - } - - function goToPrevious() { - var nextIndex = 0; - if (typeof currentIndex !== 'number' || currentIndex === 0) { - nextIndex = missingCoverageElements.length - 1; - } else if (missingCoverageElements.length > 1) { - nextIndex = currentIndex - 1; - } - - makeCurrent(nextIndex); - } - - function goToNext() { - var nextIndex = 0; - - if ( - typeof currentIndex === 'number' && - currentIndex < missingCoverageElements.length - 1 - ) { - nextIndex = currentIndex + 1; - } - - makeCurrent(nextIndex); - } - - return function jump(event) { - if ( - document.getElementById('fileSearch') === document.activeElement && - document.activeElement != null - ) { - // if we're currently focused on the search input, we don't want to navigate - return; - } - - switch (event.which) { - case 78: // n - case 74: // j - goToNext(); - break; - case 66: // b - case 75: // k - case 80: // p - goToPrevious(); - break; - } - }; -})(); -window.addEventListener('keydown', jumpToCode); diff --git a/coverage/lcov-report/detectors/chain-detector.ts.html b/coverage/lcov-report/detectors/chain-detector.ts.html deleted file mode 100644 index 201eed8..0000000 --- a/coverage/lcov-report/detectors/chain-detector.ts.html +++ /dev/null @@ -1,316 +0,0 @@ - - - - - - Code coverage report for detectors/chain-detector.ts - - - - - - - - - -
-
-

All files / detectors chain-detector.ts

-
- -
- 100% - Statements - 30/30 -
- - -
- 100% - Branches - 30/30 -
- - -
- 100% - Functions - 1/1 -
- - -
- 100% - Lines - 30/30 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78  -13x -13x -13x -13x -13x -13x -13x -  -13x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -13x -  -9x -1x -  -1x -  -  -  -  -8x -1x -1x -  -  -  -  -7x -2x -1x -  -  -  -  -6x -2x -2x -  -  -  -  -4x -1x -1x -  -  -  -  -  -3x -  -1x -1x -  -  -  -  -2x -1x -  -  -1x -  - 
import { BlockchainType } from '../types';
-import { EthereumValidator } from '../validators/ethereum';
-import { SolanaValidator } from '../validators/solana';
-import { BitcoinValidator } from '../validators/bitcoin';
-import { LitecoinValidator } from '../validators/litecoin';
-import { DogecoinValidator } from '../validators/dogecoin';
-import { CardanoValidator } from '../validators/cardano';
-import { RippleValidator } from '../validators/ripple';
- 
-const validators = {
-    ethereum: new EthereumValidator(),
-    solana: new SolanaValidator(),
-    bitcoin: new BitcoinValidator(),
-    litecoin: new LitecoinValidator(),
-    dogecoin: new DogecoinValidator(),
-    cardano: new CardanoValidator(),
-    ripple: new RippleValidator(),
-};
- 
-/**
- * Auto-detects the blockchain for an address.
- * Because EVM chains share identical formats, if it matches Ethereum,
- * it returns an array of possible matching chains.
- */
-export function detectBlockchain(address: string): BlockchainType | BlockchainType[] | null {
-    // 1. Ethereum / EVM Compatible (0x...)
-    if (address.startsWith('0x') && address.length === 42) {
-        if (validators.ethereum.validate(address).valid) {
-            // EVM ambiguity: same address is valid across all EVM networks
-            return ['ethereum', 'polygon', 'bsc', 'avalanche', 'arbitrum', 'optimism', 'base'];
-        }
-    }
- 
-    // 2. Ripple (starts with r)
-    if (address.startsWith('r') && address.length >= 25) {
-        if (validators.ripple.validate(address).valid) {
-            return 'ripple';
-        }
-    }
- 
-    // 3. Cardano (addr1, Ae2, etc)
-    if (address.startsWith('addr') || address.startsWith('stake') || address.startsWith('A') || address.startsWith('D')) {
-        if (validators.cardano.validate(address).valid) {
-            return 'cardano';
-        }
-    }
- 
-    // 4. Bitcoin (1, 3, bc1)
-    if (address.startsWith('1') || address.startsWith('3') || address.toLowerCase().startsWith('bc1')) {
-        if (validators.bitcoin.validate(address).valid) {
-            return 'bitcoin';
-        }
-    }
- 
-    // 5. Litecoin (L, M, ltc1)
-    if (address.startsWith('L') || address.startsWith('M') || address.toLowerCase().startsWith('ltc1')) {
-        if (validators.litecoin.validate(address).valid) {
-            return 'litecoin';
-        }
-    }
- 
-    // 6. Dogecoin (D, 9, A)
-    // Note: D might conflict with Cardano Byron (D), but Cardano is length > 30 usually, Dogecoin is 34.
-    if (address.startsWith('D') || address.startsWith('9') || address.startsWith('A')) {
-        // Since both DOGE and ADA might start with D / A, check Doge first if base58 length is ~25 bytes.
-        if (validators.dogecoin.validate(address).valid) {
-            return 'dogecoin';
-        }
-    }
- 
-    // 7. Solana (Base58, length 32-44)
-    if (validators.solana.validate(address).valid) {
-        return 'solana';
-    }
- 
-    return null;
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/detectors/index.html b/coverage/lcov-report/detectors/index.html deleted file mode 100644 index e82ebb6..0000000 --- a/coverage/lcov-report/detectors/index.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - Code coverage report for detectors - - - - - - - - - -
-
-

All files detectors

-
- -
- 100% - Statements - 30/30 -
- - -
- 100% - Branches - 30/30 -
- - -
- 100% - Functions - 1/1 -
- - -
- 100% - Lines - 30/30 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
chain-detector.ts -
-
100%30/30100%30/30100%1/1100%30/30
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/favicon.png b/coverage/lcov-report/favicon.png deleted file mode 100644 index c1525b811a167671e9de1fa78aab9f5c0b61cef7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 445 zcmV;u0Yd(XP))rP{nL}Ln%S7`m{0DjX9TLF* zFCb$4Oi7vyLOydb!7n&^ItCzb-%BoB`=x@N2jll2Nj`kauio%aw_@fe&*}LqlFT43 z8doAAe))z_%=P%v^@JHp3Hjhj^6*Kr_h|g_Gr?ZAa&y>wxHE99Gk>A)2MplWz2xdG zy8VD2J|Uf#EAw*bo5O*PO_}X2Tob{%bUoO2G~T`@%S6qPyc}VkhV}UifBuRk>%5v( z)x7B{I~z*k<7dv#5tC+m{km(D087J4O%+<<;K|qwefb6@GSX45wCK}Sn*> - - - - Code coverage report for formatters - - - - - - - - - -
-
-

All files formatters

-
- -
- 100% - Statements - 14/14 -
- - -
- 100% - Branches - 10/10 -
- - -
- 100% - Functions - 3/3 -
- - -
- 100% - Lines - 13/13 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
index.ts -
-
100%14/14100%10/10100%3/3100%13/13
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/formatters/index.ts.html b/coverage/lcov-report/formatters/index.ts.html deleted file mode 100644 index b2fd041..0000000 --- a/coverage/lcov-report/formatters/index.ts.html +++ /dev/null @@ -1,163 +0,0 @@ - - - - - - Code coverage report for formatters/index.ts - - - - - - - - - -
-
-

All files / formatters index.ts

-
- -
- 100% - Statements - 14/14 -
- - -
- 100% - Branches - 10/10 -
- - -
- 100% - Functions - 3/3 -
- - -
- 100% - Lines - 13/13 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27  -13x -  -13x -2x -1x -  -  -13x -3x -2x -  -  -1x -  -  -13x -2x -  -  -  -1x -1x -  -1x -  - 
import { BlockchainType } from '../types';
-import { EthereumValidator } from '../validators/ethereum';
- 
-export function shortenAddress(address: string, chars = 4): string {
-    if (!address || address.length < chars * 2 + 2) return address;
-    return `${address.slice(0, chars + 2)}...${address.slice(-chars)}`;
-}
- 
-export function normalizeAddress(address: string, blockchain: BlockchainType): string {
-    if (blockchain === 'ethereum' || blockchain === 'polygon') {
-        return address.toLowerCase();
-    }
-    // Solana and Bitcoin are case sensitive
-    return address;
-}
- 
-export function addChecksum(address: string, blockchain: BlockchainType): string {
-    if (blockchain === 'ethereum' || blockchain === 'polygon') {
-        // Use Ethereum validator's logic exposed or duplicated?
-        // Since it's utils, we can instantiate or just duplicate the simple logic.
-        // Better to use the class to ensure consistency.
-        const validator = new EthereumValidator();
-        return validator.format(address, { checksum: true });
-    }
-    return address;
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/index.html b/coverage/lcov-report/index.html deleted file mode 100644 index f39f4e7..0000000 --- a/coverage/lcov-report/index.html +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - Code coverage report for All files - - - - - - - - - -
-
-

All files

-
- -
- 91.56% - Statements - 456/498 -
- - -
- 84.34% - Branches - 194/230 -
- - -
- 97.87% - Functions - 46/47 -
- - -
- 92.34% - Lines - 434/470 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
detectors -
-
100%30/30100%30/30100%1/1100%30/30
formatters -
-
100%14/14100%10/10100%3/3100%13/13
security -
-
100%12/12100%6/6100%1/1100%12/12
utils -
-
95.08%116/12283.33%30/36100%11/1198.03%100/102
validators -
-
88.75%284/32079.72%118/14896.77%30/3189.13%279/313
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/prettify.css b/coverage/lcov-report/prettify.css deleted file mode 100644 index b317a7c..0000000 --- a/coverage/lcov-report/prettify.css +++ /dev/null @@ -1 +0,0 @@ -.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/coverage/lcov-report/prettify.js b/coverage/lcov-report/prettify.js deleted file mode 100644 index b322523..0000000 --- a/coverage/lcov-report/prettify.js +++ /dev/null @@ -1,2 +0,0 @@ -/* eslint-disable */ -window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/coverage/lcov-report/security/index.html b/coverage/lcov-report/security/index.html deleted file mode 100644 index 4458239..0000000 --- a/coverage/lcov-report/security/index.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - Code coverage report for security - - - - - - - - - -
-
-

All files security

-
- -
- 100% - Statements - 12/12 -
- - -
- 100% - Branches - 6/6 -
- - -
- 100% - Functions - 1/1 -
- - -
- 100% - Lines - 12/12 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
sanitizer.ts -
-
100%12/12100%6/6100%1/1100%12/12
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/security/sanitizer.ts.html b/coverage/lcov-report/security/sanitizer.ts.html deleted file mode 100644 index 860ca42..0000000 --- a/coverage/lcov-report/security/sanitizer.ts.html +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - Code coverage report for security/sanitizer.ts - - - - - - - - - -
-
-

All files / security sanitizer.ts

-
- -
- 100% - Statements - 12/12 -
- - -
- 100% - Branches - 6/6 -
- - -
- 100% - Functions - 1/1 -
- - -
- 100% - Lines - 12/12 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -3013x -  -13x -  -87x -2x -  -  -85x -2x -  -  -  -83x -  -  -83x -1x -  -  -  -  -82x -3x -  -  -79x -  -  - 
import { ValidationError } from '../types';
- 
-export class InputSanitizer {
-    static sanitize(input: unknown): string {
-        if (input === null || input === undefined) {
-            throw new Error(ValidationError.UNSAFE_INPUT);
-        }
- 
-        if (typeof input !== 'string') {
-            throw new Error(ValidationError.UNSAFE_INPUT);
-        }
- 
-        // Remove invisible characters and excessive whitespace
-        const trimmed = input.trim();
- 
-        // Check for excessive length (prevent DoS)
-        if (trimmed.length > 256) {
-            throw new Error(ValidationError.UNSAFE_INPUT);
-        }
- 
-        // Check for dangerous control characters
-        // eslint-disable-next-line no-control-regex
-        if (/[\x00-\x1F\x7F]/.test(trimmed)) {
-            throw new Error(ValidationError.UNSAFE_INPUT);
-        }
- 
-        return trimmed;
-    }
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/sort-arrow-sprite.png b/coverage/lcov-report/sort-arrow-sprite.png deleted file mode 100644 index 6ed68316eb3f65dec9063332d2f69bf3093bbfab..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 138 zcmeAS@N?(olHy`uVBq!ia0vp^>_9Bd!3HEZxJ@+%Qh}Z>jv*C{$p!i!8j}?a+@3A= zIAGwzjijN=FBi!|L1t?LM;Q;gkwn>2cAy-KV{dn nf0J1DIvEHQu*n~6U}x}qyky7vi4|9XhBJ7&`njxgN@xNA8m%nc diff --git a/coverage/lcov-report/sorter.js b/coverage/lcov-report/sorter.js deleted file mode 100644 index 4ed70ae..0000000 --- a/coverage/lcov-report/sorter.js +++ /dev/null @@ -1,210 +0,0 @@ -/* eslint-disable */ -var addSorting = (function() { - 'use strict'; - var cols, - currentSort = { - index: 0, - desc: false - }; - - // returns the summary table element - function getTable() { - return document.querySelector('.coverage-summary'); - } - // returns the thead element of the summary table - function getTableHeader() { - return getTable().querySelector('thead tr'); - } - // returns the tbody element of the summary table - function getTableBody() { - return getTable().querySelector('tbody'); - } - // returns the th element for nth column - function getNthColumn(n) { - return getTableHeader().querySelectorAll('th')[n]; - } - - function onFilterInput() { - const searchValue = document.getElementById('fileSearch').value; - const rows = document.getElementsByTagName('tbody')[0].children; - - // Try to create a RegExp from the searchValue. If it fails (invalid regex), - // it will be treated as a plain text search - let searchRegex; - try { - searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive - } catch (error) { - searchRegex = null; - } - - for (let i = 0; i < rows.length; i++) { - const row = rows[i]; - let isMatch = false; - - if (searchRegex) { - // If a valid regex was created, use it for matching - isMatch = searchRegex.test(row.textContent); - } else { - // Otherwise, fall back to the original plain text search - isMatch = row.textContent - .toLowerCase() - .includes(searchValue.toLowerCase()); - } - - row.style.display = isMatch ? '' : 'none'; - } - } - - // loads the search box - function addSearchBox() { - var template = document.getElementById('filterTemplate'); - var templateClone = template.content.cloneNode(true); - templateClone.getElementById('fileSearch').oninput = onFilterInput; - template.parentElement.appendChild(templateClone); - } - - // loads all columns - function loadColumns() { - var colNodes = getTableHeader().querySelectorAll('th'), - colNode, - cols = [], - col, - i; - - for (i = 0; i < colNodes.length; i += 1) { - colNode = colNodes[i]; - col = { - key: colNode.getAttribute('data-col'), - sortable: !colNode.getAttribute('data-nosort'), - type: colNode.getAttribute('data-type') || 'string' - }; - cols.push(col); - if (col.sortable) { - col.defaultDescSort = col.type === 'number'; - colNode.innerHTML = - colNode.innerHTML + ''; - } - } - return cols; - } - // attaches a data attribute to every tr element with an object - // of data values keyed by column name - function loadRowData(tableRow) { - var tableCols = tableRow.querySelectorAll('td'), - colNode, - col, - data = {}, - i, - val; - for (i = 0; i < tableCols.length; i += 1) { - colNode = tableCols[i]; - col = cols[i]; - val = colNode.getAttribute('data-value'); - if (col.type === 'number') { - val = Number(val); - } - data[col.key] = val; - } - return data; - } - // loads all row data - function loadData() { - var rows = getTableBody().querySelectorAll('tr'), - i; - - for (i = 0; i < rows.length; i += 1) { - rows[i].data = loadRowData(rows[i]); - } - } - // sorts the table using the data for the ith column - function sortByIndex(index, desc) { - var key = cols[index].key, - sorter = function(a, b) { - a = a.data[key]; - b = b.data[key]; - return a < b ? -1 : a > b ? 1 : 0; - }, - finalSorter = sorter, - tableBody = document.querySelector('.coverage-summary tbody'), - rowNodes = tableBody.querySelectorAll('tr'), - rows = [], - i; - - if (desc) { - finalSorter = function(a, b) { - return -1 * sorter(a, b); - }; - } - - for (i = 0; i < rowNodes.length; i += 1) { - rows.push(rowNodes[i]); - tableBody.removeChild(rowNodes[i]); - } - - rows.sort(finalSorter); - - for (i = 0; i < rows.length; i += 1) { - tableBody.appendChild(rows[i]); - } - } - // removes sort indicators for current column being sorted - function removeSortIndicators() { - var col = getNthColumn(currentSort.index), - cls = col.className; - - cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); - col.className = cls; - } - // adds sort indicators for current column being sorted - function addSortIndicators() { - getNthColumn(currentSort.index).className += currentSort.desc - ? ' sorted-desc' - : ' sorted'; - } - // adds event listeners for all sorter widgets - function enableUI() { - var i, - el, - ithSorter = function ithSorter(i) { - var col = cols[i]; - - return function() { - var desc = col.defaultDescSort; - - if (currentSort.index === i) { - desc = !currentSort.desc; - } - sortByIndex(i, desc); - removeSortIndicators(); - currentSort.index = i; - currentSort.desc = desc; - addSortIndicators(); - }; - }; - for (i = 0; i < cols.length; i += 1) { - if (cols[i].sortable) { - // add the click event handler on the th so users - // dont have to click on those tiny arrows - el = getNthColumn(i).querySelector('.sorter').parentElement; - if (el.addEventListener) { - el.addEventListener('click', ithSorter(i)); - } else { - el.attachEvent('onclick', ithSorter(i)); - } - } - } - } - // adds sorting functionality to the UI - return function() { - if (!getTable()) { - return; - } - cols = loadColumns(); - loadData(); - addSearchBox(); - addSortIndicators(); - enableUI(); - }; -})(); - -window.addEventListener('load', addSorting); diff --git a/coverage/lcov-report/src/detectors/chain-detector.js.html b/coverage/lcov-report/src/detectors/chain-detector.js.html deleted file mode 100644 index dac03f6..0000000 --- a/coverage/lcov-report/src/detectors/chain-detector.js.html +++ /dev/null @@ -1,181 +0,0 @@ - - - - - - Code coverage report for src/detectors/chain-detector.js - - - - - - - - - -
-
-

All files / src/detectors chain-detector.js

-
- -
- 100% - Statements - 15/15 -
- - -
- 86.66% - Branches - 13/15 -
- - -
- 100% - Functions - 1/1 -
- - -
- 100% - Lines - 15/15 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33  -6x -6x -6x -6x -6x -6x -  -  -  -  -  -  -5x -  -1x -1x -  -  -  -4x -2x -2x -  -  -  -  -2x -1x -  -1x -  - 
"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.detectBlockchain = detectBlockchain;
-var ethereum_1 = require("../validators/ethereum");
-var solana_1 = require("../validators/solana");
-var bitcoin_1 = require("../validators/bitcoin");
-var validators = {
-    ethereum: new ethereum_1.EthereumValidator(),
-    solana: new solana_1.SolanaValidator(),
-    bitcoin: new bitcoin_1.BitcoinValidator(),
-};
-function detectBlockchain(address) {
-    // 1. Ethereum/Polygon (0x...)
-    if (address.startsWith('0x') && address.length === 42) {
-        // Could be Eth or Polygon, default to Ethereum as base
-        Eif (validators.ethereum.validate(address).valid) {
-            return 'ethereum';
-        }
-    }
-    // 2. Bitcoin (1, 3, bc1)
-    if (address.startsWith('1') || address.startsWith('3') || address.toLowerCase().startsWith('bc1')) {
-        Eif (validators.bitcoin.validate(address).valid) {
-            return 'bitcoin';
-        }
-    }
-    // 3. Solana (Base58, length 32-44)
-    // Check characters - assume Base58 if mostly alphanumeric without 0, O, I, l
-    if (validators.solana.validate(address).valid) {
-        return 'solana';
-    }
-    return null;
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/detectors/chain-detector.ts.html b/coverage/lcov-report/src/detectors/chain-detector.ts.html deleted file mode 100644 index 1cef522..0000000 --- a/coverage/lcov-report/src/detectors/chain-detector.ts.html +++ /dev/null @@ -1,190 +0,0 @@ - - - - - - Code coverage report for src/detectors/chain-detector.ts - - - - - - - - - -
-
-

All files / src/detectors chain-detector.ts

-
- -
- 0% - Statements - 0/14 -
- - -
- 0% - Branches - 0/10 -
- - -
- 0% - Functions - 0/1 -
- - -
- 0% - Lines - 0/14 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import { BlockchainType } from '../types';
-import { EthereumValidator } from '../validators/ethereum';
-import { SolanaValidator } from '../validators/solana';
-import { BitcoinValidator } from '../validators/bitcoin';
- 
-const validators = {
-    ethereum: new EthereumValidator(),
-    solana: new SolanaValidator(),
-    bitcoin: new BitcoinValidator(),
-};
- 
-export function detectBlockchain(address: string): BlockchainType | null {
-    // 1. Ethereum/Polygon (0x...)
-    Iif (address.startsWith('0x') && address.length === 42) {
-        // Could be Eth or Polygon, default to Ethereum as base
-        Iif (validators.ethereum.validate(address).valid) {
-            return 'ethereum';
-        }
-    }
- 
-    // 2. Bitcoin (1, 3, bc1)
-    Iif (address.startsWith('1') || address.startsWith('3') || address.toLowerCase().startsWith('bc1')) {
-        Iif (validators.bitcoin.validate(address).valid) {
-            return 'bitcoin';
-        }
-    }
- 
-    // 3. Solana (Base58, length 32-44)
-    // Check characters - assume Base58 if mostly alphanumeric without 0, O, I, l
-    Iif (validators.solana.validate(address).valid) {
-        return 'solana';
-    }
- 
-    return null;
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/detectors/index.html b/coverage/lcov-report/src/detectors/index.html deleted file mode 100644 index ae97043..0000000 --- a/coverage/lcov-report/src/detectors/index.html +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - Code coverage report for src/detectors - - - - - - - - - -
-
-

All files src/detectors

-
- -
- 51.72% - Statements - 15/29 -
- - -
- 52% - Branches - 13/25 -
- - -
- 50% - Functions - 1/2 -
- - -
- 51.72% - Lines - 15/29 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
chain-detector.js -
-
100%15/1586.66%13/15100%1/1100%15/15
chain-detector.ts -
-
0%0/140%0/100%0/10%0/14
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/formatters/index.html b/coverage/lcov-report/src/formatters/index.html deleted file mode 100644 index 601b3d1..0000000 --- a/coverage/lcov-report/src/formatters/index.html +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - Code coverage report for src/formatters - - - - - - - - - -
-
-

All files src/formatters

-
- -
- 54.83% - Statements - 17/31 -
- - -
- 54.16% - Branches - 13/24 -
- - -
- 50% - Functions - 3/6 -
- - -
- 55.17% - Lines - 16/29 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
index.js -
-
100%17/1792.85%13/14100%3/3100%16/16
index.ts -
-
0%0/140%0/100%0/30%0/13
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/formatters/index.js.html b/coverage/lcov-report/src/formatters/index.js.html deleted file mode 100644 index 75bae20..0000000 --- a/coverage/lcov-report/src/formatters/index.js.html +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - Code coverage report for src/formatters/index.js - - - - - - - - - -
-
-

All files / src/formatters index.js

-
- -
- 100% - Statements - 17/17 -
- - -
- 92.85% - Branches - 13/14 -
- - -
- 100% - Functions - 3/3 -
- - -
- 100% - Lines - 16/16 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30  -6x -6x -6x -6x -6x -  -2x -2x -1x -1x -  -  -3x -2x -  -  -1x -  -  -2x -  -  -  -1x -1x -  -1x -  - 
"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.shortenAddress = shortenAddress;
-exports.normalizeAddress = normalizeAddress;
-exports.addChecksum = addChecksum;
-var ethereum_1 = require("../validators/ethereum");
-function shortenAddress(address, chars) {
-    Eif (chars === void 0) { chars = 4; }
-    if (!address || address.length < chars * 2 + 2)
-        return address;
-    return "".concat(address.slice(0, chars + 2), "...").concat(address.slice(-chars));
-}
-function normalizeAddress(address, blockchain) {
-    if (blockchain === 'ethereum' || blockchain === 'polygon') {
-        return address.toLowerCase();
-    }
-    // Solana and Bitcoin are case sensitive
-    return address;
-}
-function addChecksum(address, blockchain) {
-    if (blockchain === 'ethereum' || blockchain === 'polygon') {
-        // Use Ethereum validator's logic exposed or duplicated?
-        // Since it's utils, we can instantiate or just duplicate the simple logic.
-        // Better to use the class to ensure consistency.
-        var validator = new ethereum_1.EthereumValidator();
-        return validator.format(address, { checksum: true });
-    }
-    return address;
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/formatters/index.ts.html b/coverage/lcov-report/src/formatters/index.ts.html deleted file mode 100644 index 39c2d27..0000000 --- a/coverage/lcov-report/src/formatters/index.ts.html +++ /dev/null @@ -1,166 +0,0 @@ - - - - - - Code coverage report for src/formatters/index.ts - - - - - - - - - -
-
-

All files / src/formatters index.ts

-
- -
- 0% - Statements - 0/14 -
- - -
- 0% - Branches - 0/10 -
- - -
- 0% - Functions - 0/3 -
- - -
- 0% - Lines - 0/13 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import { BlockchainType, FormatOptions } from '../types';
-import { EthereumValidator } from '../validators/ethereum';
-import { stripHexPrefix, addHexPrefix } from '../utils/hex';
- 
-export function shortenAddress(address: string, chars = 4): string {
-    Iif (!address || address.length < chars * 2 + 2) return address;
-    return `${address.slice(0, chars + 2)}...${address.slice(-chars)}`;
-}
- 
-export function normalizeAddress(address: string, blockchain: BlockchainType): string {
-    Iif (blockchain === 'ethereum' || blockchain === 'polygon') {
-        return address.toLowerCase();
-    }
-    // Solana and Bitcoin are case sensitive
-    return address;
-}
- 
-export function addChecksum(address: string, blockchain: BlockchainType): string {
-    Iif (blockchain === 'ethereum' || blockchain === 'polygon') {
-        // Use Ethereum validator's logic exposed or duplicated?
-        // Since it's utils, we can instantiate or just duplicate the simple logic.
-        // Better to use the class to ensure consistency.
-        const validator = new EthereumValidator();
-        return validator.format(address, { checksum: true });
-    }
-    return address;
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/index.html b/coverage/lcov-report/src/index.html deleted file mode 100644 index 6cf1f3e..0000000 --- a/coverage/lcov-report/src/index.html +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - Code coverage report for src - - - - - - - - - -
-
-

All files src

-
- -
- 81.25% - Statements - 39/48 -
- - -
- 66.66% - Branches - 4/6 -
- - -
- 38.46% - Functions - 5/13 -
- - -
- 95% - Lines - 38/40 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
index.js -
-
74.28%26/3550%2/430%3/1092.59%25/27
types.js -
-
100%13/13100%2/266.66%2/3100%13/13
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/index.js.html b/coverage/lcov-report/src/index.js.html deleted file mode 100644 index f5c2abf..0000000 --- a/coverage/lcov-report/src/index.js.html +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - Code coverage report for src/index.js - - - - - - - - - -
-
-

All files / src index.js

-
- -
- 74.28% - Statements - 26/35 -
- - -
- 50% - Branches - 2/4 -
- - -
- 30% - Functions - 3/10 -
- - -
- 92.59% - Lines - 25/27 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40  -6x -6x -6x -6x -6x -6x -6x -6x -6x -6x -6x -6x -6x -6x -6x -6x -6x -6x -6x -  -  -  -  -  -  -22x -22x -  -  -22x -  -  -6x -6x -  -  -6x -  - 
"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.addChecksum = exports.normalizeAddress = exports.shortenAddress = exports.detectBlockchain = exports.PolygonValidator = exports.BitcoinValidator = exports.SolanaValidator = exports.EthereumValidator = void 0;
-exports.validateAddress = validateAddress;
-exports.formatAddress = formatAddress;
-var ethereum_1 = require("./validators/ethereum");
-Object.defineProperty(exports, "EthereumValidator", { enumerable: true, get: function () { return ethereum_1.EthereumValidator; } });
-var solana_1 = require("./validators/solana");
-Object.defineProperty(exports, "SolanaValidator", { enumerable: true, get: function () { return solana_1.SolanaValidator; } });
-var bitcoin_1 = require("./validators/bitcoin");
-Object.defineProperty(exports, "BitcoinValidator", { enumerable: true, get: function () { return bitcoin_1.BitcoinValidator; } });
-var polygon_1 = require("./validators/polygon");
-Object.defineProperty(exports, "PolygonValidator", { enumerable: true, get: function () { return polygon_1.PolygonValidator; } });
-var chain_detector_1 = require("./detectors/chain-detector");
-Object.defineProperty(exports, "detectBlockchain", { enumerable: true, get: function () { return chain_detector_1.detectBlockchain; } });
-var index_1 = require("./formatters/index");
-Object.defineProperty(exports, "shortenAddress", { enumerable: true, get: function () { return index_1.shortenAddress; } });
-Object.defineProperty(exports, "normalizeAddress", { enumerable: true, get: function () { return index_1.normalizeAddress; } });
-Object.defineProperty(exports, "addChecksum", { enumerable: true, get: function () { return index_1.addChecksum; } });
-var validators = {
-    ethereum: new ethereum_1.EthereumValidator(),
-    solana: new solana_1.SolanaValidator(),
-    bitcoin: new bitcoin_1.BitcoinValidator(),
-    polygon: new polygon_1.PolygonValidator(),
-};
-function validateAddress(address, blockchain, options) {
-    var validator = validators[blockchain];
-    Iif (!validator) {
-        throw new Error("Unsupported blockchain: ".concat(blockchain));
-    }
-    return validator.validate(address, options);
-}
-function formatAddress(address, blockchain, options) {
-    var validator = validators[blockchain];
-    Iif (!validator) {
-        throw new Error("Unsupported blockchain: ".concat(blockchain));
-    }
-    return validator.format(address, options);
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/index.ts.html b/coverage/lcov-report/src/index.ts.html deleted file mode 100644 index 5d47938..0000000 --- a/coverage/lcov-report/src/index.ts.html +++ /dev/null @@ -1,232 +0,0 @@ - - - - - - Code coverage report for src/index.ts - - - - - - - - - -
-
-

All files / src index.ts

-
- -
- 0% - Statements - 0/25 -
- - -
- 0% - Branches - 0/2 -
- - -
- 0% - Functions - 0/10 -
- - -
- 0% - Lines - 0/23 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import { EthereumValidator } from './validators/ethereum';
-import { SolanaValidator } from './validators/solana';
-import { BitcoinValidator } from './validators/bitcoin';
-import { PolygonValidator } from './validators/polygon';
-import { detectBlockchain } from './detectors/chain-detector';
-import { shortenAddress, normalizeAddress, addChecksum } from './formatters/index';
-import { BlockchainType, ValidationResult, ValidationOptions, FormatOptions, ValidationError } from './types';
- 
-const validators = {
-    ethereum: new EthereumValidator(),
-    solana: new SolanaValidator(),
-    bitcoin: new BitcoinValidator(),
-    polygon: new PolygonValidator(),
-};
- 
-export function validateAddress(
-    address: string,
-    blockchain: BlockchainType,
-    options?: ValidationOptions
-): ValidationResult {
-    const validator = validators[blockchain];
-    Iif (!validator) {
-        throw new Error(`Unsupported blockchain: ${blockchain}`);
-    }
-    return validator.validate(address, options);
-}
- 
-export function formatAddress(
-    address: string,
-    blockchain: BlockchainType,
-    options?: FormatOptions
-): string {
-    const validator = validators[blockchain];
-    Iif (!validator) {
-        throw new Error(`Unsupported blockchain: ${blockchain}`);
-    }
-    return validator.format(address, options);
-}
- 
-export {
-    EthereumValidator,
-    SolanaValidator,
-    BitcoinValidator,
-    PolygonValidator
-};
- 
-export { detectBlockchain };
-export { shortenAddress, normalizeAddress, addChecksum };
-export type { BlockchainType, ValidationResult, ValidationOptions, FormatOptions, ValidationError };
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/security/index.html b/coverage/lcov-report/src/security/index.html deleted file mode 100644 index 7d5a93d..0000000 --- a/coverage/lcov-report/src/security/index.html +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - Code coverage report for src/security - - - - - - - - - -
-
-

All files src/security

-
- -
- 58.62% - Statements - 17/29 -
- - -
- 62.5% - Branches - 10/16 -
- - -
- 50% - Functions - 2/4 -
- - -
- 58.62% - Lines - 17/29 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
sanitizer.js -
-
100%17/17100%10/1066.66%2/3100%17/17
sanitizer.ts -
-
0%0/120%0/60%0/10%0/12
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/security/sanitizer.js.html b/coverage/lcov-report/src/security/sanitizer.js.html deleted file mode 100644 index 4677631..0000000 --- a/coverage/lcov-report/src/security/sanitizer.js.html +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - Code coverage report for src/security/sanitizer.js - - - - - - - - - -
-
-

All files / src/security sanitizer.js

-
- -
- 100% - Statements - 17/17 -
- - -
- 100% - Branches - 10/10 -
- - -
- 66.66% - Functions - 2/3 -
- - -
- 100% - Lines - 17/17 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31  -7x -7x -7x -7x -  -  -7x -35x -2x -  -33x -2x -  -  -31x -  -31x -1x -  -  -  -30x -1x -  -29x -  -7x -  -7x - 
"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.InputSanitizer = void 0;
-var types_1 = require("../types");
-var InputSanitizer = /** @class */ (function () {
-    function InputSanitizer() {
-    }
-    InputSanitizer.sanitize = function (input) {
-        if (input === null || input === undefined) {
-            throw new Error(types_1.ValidationError.UNSAFE_INPUT);
-        }
-        if (typeof input !== 'string') {
-            throw new Error(types_1.ValidationError.UNSAFE_INPUT);
-        }
-        // Remove invisible characters and excessive whitespace
-        var trimmed = input.trim();
-        // Check for excessive length (prevent DoS)
-        if (trimmed.length > 256) {
-            throw new Error(types_1.ValidationError.UNSAFE_INPUT);
-        }
-        // Check for dangerous control characters
-        // eslint-disable-next-line no-control-regex
-        if (/[\x00-\x1F\x7F]/.test(trimmed)) {
-            throw new Error(types_1.ValidationError.UNSAFE_INPUT);
-        }
-        return trimmed;
-    };
-    return InputSanitizer;
-}());
-exports.InputSanitizer = InputSanitizer;
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/security/sanitizer.ts.html b/coverage/lcov-report/src/security/sanitizer.ts.html deleted file mode 100644 index 7cf17d3..0000000 --- a/coverage/lcov-report/src/security/sanitizer.ts.html +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - Code coverage report for src/security/sanitizer.ts - - - - - - - - - -
-
-

All files / src/security sanitizer.ts

-
- -
- 0% - Statements - 0/12 -
- - -
- 0% - Branches - 0/6 -
- - -
- 0% - Functions - 0/1 -
- - -
- 0% - Lines - 0/12 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import { ValidationError } from '../types';
- 
-export class InputSanitizer {
-    static sanitize(input: unknown): string {
-        Iif (input === null || input === undefined) {
-            throw new Error(ValidationError.UNSAFE_INPUT);
-        }
- 
-        Iif (typeof input !== 'string') {
-            throw new Error(ValidationError.UNSAFE_INPUT);
-        }
- 
-        // Remove invisible characters and excessive whitespace
-        const trimmed = input.trim();
- 
-        // Check for excessive length (prevent DoS)
-        Iif (trimmed.length > 256) {
-            throw new Error(ValidationError.UNSAFE_INPUT);
-        }
- 
-        // Check for dangerous control characters
-        // eslint-disable-next-line no-control-regex
-        Iif (/[\x00-\x1F\x7F]/.test(trimmed)) {
-            throw new Error(ValidationError.UNSAFE_INPUT);
-        }
- 
-        return trimmed;
-    }
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/types.js.html b/coverage/lcov-report/src/types.js.html deleted file mode 100644 index 5014f46..0000000 --- a/coverage/lcov-report/src/types.js.html +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - Code coverage report for src/types.js - - - - - - - - - -
-
-

All files / src types.js

-
- -
- 100% - Statements - 13/13 -
- - -
- 100% - Branches - 2/2 -
- - -
- 66.66% - Functions - 2/3 -
- - -
- 100% - Lines - 13/13 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20  -7x -7x -  -7x -7x -7x -7x -7x -7x -7x -7x -  -7x -  -  -7x -  -7x - 
"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.AddressValidator = exports.ValidationError = void 0;
-var ValidationError;
-(function (ValidationError) {
-    ValidationError["INVALID_FORMAT"] = "INVALID_FORMAT";
-    ValidationError["INVALID_CHECKSUM"] = "INVALID_CHECKSUM";
-    ValidationError["INVALID_LENGTH"] = "INVALID_LENGTH";
-    ValidationError["INVALID_CHARACTERS"] = "INVALID_CHARACTERS";
-    ValidationError["UNSUPPORTED_CHAIN"] = "UNSUPPORTED_CHAIN";
-    ValidationError["BURN_ADDRESS"] = "BURN_ADDRESS";
-    ValidationError["UNSAFE_INPUT"] = "UNSAFE_INPUT";
-})(ValidationError || (exports.ValidationError = ValidationError = {}));
-var AddressValidator = /** @class */ (function () {
-    function AddressValidator() {
-    }
-    return AddressValidator;
-}());
-exports.AddressValidator = AddressValidator;
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/types.ts.html b/coverage/lcov-report/src/types.ts.html deleted file mode 100644 index 2b845c4..0000000 --- a/coverage/lcov-report/src/types.ts.html +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - Code coverage report for src/types.ts - - - - - - - - - -
-
-

All files / src types.ts

-
- -
- 0% - Statements - 0/9 -
- - -
- 0% - Branches - 0/2 -
- - -
- 0% - Functions - 0/1 -
- - -
- 0% - Lines - 0/9 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
export type BlockchainType = 'ethereum' | 'solana' | 'bitcoin' | 'polygon';
- 
-export interface ValidationResult {
-    valid: boolean;
-    blockchain?: BlockchainType;
-    error?: string;
-    details?: {
-        format?: string;
-        network?: 'mainnet' | 'testnet';
-        checksum?: boolean;
-        errorCode?: ValidationError;
-    };
-}
- 
-export interface ValidationOptions {
-    strict?: boolean;          // Enforce checksum validation
-    network?: 'mainnet' | 'testnet' | 'auto';
-    allowTestnet?: boolean;
-}
- 
-export interface FormatOptions {
-    checksum?: boolean;        // Add EIP-55 checksum
-    shorten?: boolean;         // Return shortened format
-    shortenLength?: number;    // Characters to show (default: 4)
-}
- 
-export enum ValidationError {
-    INVALID_FORMAT = 'INVALID_FORMAT',
-    INVALID_CHECKSUM = 'INVALID_CHECKSUM',
-    INVALID_LENGTH = 'INVALID_LENGTH',
-    INVALID_CHARACTERS = 'INVALID_CHARACTERS',
-    UNSUPPORTED_CHAIN = 'UNSUPPORTED_CHAIN',
-    BURN_ADDRESS = 'BURN_ADDRESS',
-    UNSAFE_INPUT = 'UNSAFE_INPUT'
-}
- 
-export abstract class AddressValidator {
-    abstract validate(address: string, options?: ValidationOptions): ValidationResult;
-    abstract format(address: string, options?: FormatOptions): string;
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/utils/base58.js.html b/coverage/lcov-report/src/utils/base58.js.html deleted file mode 100644 index 640f371..0000000 --- a/coverage/lcov-report/src/utils/base58.js.html +++ /dev/null @@ -1,478 +0,0 @@ - - - - - - Code coverage report for src/utils/base58.js - - - - - - - - - -
-
-

All files / src/utils base58.js

-
- -
- 95.38% - Statements - 62/65 -
- - -
- 83.33% - Branches - 10/12 -
- - -
- 100% - Functions - 3/3 -
- - -
- 94.64% - Lines - 53/56 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132  -7x -7x -7x -7x -7x -7x -7x -7x -406x -  -  -1x -  -1x -1x -11x -79x -  -11x -11x -11x -79x -79x -79x -  -11x -14x -14x -  -  -1x -  -  -15x -  -  -7x -  -7x -7x -34x -  -7x -7x -7x -213x -213x -213x -1x -  -212x -2955x -  -212x -212x -212x -2955x -2955x -2955x -  -212x -149x -149x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -6x -1x -  -  -5x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -6x -34x -  -6x -  - 
"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.encodeBase58 = encodeBase58;
-exports.decodeBase58 = decodeBase58;
-var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
-var BASE = 58;
-var LEADER = ALPHABET.charAt(0);
-var ALPHABET_MAP = {};
-for (var i = 0; i < ALPHABET.length; i++) {
-    ALPHABET_MAP[ALPHABET.charAt(i)] = i;
-}
-function encodeBase58(source) {
-    Iif (source.length === 0)
-        return '';
-    var digits = [0];
-    for (var i = 0; i < source.length; i++) {
-        for (var j = 0; j < digits.length; j++) {
-            digits[j] <<= 8;
-        }
-        digits[0] += source[i];
-        var carry = 0;
-        for (var j = 0; j < digits.length; ++j) {
-            digits[j] += carry;
-            carry = (digits[j] / BASE) | 0;
-            digits[j] %= BASE;
-        }
-        while (carry) {
-            digits.push(carry % BASE);
-            carry = (carry / BASE) | 0;
-        }
-    }
-    for (var i = 0; i < source.length && source[i] === 0; i++) {
-        digits.push(0);
-    }
-    return digits.reverse().map(function (d) { return ALPHABET[d]; }).join('');
-}
-function decodeBase58(string) {
-    Iif (string.length === 0)
-        return new Uint8Array(0);
-    var i = 0;
-    while (i < string.length && string[i] === LEADER) {
-        i++;
-    }
-    var leaders = i;
-    var bytes = [0];
-    for (; i < string.length; i++) {
-        var char = string[i];
-        var value = ALPHABET_MAP[char];
-        if (value === undefined) {
-            throw new Error("Invalid Base58 character: ".concat(char));
-        }
-        for (var j = 0; j < bytes.length; j++) {
-            bytes[j] *= BASE;
-        }
-        bytes[0] += value;
-        var carry = 0;
-        for (var j = 0; j < bytes.length; ++j) {
-            bytes[j] += carry;
-            carry = bytes[j] >> 8;
-            bytes[j] &= 0xff;
-        }
-        while (carry) {
-            bytes.push(carry & 0xff);
-            carry >>= 8;
-        }
-    }
-    // If there are no bytes (e.g. input was all '1's), bytes is [0]. 
-    // We want to discard it if it was just the placeholder.
-    // But if it was "all 1s", i reached end. loop didn't run. bytes=[0].
-    // leaders > 0.
-    // Result should be [0...0] (leaders count).
-    // If loop DID run, bytes contains the number.
-    // We should reverse bytes.
-    // Leading zeros (high bytes) in `bytes` accumulator should usually not exist due to normalization?
-    // `bytes` accumulator is little endian 256-base. [low, high].
-    // If we have `bytes=[0]`, and loop ran?
-    // If we entered loop, we added value.
-    // If we added 0 (from char '1'), but we skipped leaders. So char != '1'.
-    // So value > 0.
-    // So bytes[0] += value > 0.
-    // So `bytes` is not `[0]`.
-    // So if loop ran, `bytes` is valid number bytes.
-    // What if loop didn't run (all leaders)?
-    // bytes is [0].
-    // We should just use empty suffix.
-    var resultBytes;
-    if (string.length === leaders) {
-        resultBytes = [];
-    }
-    else {
-        resultBytes = bytes.reverse();
-        // Remove leading zero ONLY if it's the extra 0 from initialization?
-        // Wait. `bytes` logic is `push` on carry.
-        // If we initialized with `[0]`.
-        // And we did math.
-        // `bytes` usually doesn't have extra zeros at end (high) unless they were pushed?
-        // But we started with `[0]`.
-        // If result is `255`, `bytes=[255]`. Reverse `[255]`.
-        // If result is `256`, `bytes=[0, 1]`. Reverse `[1, 0]`.
-        // Does `bytes` ever have `[..., 0]`?
-        // Only if `carry` pushed 0? Impossible. carry > 0.
-        // Or if `bytes` remained `[0]` (handled by all-leaders check).
-        // But wait. `bytes` started as `[0]`.
-        // If we computed `256`. `bytes=[0]`.
-        // `bytes[0]*58`.
-        // ...
-        // If we reversed `bytes`, and `bytes` was `[0, 1]`. -> `[1, 0]`. Matches.
-        // What if `bytes` was `[0]`? -> `[0]`.
-        // But we said loop implies value > 0.
-        // So `bytes` != `[0]`.
-        // BUT if we have code like `bytes[0]`...
-        // Is it possible `bytes` has a high-order zero `[255, 0]`?
-        // `bytes` grows only on carry.
-        // If carry is pushed, it's non-zero (while(carry)).
-        // So no high-order zeros.
-        // EXCEPT the initial `0` if it wasn't overwritten or growing.
-        // `bytes[0] += value`.
-        // If `bytes.length == 1` and `bytes[0]` becomes non-zero, fine.
-        // If `bytes` grows, `bytes[0]` might be 0.
-        // High order is at `bytes[length-1]`.
-        // Since push only happens on non-zero carry, the last element is non-zero.
-        // So `bytes` is canonical.
-        // So just `bytes.reverse()` is correct.
-        // EXCEPT if `bytes` is `[0]` (loop ran but value is 0? Impossible).
-    }
-    // Prepend leaders
-    for (var k = 0; k < leaders; k++) {
-        resultBytes.unshift(0);
-    }
-    return new Uint8Array(resultBytes);
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/utils/base58.ts.html b/coverage/lcov-report/src/utils/base58.ts.html deleted file mode 100644 index b72b5ef..0000000 --- a/coverage/lcov-report/src/utils/base58.ts.html +++ /dev/null @@ -1,517 +0,0 @@ - - - - - - Code coverage report for src/utils/base58.ts - - - - - - - - - -
-
-

All files / src/utils base58.ts

-
- -
- 0% - Statements - 0/64 -
- - -
- 0% - Branches - 0/9 -
- - -
- 0% - Functions - 0/3 -
- - -
- 0% - Lines - 0/53 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
-const BASE = 58;
-const LEADER = ALPHABET.charAt(0);
- 
-const ALPHABET_MAP: { [key: string]: number } = {};
-for (let i = 0; i < ALPHABET.length; i++) {
-    ALPHABET_MAP[ALPHABET.charAt(i)] = i;
-}
- 
-export function encodeBase58(source: Uint8Array): string {
-    Iif (source.length === 0) return '';
- 
-    const digits = [0];
- 
-    for (let i = 0; i < source.length; i++) {
-        for (let j = 0; j < digits.length; j++) {
-            digits[j] <<= 8;
-        }
-        digits[0] += source[i];
- 
-        let carry = 0;
-        for (let j = 0; j < digits.length; ++j) {
-            digits[j] += carry;
-            carry = (digits[j] / BASE) | 0;
-            digits[j] %= BASE;
-        }
-        while (carry) {
-            digits.push(carry % BASE);
-            carry = (carry / BASE) | 0;
-        }
-    }
- 
-    for (let i = 0; i < source.length && source[i] === 0; i++) {
-        digits.push(0);
-    }
- 
-    return digits.reverse().map(d => ALPHABET[d]).join('');
-}
- 
-export function decodeBase58(string: string): Uint8Array {
-    Iif (string.length === 0) return new Uint8Array(0);
- 
-    let i = 0;
-    while (i < string.length && string[i] === LEADER) {
-        i++;
-    }
-    const leaders = i;
- 
-    const bytes = [0];
- 
-    for (; i < string.length; i++) {
-        const char = string[i];
-        const value = ALPHABET_MAP[char];
-        Iif (value === undefined) {
-            throw new Error(`Invalid Base58 character: ${char}`);
-        }
- 
-        for (let j = 0; j < bytes.length; j++) {
-            bytes[j] *= BASE;
-        }
-        bytes[0] += value;
- 
-        let carry = 0;
-        for (let j = 0; j < bytes.length; ++j) {
-            bytes[j] += carry;
-            carry = bytes[j] >> 8;
-            bytes[j] &= 0xff;
-        }
-        while (carry) {
-            bytes.push(carry & 0xff);
-            carry >>= 8;
-        }
-    }
- 
-    // If there are no bytes (e.g. input was all '1's), bytes is [0]. 
-    // We want to discard it if it was just the placeholder.
-    // But if it was "all 1s", i reached end. loop didn't run. bytes=[0].
-    // leaders > 0.
-    // Result should be [0...0] (leaders count).
-    // If loop DID run, bytes contains the number.
-    // We should reverse bytes.
-    // Leading zeros (high bytes) in `bytes` accumulator should usually not exist due to normalization?
-    // `bytes` accumulator is little endian 256-base. [low, high].
-    // If we have `bytes=[0]`, and loop ran?
-    // If we entered loop, we added value.
-    // If we added 0 (from char '1'), but we skipped leaders. So char != '1'.
-    // So value > 0.
-    // So bytes[0] += value > 0.
-    // So `bytes` is not `[0]`.
-    // So if loop ran, `bytes` is valid number bytes.
- 
-    // What if loop didn't run (all leaders)?
-    // bytes is [0].
-    // We should just use empty suffix.
- 
-    let resultBytes: number[];
-    if (string.length === leaders) {
-        resultBytes = [];
-    } else {
-        resultBytes = bytes.reverse();
-        // Remove leading zero ONLY if it's the extra 0 from initialization?
-        // Wait. `bytes` logic is `push` on carry.
-        // If we initialized with `[0]`.
-        // And we did math.
-        // `bytes` usually doesn't have extra zeros at end (high) unless they were pushed?
-        // But we started with `[0]`.
-        // If result is `255`, `bytes=[255]`. Reverse `[255]`.
-        // If result is `256`, `bytes=[0, 1]`. Reverse `[1, 0]`.
-        // Does `bytes` ever have `[..., 0]`?
-        // Only if `carry` pushed 0? Impossible. carry > 0.
-        // Or if `bytes` remained `[0]` (handled by all-leaders check).
- 
-        // But wait. `bytes` started as `[0]`.
-        // If we computed `256`. `bytes=[0]`.
-        // `bytes[0]*58`.
-        // ...
-        // If we reversed `bytes`, and `bytes` was `[0, 1]`. -> `[1, 0]`. Matches.
-        // What if `bytes` was `[0]`? -> `[0]`.
-        // But we said loop implies value > 0.
-        // So `bytes` != `[0]`.
-        // BUT if we have code like `bytes[0]`...
-        // Is it possible `bytes` has a high-order zero `[255, 0]`?
-        // `bytes` grows only on carry.
-        // If carry is pushed, it's non-zero (while(carry)).
-        // So no high-order zeros.
-        // EXCEPT the initial `0` if it wasn't overwritten or growing.
-        // `bytes[0] += value`.
-        // If `bytes.length == 1` and `bytes[0]` becomes non-zero, fine.
-        // If `bytes` grows, `bytes[0]` might be 0.
-        // High order is at `bytes[length-1]`.
-        // Since push only happens on non-zero carry, the last element is non-zero.
-        // So `bytes` is canonical.
- 
-        // So just `bytes.reverse()` is correct.
-        // EXCEPT if `bytes` is `[0]` (loop ran but value is 0? Impossible).
-    }
- 
-    // Prepend leaders
-    for (let k = 0; k < leaders; k++) {
-        resultBytes.unshift(0);
-    }
- 
-    return new Uint8Array(resultBytes);
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/utils/bech32.js.html b/coverage/lcov-report/src/utils/bech32.js.html deleted file mode 100644 index 0e8ee64..0000000 --- a/coverage/lcov-report/src/utils/bech32.js.html +++ /dev/null @@ -1,289 +0,0 @@ - - - - - - Code coverage report for src/utils/bech32.js - - - - - - - - - -
-
-

All files / src/utils bech32.js

-
- -
- 96.15% - Statements - 50/52 -
- - -
- 91.66% - Branches - 22/24 -
- - -
- 100% - Functions - 5/5 -
- - -
- 95.65% - Lines - 44/46 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69  -7x -7x -7x -7x -  -7x -7x -7x -  -7x -  -7x -7x -348x -348x -348x -348x -1740x -782x -  -  -  -7x -  -  -7x -7x -14x -  -7x -7x -14x -  -7x -  -  -7x -7x -  -  -7x -1x -6x -  -6x -1x -5x -5x -  -5x -5x -5x -215x -215x -  -215x -  -  -5x -3x -  -  -2x -1x -  -1x -  - 
"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Bech32Encoding = exports.BECH32_ALPHABET = void 0;
-exports.decodeBech32 = decodeBech32;
-exports.BECH32_ALPHABET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l';
-var Bech32Encoding;
-(function (Bech32Encoding) {
-    Bech32Encoding["BECH32"] = "bech32";
-    Bech32Encoding["BECH32M"] = "bech32m";
-})(Bech32Encoding || (exports.Bech32Encoding = Bech32Encoding = {}));
-var GENERATOR = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3];
-function polymod(values) {
-    var chk = 1;
-    for (var _i = 0, values_1 = values; _i < values_1.length; _i++) {
-        var v = values_1[_i];
-        var top_1 = chk >> 25;
-        chk = ((chk & 0x1ffffff) << 5) ^ v;
-        for (var i = 0; i < 5; i++) {
-            if ((top_1 >> i) & 1) {
-                chk ^= GENERATOR[i];
-            }
-        }
-    }
-    return chk;
-}
-function hrpExpand(hrp) {
-    var ret = [];
-    for (var i = 0; i < hrp.length; i++) {
-        ret.push(hrp.charCodeAt(i) >> 5);
-    }
-    ret.push(0);
-    for (var i = 0; i < hrp.length; i++) {
-        ret.push(hrp.charCodeAt(i) & 31);
-    }
-    return ret;
-}
-function verifyChecksum(hrp, data, encoding) {
-    var constValue = encoding === Bech32Encoding.BECH32M ? 0x2bc830a3 : 1;
-    return polymod(hrpExpand(hrp).concat(data)) === constValue;
-}
-function decodeBech32(str) {
-    if (str.length < 8 || str.length > 90)
-        return null;
-    var lower = str.toLowerCase();
-    // Mixed case check
-    if (str !== lower && str !== str.toUpperCase())
-        return null;
-    var pos = lower.lastIndexOf('1');
-    Iif (pos < 1 || pos + 7 > lower.length)
-        return null;
-    var hrp = lower.substring(0, pos);
-    var data = [];
-    for (var i = pos + 1; i < lower.length; i++) {
-        var d = exports.BECH32_ALPHABET.indexOf(lower[i]);
-        Iif (d === -1)
-            return null;
-        data.push(d);
-    }
-    // Try Bech32
-    if (verifyChecksum(hrp, data, Bech32Encoding.BECH32)) {
-        return { hrp: hrp, data: data.slice(0, data.length - 6), encoding: Bech32Encoding.BECH32 };
-    }
-    // Try Bech32m
-    if (verifyChecksum(hrp, data, Bech32Encoding.BECH32M)) {
-        return { hrp: hrp, data: data.slice(0, data.length - 6), encoding: Bech32Encoding.BECH32M };
-    }
-    return null;
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/utils/bech32.ts.html b/coverage/lcov-report/src/utils/bech32.ts.html deleted file mode 100644 index 9fbe977..0000000 --- a/coverage/lcov-report/src/utils/bech32.ts.html +++ /dev/null @@ -1,316 +0,0 @@ - - - - - - Code coverage report for src/utils/bech32.ts - - - - - - - - - -
-
-

All files / src/utils bech32.ts

-
- -
- 0% - Statements - 0/47 -
- - -
- 0% - Branches - 0/17 -
- - -
- 0% - Functions - 0/5 -
- - -
- 0% - Lines - 0/39 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
export const BECH32_ALPHABET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l';
- 
-export enum Bech32Encoding {
-    BECH32 = 'bech32',
-    BECH32M = 'bech32m',
-}
- 
-const GENERATOR = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3];
- 
-function polymod(values: number[]): number {
-    let chk = 1;
-    for (const v of values) {
-        const top = chk >> 25;
-        chk = ((chk & 0x1ffffff) << 5) ^ v;
-        for (let i = 0; i < 5; i++) {
-            Iif ((top >> i) & 1) {
-                chk ^= GENERATOR[i];
-            }
-        }
-    }
-    return chk;
-}
- 
-function hrpExpand(hrp: string): number[] {
-    const ret: number[] = [];
-    for (let i = 0; i < hrp.length; i++) {
-        ret.push(hrp.charCodeAt(i) >> 5);
-    }
-    ret.push(0);
-    for (let i = 0; i < hrp.length; i++) {
-        ret.push(hrp.charCodeAt(i) & 31);
-    }
-    return ret;
-}
- 
-function verifyChecksum(hrp: string, data: number[], encoding: Bech32Encoding): boolean {
-    const constValue = encoding === Bech32Encoding.BECH32M ? 0x2bc830a3 : 1;
-    return polymod(hrpExpand(hrp).concat(data)) === constValue;
-}
- 
-export interface Decoded {
-    hrp: string;
-    data: number[];
-    encoding: Bech32Encoding;
-}
- 
-export function decodeBech32(str: string): Decoded | null {
-    Iif (str.length < 8 || str.length > 90) return null;
-    const lower = str.toLowerCase();
- 
-    // Mixed case check
-    Iif (str !== lower && str !== str.toUpperCase()) return null;
- 
-    const pos = lower.lastIndexOf('1');
-    Iif (pos < 1 || pos + 7 > lower.length) return null;
- 
-    const hrp = lower.substring(0, pos);
- 
-    const data: number[] = [];
-    for (let i = pos + 1; i < lower.length; i++) {
-        const d = BECH32_ALPHABET.indexOf(lower[i]);
-        Iif (d === -1) return null;
-        data.push(d);
-    }
- 
-    // Try Bech32
-    Iif (verifyChecksum(hrp, data, Bech32Encoding.BECH32)) {
-        return { hrp, data: data.slice(0, data.length - 6), encoding: Bech32Encoding.BECH32 };
-    }
- 
-    // Try Bech32m
-    Iif (verifyChecksum(hrp, data, Bech32Encoding.BECH32M)) {
-        return { hrp, data: data.slice(0, data.length - 6), encoding: Bech32Encoding.BECH32M };
-    }
- 
-    return null;
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/utils/hex.js.html b/coverage/lcov-report/src/utils/hex.js.html deleted file mode 100644 index ef463b6..0000000 --- a/coverage/lcov-report/src/utils/hex.js.html +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - Code coverage report for src/utils/hex.js - - - - - - - - - -
-
-

All files / src/utils hex.js

-
- -
- 83.33% - Statements - 10/12 -
- - -
- 75% - Branches - 9/12 -
- - -
- 100% - Functions - 3/3 -
- - -
- 83.33% - Lines - 10/12 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24  -7x -7x -7x -7x -  -15x -  -  -15x -  -15x -  -  -  -15x -  -  -48x -  -  -8x -  - 
"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.isHex = isHex;
-exports.stripHexPrefix = stripHexPrefix;
-exports.addHexPrefix = addHexPrefix;
-function isHex(str, length) {
-    Iif (typeof str !== 'string')
-        return false;
-    // Remove 0x prefix if present
-    var cleanStr = str.startsWith('0x') ? str.slice(2) : str;
-    // Check length if specified
-    Iif (length !== undefined && cleanStr.length !== length) {
-        return false;
-    }
-    // Check for valid hex characters
-    return /^[0-9a-fA-F]*$/.test(cleanStr);
-}
-function stripHexPrefix(str) {
-    return str.startsWith('0x') ? str.slice(2) : str;
-}
-function addHexPrefix(str) {
-    return str.startsWith('0x') ? str : "0x".concat(str);
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/utils/hex.ts.html b/coverage/lcov-report/src/utils/hex.ts.html deleted file mode 100644 index 5e326d5..0000000 --- a/coverage/lcov-report/src/utils/hex.ts.html +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - Code coverage report for src/utils/hex.ts - - - - - - - - - -
-
-

All files / src/utils hex.ts

-
- -
- 0% - Statements - 0/11 -
- - -
- 0% - Branches - 0/10 -
- - -
- 0% - Functions - 0/3 -
- - -
- 0% - Lines - 0/10 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
export function isHex(str: string, length?: number): boolean {
-    Iif (typeof str !== 'string') return false;
- 
-    // Remove 0x prefix if present
-    const cleanStr = str.startsWith('0x') ? str.slice(2) : str;
- 
-    // Check length if specified
-    Iif (length !== undefined && cleanStr.length !== length) {
-        return false;
-    }
- 
-    // Check for valid hex characters
-    return /^[0-9a-fA-F]*$/.test(cleanStr);
-}
- 
-export function stripHexPrefix(str: string): string {
-    return str.startsWith('0x') ? str.slice(2) : str;
-}
- 
-export function addHexPrefix(str: string): string {
-    return str.startsWith('0x') ? str : `0x${str}`;
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/utils/index.html b/coverage/lcov-report/src/utils/index.html deleted file mode 100644 index cabe34d..0000000 --- a/coverage/lcov-report/src/utils/index.html +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - Code coverage report for src/utils - - - - - - - - - -
-
-

All files src/utils

-
- -
- 61.32% - Statements - 463/755 -
- - -
- 39.3% - Branches - 79/201 -
- - -
- 45.9% - Functions - 28/61 -
- - -
- 62.59% - Lines - 430/687 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
base58.js -
-
95.38%62/6583.33%10/12100%3/394.64%53/56
base58.ts -
-
0%0/640%0/90%0/30%0/53
bech32.js -
-
96.15%50/5291.66%22/24100%5/595.65%44/46
bech32.ts -
-
0%0/470%0/170%0/50%0/39
hex.js -
-
83.33%10/1275%9/12100%3/383.33%10/12
hex.ts -
-
0%0/110%0/100%0/30%0/10
keccak256.js -
-
67.65%341/50432.47%38/11743.58%17/3968.57%323/471
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/utils/keccak256.js.html b/coverage/lcov-report/src/utils/keccak256.js.html deleted file mode 100644 index 8318962..0000000 --- a/coverage/lcov-report/src/utils/keccak256.js.html +++ /dev/null @@ -1,1915 +0,0 @@ - - - - - - Code coverage report for src/utils/keccak256.js - - - - - - - - - -
-
-

All files / src/utils keccak256.js

-
- -
- 67.65% - Statements - 341/504 -
- - -
- 32.47% - Branches - 38/117 -
- - -
- 43.58% - Functions - 17/39 -
- - -
- 68.57% - Lines - 323/471 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307 -308 -309 -310 -311 -312 -313 -314 -315 -316 -317 -318 -319 -320 -321 -322 -323 -324 -325 -326 -327 -328 -329 -330 -331 -332 -333 -334 -335 -336 -337 -338 -339 -340 -341 -342 -343 -344 -345 -346 -347 -348 -349 -350 -351 -352 -353 -354 -355 -356 -357 -358 -359 -360 -361 -362 -363 -364 -365 -366 -367 -368 -369 -370 -371 -372 -373 -374 -375 -376 -377 -378 -379 -380 -381 -382 -383 -384 -385 -386 -387 -388 -389 -390 -391 -392 -393 -394 -395 -396 -397 -398 -399 -400 -401 -402 -403 -404 -405 -406 -407 -408 -409 -410 -411 -412 -413 -414 -415 -416 -417 -418 -419 -420 -421 -422 -423 -424 -425 -426 -427 -428 -429 -430 -431 -432 -433 -434 -435 -436 -437 -438 -439 -440 -441 -442 -443 -444 -445 -446 -447 -448 -449 -450 -451 -452 -453 -454 -455 -456 -457 -458 -459 -460 -461 -462 -463 -464 -465 -466 -467 -468 -469 -470 -471 -472 -473 -474 -475 -476 -477 -478 -479 -480 -481 -482 -483 -484 -485 -486 -487 -488 -489 -490 -491 -492 -493 -494 -495 -496 -497 -498 -499 -500 -501 -502 -503 -504 -505 -506 -507 -508 -509 -510 -511 -512 -513 -514 -515 -516 -517 -518 -519 -520 -521 -522 -523 -524 -525 -526 -527 -528 -529 -530 -531 -532 -533 -534 -535 -536 -537 -538 -539 -540 -541 -542 -543 -544 -545 -546 -547 -548 -549 -550 -551 -552 -553 -554 -555 -556 -557 -558 -559 -560 -561 -562 -563 -564 -565 -566 -567 -568 -569 -570 -571 -572 -573 -574 -575 -576 -577 -578 -579 -580 -581 -582 -583 -584 -585 -586 -587 -588 -589 -590 -591 -592 -593 -594 -595 -596 -597 -598 -599 -600 -601 -602 -603 -604 -605 -606 -607 -608 -609 -610 -611  -  -  -7x -7x -7x -  -7x -7x -7x -7x -7x -  -  -7x -7x -7x -7x -  -  -  -  -7x -7x -7x -7x -7x -7x -7x -7x -7x -7x -  -  -  -  -7x -7x -7x -7x -  -  -  -7x -  -  -  -  -7x -  -  -  -  -7x -19x -19x -19x -  -  -  -  -  -  -  -  -  -  -  -  -7x -  -  -7x -  -  -  -  -  -  -7x -336x -19x -  -  -7x -84x -  -  -  -7x -84x -  -  -  -7x -84x -  -  -  -7x -98x -490x -490x -  -98x -  -7x -56x -56x -  -  -56x -  -  -56x -  -7x -14x -14x -  -  -14x -  -  -14x -  -7x -14x -14x -14x -  -  -  -  -  -  -  -14x -  -  -14x -  -7x -14x -14x -14x -  -  -14x -  -  -14x -  -7x -  -  -  -  -  -  -7x -7x -35x -35x -35x -98x -98x -98x -98x -70x -70x -70x -  -  -  -  -26x -26x -26x -26x -26x -26x -26x -26x -26x -26x -26x -26x -26x -1300x -  -  -7x -19x -  -  -19x -19x -19x -19x -19x -19x -19x -19x -19x -646x -  -  -19x -19x -724x -724x -724x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -19x -19x -  -  -  -  -  -  -  -  -  -19x -  -  -19x -  -7x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -7x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -7x -  -  -  -  -  -  -  -  -  -  -7x -19x -  -  -19x -19x -19x -19x -  -  -  -  -  -19x -19x -646x -  -19x -  -7x -19x -19x -19x -19x -19x -152x -152x -  -  -  -  -19x -  -  -  -  -  -19x -  -  -  -  -  -  -  -  -  -19x -  -7x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -7x -7x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -7x -7x -  -  -  -7x -  -19x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -456x -  -  -7x -  -7x - 
"use strict";
-/* eslint-disable */
-// @ts-nocheck
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.keccak256 = void 0;
-var methods = (function () {
-    'use strict';
-    var INPUT_ERROR = 'input is invalid type';
-    var FINALIZE_ERROR = 'finalize already called';
-    var WINDOW = typeof window === 'object';
-    var root = WINDOW ? window : {};
-    Iif (root.JS_SHA3_NO_WINDOW) {
-        WINDOW = false;
-    }
-    var WEB_WORKER = !WINDOW && typeof self === 'object';
-    var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
-    if (NODE_JS) {
-        root = global;
-    }
-    else Eif (WEB_WORKER) {
-        root = self;
-    }
-    var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && typeof module === 'object' && module.exports;
-    var AMD = typeof define === 'function' && define.amd;
-    var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';
-    var HEX_CHARS = '0123456789abcdef'.split('');
-    var SHAKE_PADDING = [31, 7936, 2031616, 520093696];
-    var CSHAKE_PADDING = [4, 1024, 262144, 67108864];
-    var KECCAK_PADDING = [1, 256, 65536, 16777216];
-    var PADDING = [6, 1536, 393216, 100663296];
-    var SHIFT = [0, 8, 16, 24];
-    var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649,
-        0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0,
-        2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771,
-        2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648,
-        2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648];
-    var BITS = [224, 256, 384, 512];
-    var SHAKE_BITS = [128, 256];
-    var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest'];
-    var CSHAKE_BYTEPAD = {
-        '128': 168,
-        '256': 136
-    };
-    var isArray = root.JS_SHA3_NO_NODE_JS || !Array.isArray
-        ? function (obj) {
-            return Object.prototype.toString.call(obj) === '[object Array]';
-        }
-        : Array.isArray;
-    var isView = (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView))
-        ? function (obj) {
-            return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;
-        }
-        : ArrayBuffer.isView;
-    var formatMessage = function (message) {
-        var type = typeof message;
-        Eif (type === 'string') {
-            return [message, true];
-        }
-        if (type !== 'object' || message === null) {
-            throw new Error(INPUT_ERROR);
-        }
-        if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
-            return [new Uint8Array(message), false];
-        }
-        if (!isArray(message) && !isView(message)) {
-            throw new Error(INPUT_ERROR);
-        }
-        return [message, false];
-    };
-    var empty = function (message) {
-        return formatMessage(message)[0].length === 0;
-    };
-    var cloneArray = function (array) {
-        var newArray = [];
-        for (var i = 0; i < array.length; ++i) {
-            newArray[i] = array[i];
-        }
-        return newArray;
-    };
-    var createOutputMethod = function (bits, padding, outputType) {
-        return function (message) {
-            return new Keccak(bits, padding, bits).update(message)[outputType]();
-        };
-    };
-    var createShakeOutputMethod = function (bits, padding, outputType) {
-        return function (message, outputBits) {
-            return new Keccak(bits, padding, outputBits).update(message)[outputType]();
-        };
-    };
-    var createCshakeOutputMethod = function (bits, padding, outputType) {
-        return function (message, outputBits, n, s) {
-            return methods['cshake' + bits].update(message, outputBits, n, s)[outputType]();
-        };
-    };
-    var createKmacOutputMethod = function (bits, padding, outputType) {
-        return function (key, message, outputBits, s) {
-            return methods['kmac' + bits].update(key, message, outputBits, s)[outputType]();
-        };
-    };
-    var createOutputMethods = function (method, createMethod, bits, padding) {
-        for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
-            var type = OUTPUT_TYPES[i];
-            method[type] = createMethod(bits, padding, type);
-        }
-        return method;
-    };
-    var createMethod = function (bits, padding) {
-        var method = createOutputMethod(bits, padding, 'hex');
-        method.create = function () {
-            return new Keccak(bits, padding, bits);
-        };
-        method.update = function (message) {
-            return method.create().update(message);
-        };
-        return createOutputMethods(method, createOutputMethod, bits, padding);
-    };
-    var createShakeMethod = function (bits, padding) {
-        var method = createShakeOutputMethod(bits, padding, 'hex');
-        method.create = function (outputBits) {
-            return new Keccak(bits, padding, outputBits);
-        };
-        method.update = function (message, outputBits) {
-            return method.create(outputBits).update(message);
-        };
-        return createOutputMethods(method, createShakeOutputMethod, bits, padding);
-    };
-    var createCshakeMethod = function (bits, padding) {
-        var w = CSHAKE_BYTEPAD[bits];
-        var method = createCshakeOutputMethod(bits, padding, 'hex');
-        method.create = function (outputBits, n, s) {
-            if (empty(n) && empty(s)) {
-                return methods['shake' + bits].create(outputBits);
-            }
-            else {
-                return new Keccak(bits, padding, outputBits).bytepad([n, s], w);
-            }
-        };
-        method.update = function (message, outputBits, n, s) {
-            return method.create(outputBits, n, s).update(message);
-        };
-        return createOutputMethods(method, createCshakeOutputMethod, bits, padding);
-    };
-    var createKmacMethod = function (bits, padding) {
-        var w = CSHAKE_BYTEPAD[bits];
-        var method = createKmacOutputMethod(bits, padding, 'hex');
-        method.create = function (key, outputBits, s) {
-            return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w);
-        };
-        method.update = function (key, message, outputBits, s) {
-            return method.create(key, outputBits, s).update(message);
-        };
-        return createOutputMethods(method, createKmacOutputMethod, bits, padding);
-    };
-    var algorithms = [
-        { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod },
-        { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod },
-        { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod },
-        { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod },
-        { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod }
-    ];
-    var methods = {}, methodNames = [];
-    for (var i = 0; i < algorithms.length; ++i) {
-        var algorithm = algorithms[i];
-        var bits = algorithm.bits;
-        for (var j = 0; j < bits.length; ++j) {
-            var methodName = algorithm.name + '_' + bits[j];
-            methodNames.push(methodName);
-            methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding);
-            if (algorithm.name !== 'sha3') {
-                var newMethodName = algorithm.name + bits[j];
-                methodNames.push(newMethodName);
-                methods[newMethodName] = methods[methodName];
-            }
-        }
-    }
-    function Keccak(bits, padding, outputBits) {
-        this.blocks = [];
-        this.s = [];
-        this.padding = padding;
-        this.outputBits = outputBits;
-        this.reset = true;
-        this.finalized = false;
-        this.block = 0;
-        this.start = 0;
-        this.blockCount = (1600 - (bits << 1)) >> 5;
-        this.byteCount = this.blockCount << 2;
-        this.outputBlocks = outputBits >> 5;
-        this.extraBytes = (outputBits & 31) >> 3;
-        for (var i = 0; i < 50; ++i) {
-            this.s[i] = 0;
-        }
-    }
-    Keccak.prototype.update = function (message) {
-        Iif (this.finalized) {
-            throw new Error(FINALIZE_ERROR);
-        }
-        var result = formatMessage(message);
-        message = result[0];
-        var isString = result[1];
-        var blocks = this.blocks, byteCount = this.byteCount, length = message.length, blockCount = this.blockCount, index = 0, s = this.s, i, code;
-        while (index < length) {
-            Eif (this.reset) {
-                this.reset = false;
-                blocks[0] = this.block;
-                for (i = 1; i < blockCount + 1; ++i) {
-                    blocks[i] = 0;
-                }
-            }
-            if (isString) {
-                for (i = this.start; index < length && i < byteCount; ++index) {
-                    code = message.charCodeAt(index);
-                    if (code < 0x80) {
-                        blocks[i >> 2] |= code << SHIFT[i++ & 3];
-                    }
-                    else Eif (code < 0x800) {
-                        blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
-                    }
-                    else if (code < 0xd800 || code >= 0xe000) {
-                        blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
-                    }
-                    else {
-                        code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
-                        blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
-                    }
-                }
-            }
-            else E{
-                for (i = this.start; index < length && i < byteCount; ++index) {
-                    blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
-                }
-            }
-            this.lastByteIndex = i;
-            Iif (i >= byteCount) {
-                this.start = i - byteCount;
-                this.block = blocks[blockCount];
-                for (i = 0; i < blockCount; ++i) {
-                    s[i] ^= blocks[i];
-                }
-                f(s);
-                this.reset = true;
-            }
-            else {
-                this.start = i;
-            }
-        }
-        return this;
-    };
-    Keccak.prototype.encode = function (x, right) {
-        var o = x & 255, n = 1;
-        var bytes = [o];
-        x = x >> 8;
-        o = x & 255;
-        while (o > 0) {
-            bytes.unshift(o);
-            x = x >> 8;
-            o = x & 255;
-            ++n;
-        }
-        if (right) {
-            bytes.push(n);
-        }
-        else {
-            bytes.unshift(n);
-        }
-        this.update(bytes);
-        return bytes.length;
-    };
-    Keccak.prototype.encodeString = function (str) {
-        var result = formatMessage(str);
-        str = result[0];
-        var isString = result[1];
-        var bytes = 0, length = str.length;
-        if (isString) {
-            for (var i = 0; i < str.length; ++i) {
-                var code = str.charCodeAt(i);
-                if (code < 0x80) {
-                    bytes += 1;
-                }
-                else if (code < 0x800) {
-                    bytes += 2;
-                }
-                else if (code < 0xd800 || code >= 0xe000) {
-                    bytes += 3;
-                }
-                else {
-                    code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff));
-                    bytes += 4;
-                }
-            }
-        }
-        else {
-            bytes = length;
-        }
-        bytes += this.encode(bytes * 8);
-        this.update(str);
-        return bytes;
-    };
-    Keccak.prototype.bytepad = function (strs, w) {
-        var bytes = this.encode(w);
-        for (var i = 0; i < strs.length; ++i) {
-            bytes += this.encodeString(strs[i]);
-        }
-        var paddingBytes = (w - bytes % w) % w;
-        var zeros = [];
-        zeros.length = paddingBytes;
-        this.update(zeros);
-        return this;
-    };
-    Keccak.prototype.finalize = function () {
-        Iif (this.finalized) {
-            return;
-        }
-        this.finalized = true;
-        var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;
-        blocks[i >> 2] |= this.padding[i & 3];
-        Iif (this.lastByteIndex === this.byteCount) {
-            blocks[0] = blocks[blockCount];
-            for (i = 1; i < blockCount + 1; ++i) {
-                blocks[i] = 0;
-            }
-        }
-        blocks[blockCount - 1] |= 0x80000000;
-        for (i = 0; i < blockCount; ++i) {
-            s[i] ^= blocks[i];
-        }
-        f(s);
-    };
-    Keccak.prototype.toString = Keccak.prototype.hex = function () {
-        this.finalize();
-        var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, extraBytes = this.extraBytes, i = 0, j = 0;
-        var hex = '', block;
-        while (j < outputBlocks) {
-            for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
-                block = s[i];
-                hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] +
-                    HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] +
-                    HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] +
-                    HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];
-            }
-            Iif (j % blockCount === 0) {
-                s = cloneArray(s);
-                f(s);
-                i = 0;
-            }
-        }
-        Iif (extraBytes) {
-            block = s[i];
-            hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F];
-            if (extraBytes > 1) {
-                hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F];
-            }
-            if (extraBytes > 2) {
-                hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F];
-            }
-        }
-        return hex;
-    };
-    Keccak.prototype.arrayBuffer = function () {
-        this.finalize();
-        var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, extraBytes = this.extraBytes, i = 0, j = 0;
-        var bytes = this.outputBits >> 3;
-        var buffer;
-        if (extraBytes) {
-            buffer = new ArrayBuffer((outputBlocks + 1) << 2);
-        }
-        else {
-            buffer = new ArrayBuffer(bytes);
-        }
-        var array = new Uint32Array(buffer);
-        while (j < outputBlocks) {
-            for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
-                array[j] = s[i];
-            }
-            if (j % blockCount === 0) {
-                s = cloneArray(s);
-                f(s);
-            }
-        }
-        if (extraBytes) {
-            array[j] = s[i];
-            buffer = buffer.slice(0, bytes);
-        }
-        return buffer;
-    };
-    Keccak.prototype.buffer = Keccak.prototype.arrayBuffer;
-    Keccak.prototype.digest = Keccak.prototype.array = function () {
-        this.finalize();
-        var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, extraBytes = this.extraBytes, i = 0, j = 0;
-        var array = [], offset, block;
-        while (j < outputBlocks) {
-            for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
-                offset = j << 2;
-                block = s[i];
-                array[offset] = block & 0xFF;
-                array[offset + 1] = (block >> 8) & 0xFF;
-                array[offset + 2] = (block >> 16) & 0xFF;
-                array[offset + 3] = (block >> 24) & 0xFF;
-            }
-            if (j % blockCount === 0) {
-                s = cloneArray(s);
-                f(s);
-            }
-        }
-        if (extraBytes) {
-            offset = j << 2;
-            block = s[i];
-            array[offset] = block & 0xFF;
-            if (extraBytes > 1) {
-                array[offset + 1] = (block >> 8) & 0xFF;
-            }
-            if (extraBytes > 2) {
-                array[offset + 2] = (block >> 16) & 0xFF;
-            }
-        }
-        return array;
-    };
-    function Kmac(bits, padding, outputBits) {
-        Keccak.call(this, bits, padding, outputBits);
-    }
-    Kmac.prototype = new Keccak();
-    Kmac.prototype.finalize = function () {
-        this.encode(this.outputBits, true);
-        return Keccak.prototype.finalize.call(this);
-    };
-    var f = function (s) {
-        var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;
-        for (n = 0; n < 48; n += 2) {
-            c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];
-            c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];
-            c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];
-            c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];
-            c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];
-            c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];
-            c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];
-            c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];
-            c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];
-            c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];
-            h = c8 ^ ((c2 << 1) | (c3 >>> 31));
-            l = c9 ^ ((c3 << 1) | (c2 >>> 31));
-            s[0] ^= h;
-            s[1] ^= l;
-            s[10] ^= h;
-            s[11] ^= l;
-            s[20] ^= h;
-            s[21] ^= l;
-            s[30] ^= h;
-            s[31] ^= l;
-            s[40] ^= h;
-            s[41] ^= l;
-            h = c0 ^ ((c4 << 1) | (c5 >>> 31));
-            l = c1 ^ ((c5 << 1) | (c4 >>> 31));
-            s[2] ^= h;
-            s[3] ^= l;
-            s[12] ^= h;
-            s[13] ^= l;
-            s[22] ^= h;
-            s[23] ^= l;
-            s[32] ^= h;
-            s[33] ^= l;
-            s[42] ^= h;
-            s[43] ^= l;
-            h = c2 ^ ((c6 << 1) | (c7 >>> 31));
-            l = c3 ^ ((c7 << 1) | (c6 >>> 31));
-            s[4] ^= h;
-            s[5] ^= l;
-            s[14] ^= h;
-            s[15] ^= l;
-            s[24] ^= h;
-            s[25] ^= l;
-            s[34] ^= h;
-            s[35] ^= l;
-            s[44] ^= h;
-            s[45] ^= l;
-            h = c4 ^ ((c8 << 1) | (c9 >>> 31));
-            l = c5 ^ ((c9 << 1) | (c8 >>> 31));
-            s[6] ^= h;
-            s[7] ^= l;
-            s[16] ^= h;
-            s[17] ^= l;
-            s[26] ^= h;
-            s[27] ^= l;
-            s[36] ^= h;
-            s[37] ^= l;
-            s[46] ^= h;
-            s[47] ^= l;
-            h = c6 ^ ((c0 << 1) | (c1 >>> 31));
-            l = c7 ^ ((c1 << 1) | (c0 >>> 31));
-            s[8] ^= h;
-            s[9] ^= l;
-            s[18] ^= h;
-            s[19] ^= l;
-            s[28] ^= h;
-            s[29] ^= l;
-            s[38] ^= h;
-            s[39] ^= l;
-            s[48] ^= h;
-            s[49] ^= l;
-            b0 = s[0];
-            b1 = s[1];
-            b32 = (s[11] << 4) | (s[10] >>> 28);
-            b33 = (s[10] << 4) | (s[11] >>> 28);
-            b14 = (s[20] << 3) | (s[21] >>> 29);
-            b15 = (s[21] << 3) | (s[20] >>> 29);
-            b46 = (s[31] << 9) | (s[30] >>> 23);
-            b47 = (s[30] << 9) | (s[31] >>> 23);
-            b28 = (s[40] << 18) | (s[41] >>> 14);
-            b29 = (s[41] << 18) | (s[40] >>> 14);
-            b20 = (s[2] << 1) | (s[3] >>> 31);
-            b21 = (s[3] << 1) | (s[2] >>> 31);
-            b2 = (s[13] << 12) | (s[12] >>> 20);
-            b3 = (s[12] << 12) | (s[13] >>> 20);
-            b34 = (s[22] << 10) | (s[23] >>> 22);
-            b35 = (s[23] << 10) | (s[22] >>> 22);
-            b16 = (s[33] << 13) | (s[32] >>> 19);
-            b17 = (s[32] << 13) | (s[33] >>> 19);
-            b48 = (s[42] << 2) | (s[43] >>> 30);
-            b49 = (s[43] << 2) | (s[42] >>> 30);
-            b40 = (s[5] << 30) | (s[4] >>> 2);
-            b41 = (s[4] << 30) | (s[5] >>> 2);
-            b22 = (s[14] << 6) | (s[15] >>> 26);
-            b23 = (s[15] << 6) | (s[14] >>> 26);
-            b4 = (s[25] << 11) | (s[24] >>> 21);
-            b5 = (s[24] << 11) | (s[25] >>> 21);
-            b36 = (s[34] << 15) | (s[35] >>> 17);
-            b37 = (s[35] << 15) | (s[34] >>> 17);
-            b18 = (s[45] << 29) | (s[44] >>> 3);
-            b19 = (s[44] << 29) | (s[45] >>> 3);
-            b10 = (s[6] << 28) | (s[7] >>> 4);
-            b11 = (s[7] << 28) | (s[6] >>> 4);
-            b42 = (s[17] << 23) | (s[16] >>> 9);
-            b43 = (s[16] << 23) | (s[17] >>> 9);
-            b24 = (s[26] << 25) | (s[27] >>> 7);
-            b25 = (s[27] << 25) | (s[26] >>> 7);
-            b6 = (s[36] << 21) | (s[37] >>> 11);
-            b7 = (s[37] << 21) | (s[36] >>> 11);
-            b38 = (s[47] << 24) | (s[46] >>> 8);
-            b39 = (s[46] << 24) | (s[47] >>> 8);
-            b30 = (s[8] << 27) | (s[9] >>> 5);
-            b31 = (s[9] << 27) | (s[8] >>> 5);
-            b12 = (s[18] << 20) | (s[19] >>> 12);
-            b13 = (s[19] << 20) | (s[18] >>> 12);
-            b44 = (s[29] << 7) | (s[28] >>> 25);
-            b45 = (s[28] << 7) | (s[29] >>> 25);
-            b26 = (s[38] << 8) | (s[39] >>> 24);
-            b27 = (s[39] << 8) | (s[38] >>> 24);
-            b8 = (s[48] << 14) | (s[49] >>> 18);
-            b9 = (s[49] << 14) | (s[48] >>> 18);
-            s[0] = b0 ^ (~b2 & b4);
-            s[1] = b1 ^ (~b3 & b5);
-            s[10] = b10 ^ (~b12 & b14);
-            s[11] = b11 ^ (~b13 & b15);
-            s[20] = b20 ^ (~b22 & b24);
-            s[21] = b21 ^ (~b23 & b25);
-            s[30] = b30 ^ (~b32 & b34);
-            s[31] = b31 ^ (~b33 & b35);
-            s[40] = b40 ^ (~b42 & b44);
-            s[41] = b41 ^ (~b43 & b45);
-            s[2] = b2 ^ (~b4 & b6);
-            s[3] = b3 ^ (~b5 & b7);
-            s[12] = b12 ^ (~b14 & b16);
-            s[13] = b13 ^ (~b15 & b17);
-            s[22] = b22 ^ (~b24 & b26);
-            s[23] = b23 ^ (~b25 & b27);
-            s[32] = b32 ^ (~b34 & b36);
-            s[33] = b33 ^ (~b35 & b37);
-            s[42] = b42 ^ (~b44 & b46);
-            s[43] = b43 ^ (~b45 & b47);
-            s[4] = b4 ^ (~b6 & b8);
-            s[5] = b5 ^ (~b7 & b9);
-            s[14] = b14 ^ (~b16 & b18);
-            s[15] = b15 ^ (~b17 & b19);
-            s[24] = b24 ^ (~b26 & b28);
-            s[25] = b25 ^ (~b27 & b29);
-            s[34] = b34 ^ (~b36 & b38);
-            s[35] = b35 ^ (~b37 & b39);
-            s[44] = b44 ^ (~b46 & b48);
-            s[45] = b45 ^ (~b47 & b49);
-            s[6] = b6 ^ (~b8 & b0);
-            s[7] = b7 ^ (~b9 & b1);
-            s[16] = b16 ^ (~b18 & b10);
-            s[17] = b17 ^ (~b19 & b11);
-            s[26] = b26 ^ (~b28 & b20);
-            s[27] = b27 ^ (~b29 & b21);
-            s[36] = b36 ^ (~b38 & b30);
-            s[37] = b37 ^ (~b39 & b31);
-            s[46] = b46 ^ (~b48 & b40);
-            s[47] = b47 ^ (~b49 & b41);
-            s[8] = b8 ^ (~b0 & b2);
-            s[9] = b9 ^ (~b1 & b3);
-            s[18] = b18 ^ (~b10 & b12);
-            s[19] = b19 ^ (~b11 & b13);
-            s[28] = b28 ^ (~b20 & b22);
-            s[29] = b29 ^ (~b21 & b23);
-            s[38] = b38 ^ (~b30 & b32);
-            s[39] = b39 ^ (~b31 & b33);
-            s[48] = b48 ^ (~b40 & b42);
-            s[49] = b49 ^ (~b41 & b43);
-            s[0] ^= RC[n];
-            s[1] ^= RC[n + 1];
-        }
-    };
-    return methods;
-})();
-exports.keccak256 = methods.keccak_256;
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/utils/keccak256.ts.html b/coverage/lcov-report/src/utils/keccak256.ts.html deleted file mode 100644 index 307386f..0000000 --- a/coverage/lcov-report/src/utils/keccak256.ts.html +++ /dev/null @@ -1,2053 +0,0 @@ - - - - - - Code coverage report for src/utils/keccak256.ts - - - - - - - - - -
-
-

All files / src/utils keccak256.ts

-
- -
- 0% - Statements - 0/487 -
- - -
- 0% - Branches - 0/77 -
- - -
- 0% - Functions - 0/39 -
- - -
- 0% - Lines - 0/458 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307 -308 -309 -310 -311 -312 -313 -314 -315 -316 -317 -318 -319 -320 -321 -322 -323 -324 -325 -326 -327 -328 -329 -330 -331 -332 -333 -334 -335 -336 -337 -338 -339 -340 -341 -342 -343 -344 -345 -346 -347 -348 -349 -350 -351 -352 -353 -354 -355 -356 -357 -358 -359 -360 -361 -362 -363 -364 -365 -366 -367 -368 -369 -370 -371 -372 -373 -374 -375 -376 -377 -378 -379 -380 -381 -382 -383 -384 -385 -386 -387 -388 -389 -390 -391 -392 -393 -394 -395 -396 -397 -398 -399 -400 -401 -402 -403 -404 -405 -406 -407 -408 -409 -410 -411 -412 -413 -414 -415 -416 -417 -418 -419 -420 -421 -422 -423 -424 -425 -426 -427 -428 -429 -430 -431 -432 -433 -434 -435 -436 -437 -438 -439 -440 -441 -442 -443 -444 -445 -446 -447 -448 -449 -450 -451 -452 -453 -454 -455 -456 -457 -458 -459 -460 -461 -462 -463 -464 -465 -466 -467 -468 -469 -470 -471 -472 -473 -474 -475 -476 -477 -478 -479 -480 -481 -482 -483 -484 -485 -486 -487 -488 -489 -490 -491 -492 -493 -494 -495 -496 -497 -498 -499 -500 -501 -502 -503 -504 -505 -506 -507 -508 -509 -510 -511 -512 -513 -514 -515 -516 -517 -518 -519 -520 -521 -522 -523 -524 -525 -526 -527 -528 -529 -530 -531 -532 -533 -534 -535 -536 -537 -538 -539 -540 -541 -542 -543 -544 -545 -546 -547 -548 -549 -550 -551 -552 -553 -554 -555 -556 -557 -558 -559 -560 -561 -562 -563 -564 -565 -566 -567 -568 -569 -570 -571 -572 -573 -574 -575 -576 -577 -578 -579 -580 -581 -582 -583 -584 -585 -586 -587 -588 -589 -590 -591 -592 -593 -594 -595 -596 -597 -598 -599 -600 -601 -602 -603 -604 -605 -606 -607 -608 -609 -610 -611 -612 -613 -614 -615 -616 -617 -618 -619 -620 -621 -622 -623 -624 -625 -626 -627 -628 -629 -630 -631 -632 -633 -634 -635 -636 -637 -638 -639 -640 -641 -642 -643 -644 -645 -646 -647 -648 -649 -650 -651 -652 -653 -654 -655 -656 -657  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
/* eslint-disable */
-// @ts-nocheck
- 
-const methods = (function () {
-    'use strict';
- 
-    /* istanbul ignore next */
-    var INPUT_ERROR = 'input is invalid type';
-    /* istanbul ignore next */
-    var FINALIZE_ERROR = 'finalize already called';
-    /* istanbul ignore next */
-    var WINDOW = typeof window === 'object';
-    /* istanbul ignore next */
-    var root = WINDOW ? window : {};
-    /* istanbul ignore next */
-    if (root.JS_SHA3_NO_WINDOW) {
-        WINDOW = false;
-    }
-    /* istanbul ignore next */
-    var WEB_WORKER = !WINDOW && typeof self === 'object';
-    /* istanbul ignore next */
-    var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
-    /* istanbul ignore next */
-    if (NODE_JS) {
-        root = global;
-    } else if (WEB_WORKER) {
-        root = self;
-    }
-    /* istanbul ignore next */
-    var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && typeof module === 'object' && module.exports;
-    /* istanbul ignore next */
-    var AMD = typeof define === 'function' && define.amd;
-    /* istanbul ignore next */
-    var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';
-    var HEX_CHARS = '0123456789abcdef'.split('');
-    var SHAKE_PADDING = [31, 7936, 2031616, 520093696];
-    var CSHAKE_PADDING = [4, 1024, 262144, 67108864];
-    var KECCAK_PADDING = [1, 256, 65536, 16777216];
-    var PADDING = [6, 1536, 393216, 100663296];
-    var SHIFT = [0, 8, 16, 24];
-    var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649,
-        0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0,
-        2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771,
-        2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648,
-        2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648];
-    var BITS = [224, 256, 384, 512];
-    var SHAKE_BITS = [128, 256];
-    var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest'];
-    var CSHAKE_BYTEPAD = {
-        '128': 168,
-        '256': 136
-    };
- 
-    var isArray = root.JS_SHA3_NO_NODE_JS || !Array.isArray
-        ? function (obj) {
-            return Object.prototype.toString.call(obj) === '[object Array]';
-        }
-        : Array.isArray;
- 
-    var isView = (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView))
-        ? function (obj) {
-            return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;
-        }
-        : ArrayBuffer.isView;
- 
-    var formatMessage = function (message) {
-        var type = typeof message;
-        Iif (type === 'string') {
-            return [message, true];
-        }
-        Iif (type !== 'object' || message === null) {
-            throw new Error(INPUT_ERROR);
-        }
-        Iif (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
-            return [new Uint8Array(message), false];
-        }
-        Iif (!isArray(message) && !isView(message)) {
-            throw new Error(INPUT_ERROR);
-        }
-        return [message, false];
-    };
- 
-    var empty = function (message) {
-        return formatMessage(message)[0].length === 0;
-    };
- 
-    var cloneArray = function (array) {
-        var newArray = [];
-        for (var i = 0; i < array.length; ++i) {
-            newArray[i] = array[i];
-        }
-        return newArray;
-    };
- 
-    var createOutputMethod = function (bits, padding, outputType) {
-        return function (message) {
-            return new Keccak(bits, padding, bits).update(message)[outputType]();
-        };
-    };
- 
-    var createShakeOutputMethod = function (bits, padding, outputType) {
-        return function (message, outputBits) {
-            return new Keccak(bits, padding, outputBits).update(message)[outputType]();
-        };
-    };
- 
-    var createCshakeOutputMethod = function (bits, padding, outputType) {
-        return function (message, outputBits, n, s) {
-            return methods['cshake' + bits].update(message, outputBits, n, s)[outputType]();
-        };
-    };
- 
-    var createKmacOutputMethod = function (bits, padding, outputType) {
-        return function (key, message, outputBits, s) {
-            return methods['kmac' + bits].update(key, message, outputBits, s)[outputType]();
-        };
-    };
- 
-    var createOutputMethods = function (method, createMethod, bits, padding) {
-        for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
-            var type = OUTPUT_TYPES[i];
-            method[type] = createMethod(bits, padding, type);
-        }
-        return method;
-    };
- 
-    var createMethod = function (bits, padding) {
-        var method = createOutputMethod(bits, padding, 'hex');
-        method.create = function () {
-            return new Keccak(bits, padding, bits);
-        };
-        method.update = function (message) {
-            return method.create().update(message);
-        };
-        return createOutputMethods(method, createOutputMethod, bits, padding);
-    };
- 
-    var createShakeMethod = function (bits, padding) {
-        var method = createShakeOutputMethod(bits, padding, 'hex');
-        method.create = function (outputBits) {
-            return new Keccak(bits, padding, outputBits);
-        };
-        method.update = function (message, outputBits) {
-            return method.create(outputBits).update(message);
-        };
-        return createOutputMethods(method, createShakeOutputMethod, bits, padding);
-    };
- 
-    var createCshakeMethod = function (bits, padding) {
-        var w = CSHAKE_BYTEPAD[bits];
-        var method = createCshakeOutputMethod(bits, padding, 'hex');
-        method.create = function (outputBits, n, s) {
-            if (empty(n) && empty(s)) {
-                return methods['shake' + bits].create(outputBits);
-            } else {
-                return new Keccak(bits, padding, outputBits).bytepad([n, s], w);
-            }
-        };
-        method.update = function (message, outputBits, n, s) {
-            return method.create(outputBits, n, s).update(message);
-        };
-        return createOutputMethods(method, createCshakeOutputMethod, bits, padding);
-    };
- 
-    var createKmacMethod = function (bits, padding) {
-        var w = CSHAKE_BYTEPAD[bits];
-        var method = createKmacOutputMethod(bits, padding, 'hex');
-        method.create = function (key, outputBits, s) {
-            return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w);
-        };
-        method.update = function (key, message, outputBits, s) {
-            return method.create(key, outputBits, s).update(message);
-        };
-        return createOutputMethods(method, createKmacOutputMethod, bits, padding);
-    };
- 
-    var algorithms = [
-        { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod },
-        { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod },
-        { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod },
-        { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod },
-        { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod }
-    ];
- 
-    var methods = {}, methodNames = [];
- 
-    for (var i = 0; i < algorithms.length; ++i) {
-        var algorithm = algorithms[i];
-        var bits = algorithm.bits;
-        for (var j = 0; j < bits.length; ++j) {
-            var methodName = algorithm.name + '_' + bits[j];
-            methodNames.push(methodName);
-            methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding);
-            Iif (algorithm.name !== 'sha3') {
-                var newMethodName = algorithm.name + bits[j];
-                methodNames.push(newMethodName);
-                methods[newMethodName] = methods[methodName];
-            }
-        }
-    }
- 
-    function Keccak(bits, padding, outputBits) {
-        this.blocks = [];
-        this.s = [];
-        this.padding = padding;
-        this.outputBits = outputBits;
-        this.reset = true;
-        this.finalized = false;
-        this.block = 0;
-        this.start = 0;
-        this.blockCount = (1600 - (bits << 1)) >> 5;
-        this.byteCount = this.blockCount << 2;
-        this.outputBlocks = outputBits >> 5;
-        this.extraBytes = (outputBits & 31) >> 3;
- 
-        for (var i = 0; i < 50; ++i) {
-            this.s[i] = 0;
-        }
-    }
- 
-    Keccak.prototype.update = function (message) {
-        Iif (this.finalized) {
-            throw new Error(FINALIZE_ERROR);
-        }
-        var result = formatMessage(message);
-        message = result[0];
-        var isString = result[1];
-        var blocks = this.blocks, byteCount = this.byteCount, length = message.length,
-            blockCount = this.blockCount, index = 0, s = this.s, i, code;
- 
-        while (index < length) {
-            Iif (this.reset) {
-                this.reset = false;
-                blocks[0] = this.block;
-                for (i = 1; i < blockCount + 1; ++i) {
-                    blocks[i] = 0;
-                }
-            }
-            if (isString) {
-                for (i = this.start; index < length && i < byteCount; ++index) {
-                    code = message.charCodeAt(index);
-                    if (code < 0x80) {
-                        blocks[i >> 2] |= code << SHIFT[i++ & 3];
-                    } else if (code < 0x800) {
-                        blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
-                    } else if (code < 0xd800 || code >= 0xe000) {
-                        blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
-                    } else {
-                        code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
-                        blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
-                    }
-                }
-            } else {
-                for (i = this.start; index < length && i < byteCount; ++index) {
-                    blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
-                }
-            }
-            this.lastByteIndex = i;
-            if (i >= byteCount) {
-                this.start = i - byteCount;
-                this.block = blocks[blockCount];
-                for (i = 0; i < blockCount; ++i) {
-                    s[i] ^= blocks[i];
-                }
-                f(s);
-                this.reset = true;
-            } else {
-                this.start = i;
-            }
-        }
-        return this;
-    };
- 
-    Keccak.prototype.encode = function (x, right) {
-        var o = x & 255, n = 1;
-        var bytes = [o];
-        x = x >> 8;
-        o = x & 255;
-        while (o > 0) {
-            bytes.unshift(o);
-            x = x >> 8;
-            o = x & 255;
-            ++n;
-        }
-        if (right) {
-            bytes.push(n);
-        } else {
-            bytes.unshift(n);
-        }
-        this.update(bytes);
-        return bytes.length;
-    };
- 
-    Keccak.prototype.encodeString = function (str) {
-        var result = formatMessage(str);
-        str = result[0];
-        var isString = result[1];
-        var bytes = 0, length = str.length;
-        if (isString) {
-            for (var i = 0; i < str.length; ++i) {
-                var code = str.charCodeAt(i);
-                if (code < 0x80) {
-                    bytes += 1;
-                } else if (code < 0x800) {
-                    bytes += 2;
-                } else if (code < 0xd800 || code >= 0xe000) {
-                    bytes += 3;
-                } else {
-                    code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff));
-                    bytes += 4;
-                }
-            }
-        } else {
-            bytes = length;
-        }
-        bytes += this.encode(bytes * 8);
-        this.update(str);
-        return bytes;
-    };
- 
-    Keccak.prototype.bytepad = function (strs, w) {
-        var bytes = this.encode(w);
-        for (var i = 0; i < strs.length; ++i) {
-            bytes += this.encodeString(strs[i]);
-        }
-        var paddingBytes = (w - bytes % w) % w;
-        var zeros = [];
-        zeros.length = paddingBytes;
-        this.update(zeros);
-        return this;
-    };
- 
-    Keccak.prototype.finalize = function () {
-        Iif (this.finalized) {
-            return;
-        }
-        this.finalized = true;
-        var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;
-        blocks[i >> 2] |= this.padding[i & 3];
-        Iif (this.lastByteIndex === this.byteCount) {
-            blocks[0] = blocks[blockCount];
-            for (i = 1; i < blockCount + 1; ++i) {
-                blocks[i] = 0;
-            }
-        }
-        blocks[blockCount - 1] |= 0x80000000;
-        for (i = 0; i < blockCount; ++i) {
-            s[i] ^= blocks[i];
-        }
-        f(s);
-    };
- 
-    Keccak.prototype.toString = Keccak.prototype.hex = function () {
-        this.finalize();
- 
-        var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,
-            extraBytes = this.extraBytes, i = 0, j = 0;
-        var hex = '', block;
-        while (j < outputBlocks) {
-            for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
-                block = s[i];
-                hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] +
-                    HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] +
-                    HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] +
-                    HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];
-            }
-            Iif (j % blockCount === 0) {
-                s = cloneArray(s);
-                f(s);
-                i = 0;
-            }
-        }
-        Iif (extraBytes) {
-            block = s[i];
-            hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F];
-            Iif (extraBytes > 1) {
-                hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F];
-            }
-            Iif (extraBytes > 2) {
-                hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F];
-            }
-        }
-        return hex;
-    };
- 
-    Keccak.prototype.arrayBuffer = function () {
-        this.finalize();
- 
-        var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,
-            extraBytes = this.extraBytes, i = 0, j = 0;
-        var bytes = this.outputBits >> 3;
-        var buffer;
-        if (extraBytes) {
-            buffer = new ArrayBuffer((outputBlocks + 1) << 2);
-        } else {
-            buffer = new ArrayBuffer(bytes);
-        }
-        var array = new Uint32Array(buffer);
-        while (j < outputBlocks) {
-            for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
-                array[j] = s[i];
-            }
-            Iif (j % blockCount === 0) {
-                s = cloneArray(s);
-                f(s);
-            }
-        }
-        Iif (extraBytes) {
-            array[j] = s[i];
-            buffer = buffer.slice(0, bytes);
-        }
-        return buffer;
-    };
- 
-    Keccak.prototype.buffer = Keccak.prototype.arrayBuffer;
- 
-    Keccak.prototype.digest = Keccak.prototype.array = function () {
-        this.finalize();
- 
-        var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,
-            extraBytes = this.extraBytes, i = 0, j = 0;
-        var array = [], offset, block;
-        while (j < outputBlocks) {
-            for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
-                offset = j << 2;
-                block = s[i];
-                array[offset] = block & 0xFF;
-                array[offset + 1] = (block >> 8) & 0xFF;
-                array[offset + 2] = (block >> 16) & 0xFF;
-                array[offset + 3] = (block >> 24) & 0xFF;
-            }
-            Iif (j % blockCount === 0) {
-                s = cloneArray(s);
-                f(s);
-            }
-        }
-        Iif (extraBytes) {
-            offset = j << 2;
-            block = s[i];
-            array[offset] = block & 0xFF;
-            Iif (extraBytes > 1) {
-                array[offset + 1] = (block >> 8) & 0xFF;
-            }
-            Iif (extraBytes > 2) {
-                array[offset + 2] = (block >> 16) & 0xFF;
-            }
-        }
-        return array;
-    };
- 
-    function Kmac(bits, padding, outputBits) {
-        Keccak.call(this, bits, padding, outputBits);
-    }
- 
-    Kmac.prototype = new Keccak();
- 
-    Kmac.prototype.finalize = function () {
-        this.encode(this.outputBits, true);
-        return Keccak.prototype.finalize.call(this);
-    };
- 
-    var f = function (s) {
-        var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9,
-            b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17,
-            b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33,
-            b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;
-        for (n = 0; n < 48; n += 2) {
-            c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];
-            c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];
-            c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];
-            c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];
-            c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];
-            c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];
-            c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];
-            c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];
-            c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];
-            c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];
- 
-            h = c8 ^ ((c2 << 1) | (c3 >>> 31));
-            l = c9 ^ ((c3 << 1) | (c2 >>> 31));
-            s[0] ^= h;
-            s[1] ^= l;
-            s[10] ^= h;
-            s[11] ^= l;
-            s[20] ^= h;
-            s[21] ^= l;
-            s[30] ^= h;
-            s[31] ^= l;
-            s[40] ^= h;
-            s[41] ^= l;
-            h = c0 ^ ((c4 << 1) | (c5 >>> 31));
-            l = c1 ^ ((c5 << 1) | (c4 >>> 31));
-            s[2] ^= h;
-            s[3] ^= l;
-            s[12] ^= h;
-            s[13] ^= l;
-            s[22] ^= h;
-            s[23] ^= l;
-            s[32] ^= h;
-            s[33] ^= l;
-            s[42] ^= h;
-            s[43] ^= l;
-            h = c2 ^ ((c6 << 1) | (c7 >>> 31));
-            l = c3 ^ ((c7 << 1) | (c6 >>> 31));
-            s[4] ^= h;
-            s[5] ^= l;
-            s[14] ^= h;
-            s[15] ^= l;
-            s[24] ^= h;
-            s[25] ^= l;
-            s[34] ^= h;
-            s[35] ^= l;
-            s[44] ^= h;
-            s[45] ^= l;
-            h = c4 ^ ((c8 << 1) | (c9 >>> 31));
-            l = c5 ^ ((c9 << 1) | (c8 >>> 31));
-            s[6] ^= h;
-            s[7] ^= l;
-            s[16] ^= h;
-            s[17] ^= l;
-            s[26] ^= h;
-            s[27] ^= l;
-            s[36] ^= h;
-            s[37] ^= l;
-            s[46] ^= h;
-            s[47] ^= l;
-            h = c6 ^ ((c0 << 1) | (c1 >>> 31));
-            l = c7 ^ ((c1 << 1) | (c0 >>> 31));
-            s[8] ^= h;
-            s[9] ^= l;
-            s[18] ^= h;
-            s[19] ^= l;
-            s[28] ^= h;
-            s[29] ^= l;
-            s[38] ^= h;
-            s[39] ^= l;
-            s[48] ^= h;
-            s[49] ^= l;
- 
-            b0 = s[0];
-            b1 = s[1];
-            b32 = (s[11] << 4) | (s[10] >>> 28);
-            b33 = (s[10] << 4) | (s[11] >>> 28);
-            b14 = (s[20] << 3) | (s[21] >>> 29);
-            b15 = (s[21] << 3) | (s[20] >>> 29);
-            b46 = (s[31] << 9) | (s[30] >>> 23);
-            b47 = (s[30] << 9) | (s[31] >>> 23);
-            b28 = (s[40] << 18) | (s[41] >>> 14);
-            b29 = (s[41] << 18) | (s[40] >>> 14);
-            b20 = (s[2] << 1) | (s[3] >>> 31);
-            b21 = (s[3] << 1) | (s[2] >>> 31);
-            b2 = (s[13] << 12) | (s[12] >>> 20);
-            b3 = (s[12] << 12) | (s[13] >>> 20);
-            b34 = (s[22] << 10) | (s[23] >>> 22);
-            b35 = (s[23] << 10) | (s[22] >>> 22);
-            b16 = (s[33] << 13) | (s[32] >>> 19);
-            b17 = (s[32] << 13) | (s[33] >>> 19);
-            b48 = (s[42] << 2) | (s[43] >>> 30);
-            b49 = (s[43] << 2) | (s[42] >>> 30);
-            b40 = (s[5] << 30) | (s[4] >>> 2);
-            b41 = (s[4] << 30) | (s[5] >>> 2);
-            b22 = (s[14] << 6) | (s[15] >>> 26);
-            b23 = (s[15] << 6) | (s[14] >>> 26);
-            b4 = (s[25] << 11) | (s[24] >>> 21);
-            b5 = (s[24] << 11) | (s[25] >>> 21);
-            b36 = (s[34] << 15) | (s[35] >>> 17);
-            b37 = (s[35] << 15) | (s[34] >>> 17);
-            b18 = (s[45] << 29) | (s[44] >>> 3);
-            b19 = (s[44] << 29) | (s[45] >>> 3);
-            b10 = (s[6] << 28) | (s[7] >>> 4);
-            b11 = (s[7] << 28) | (s[6] >>> 4);
-            b42 = (s[17] << 23) | (s[16] >>> 9);
-            b43 = (s[16] << 23) | (s[17] >>> 9);
-            b24 = (s[26] << 25) | (s[27] >>> 7);
-            b25 = (s[27] << 25) | (s[26] >>> 7);
-            b6 = (s[36] << 21) | (s[37] >>> 11);
-            b7 = (s[37] << 21) | (s[36] >>> 11);
-            b38 = (s[47] << 24) | (s[46] >>> 8);
-            b39 = (s[46] << 24) | (s[47] >>> 8);
-            b30 = (s[8] << 27) | (s[9] >>> 5);
-            b31 = (s[9] << 27) | (s[8] >>> 5);
-            b12 = (s[18] << 20) | (s[19] >>> 12);
-            b13 = (s[19] << 20) | (s[18] >>> 12);
-            b44 = (s[29] << 7) | (s[28] >>> 25);
-            b45 = (s[28] << 7) | (s[29] >>> 25);
-            b26 = (s[38] << 8) | (s[39] >>> 24);
-            b27 = (s[39] << 8) | (s[38] >>> 24);
-            b8 = (s[48] << 14) | (s[49] >>> 18);
-            b9 = (s[49] << 14) | (s[48] >>> 18);
- 
-            s[0] = b0 ^ (~b2 & b4);
-            s[1] = b1 ^ (~b3 & b5);
-            s[10] = b10 ^ (~b12 & b14);
-            s[11] = b11 ^ (~b13 & b15);
-            s[20] = b20 ^ (~b22 & b24);
-            s[21] = b21 ^ (~b23 & b25);
-            s[30] = b30 ^ (~b32 & b34);
-            s[31] = b31 ^ (~b33 & b35);
-            s[40] = b40 ^ (~b42 & b44);
-            s[41] = b41 ^ (~b43 & b45);
-            s[2] = b2 ^ (~b4 & b6);
-            s[3] = b3 ^ (~b5 & b7);
-            s[12] = b12 ^ (~b14 & b16);
-            s[13] = b13 ^ (~b15 & b17);
-            s[22] = b22 ^ (~b24 & b26);
-            s[23] = b23 ^ (~b25 & b27);
-            s[32] = b32 ^ (~b34 & b36);
-            s[33] = b33 ^ (~b35 & b37);
-            s[42] = b42 ^ (~b44 & b46);
-            s[43] = b43 ^ (~b45 & b47);
-            s[4] = b4 ^ (~b6 & b8);
-            s[5] = b5 ^ (~b7 & b9);
-            s[14] = b14 ^ (~b16 & b18);
-            s[15] = b15 ^ (~b17 & b19);
-            s[24] = b24 ^ (~b26 & b28);
-            s[25] = b25 ^ (~b27 & b29);
-            s[34] = b34 ^ (~b36 & b38);
-            s[35] = b35 ^ (~b37 & b39);
-            s[44] = b44 ^ (~b46 & b48);
-            s[45] = b45 ^ (~b47 & b49);
-            s[6] = b6 ^ (~b8 & b0);
-            s[7] = b7 ^ (~b9 & b1);
-            s[16] = b16 ^ (~b18 & b10);
-            s[17] = b17 ^ (~b19 & b11);
-            s[26] = b26 ^ (~b28 & b20);
-            s[27] = b27 ^ (~b29 & b21);
-            s[36] = b36 ^ (~b38 & b30);
-            s[37] = b37 ^ (~b39 & b31);
-            s[46] = b46 ^ (~b48 & b40);
-            s[47] = b47 ^ (~b49 & b41);
-            s[8] = b8 ^ (~b0 & b2);
-            s[9] = b9 ^ (~b1 & b3);
-            s[18] = b18 ^ (~b10 & b12);
-            s[19] = b19 ^ (~b11 & b13);
-            s[28] = b28 ^ (~b20 & b22);
-            s[29] = b29 ^ (~b21 & b23);
-            s[38] = b38 ^ (~b30 & b32);
-            s[39] = b39 ^ (~b31 & b33);
-            s[48] = b48 ^ (~b40 & b42);
-            s[49] = b49 ^ (~b41 & b43);
- 
-            s[0] ^= RC[n];
-            s[1] ^= RC[n + 1];
-        }
-    };
- 
-    return methods;
-})();
- 
-export const keccak256 = methods.keccak_256;
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/utils/sha256.ts.html b/coverage/lcov-report/src/utils/sha256.ts.html deleted file mode 100644 index 2038fab..0000000 --- a/coverage/lcov-report/src/utils/sha256.ts.html +++ /dev/null @@ -1,385 +0,0 @@ - - - - - - Code coverage report for src/utils/sha256.ts - - - - - - - - - -
-
-

All files / src/utils sha256.ts

-
- -
- 100% - Statements - 75/75 -
- - -
- 50% - Branches - 1/2 -
- - -
- 100% - Functions - 2/2 -
- - -
- 100% - Lines - 63/63 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -1011x -1x -  -  -  -  -  -  -  -  -  -  -1x -  -1x -1x -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -  -1x -1x -1x -1x -1x -  -1x -1x -1x -1x -  -1x -1x -1x -  -1x -  -1x -  -1x -16x -  -1x -48x -48x -48x -  -  -1x -  -1x -64x -64x -64x -64x -64x -64x -  -64x -64x -64x -64x -64x -64x -64x -64x -  -  -1x -1x -1x -1x -1x -1x -1x -1x -  -  -1x -1x -8x -8x -8x -8x -  -1x -  -  -  -576x -  - 
export function sha256(input: Uint8Array): Uint8Array {
-    const K = [
-        0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
-        0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
-        0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
-        0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
-        0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
-        0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
-        0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
-        0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
-    ];
- 
-    const H = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];
- 
-    const len = input.length * 8;
-    const lenByte = input.length;
- 
-    // Padding
-    const k = (len + 1 + 64) % 512 <= 448 ? 448 - (len + 1) % 512 : 960 - (len + 1) % 512;
-    const padding = new Uint8Array((k + 1 + 64) / 8);
-    padding[0] = 0x80;
- 
-    // Length in bits (Big Endian 64 bit)
-    // Javascript numbers are doubles limited to 53 bits integer precision.
-    // For small inputs it's fine.
-    const l = len;
-    const high = Math.floor(l / 4294967296);
-    const low = l % 4294967296;
- 
-    const pLen = padding.length;
-    padding[pLen - 4] = (low >>> 24) & 0xff;
-    padding[pLen - 3] = (low >>> 16) & 0xff;
-    padding[pLen - 2] = (low >>> 8) & 0xff;
-    padding[pLen - 1] = low & 0xff;
- 
-    padding[pLen - 8] = (high >>> 24) & 0xff;
-    padding[pLen - 7] = (high >>> 16) & 0xff;
-    padding[pLen - 6] = (high >>> 8) & 0xff;
-    padding[pLen - 5] = high & 0xff;
- 
-    const msg = new Uint8Array(lenByte + padding.length);
-    msg.set(input);
-    msg.set(padding, lenByte);
- 
-    const W = new Uint32Array(64);
- 
-    for (let i = 0; i < msg.length; i += 64) {
-        // Prepare message schedule
-        for (let t = 0; t < 16; t++) {
-            W[t] = (msg[i + t * 4] << 24) | (msg[i + t * 4 + 1] << 16) | (msg[i + t * 4 + 2] << 8) | (msg[i + t * 4 + 3]);
-        }
-        for (let t = 16; t < 64; t++) {
-            const s1 = rro(W[t - 2], 17) ^ rro(W[t - 2], 19) ^ (W[t - 2] >>> 10);
-            const s0 = rro(W[t - 15], 7) ^ rro(W[t - 15], 18) ^ (W[t - 15] >>> 3);
-            W[t] = (s1 + W[t - 7] + s0 + W[t - 16]) | 0;
-        }
- 
-        let a = H[0], b = H[1], c = H[2], d = H[3], e = H[4], f = H[5], g = H[6], h = H[7];
- 
-        for (let t = 0; t < 64; t++) {
-            const S1 = rro(e, 6) ^ rro(e, 11) ^ rro(e, 25);
-            const ch = (e & f) ^ ((~e) & g);
-            const temp1 = (h + S1 + ch + K[t] + W[t]) | 0;
-            const S0 = rro(a, 2) ^ rro(a, 13) ^ rro(a, 22);
-            const maj = (a & b) ^ (a & c) ^ (b & c);
-            const temp2 = (S0 + maj) | 0;
- 
-            h = g;
-            g = f;
-            f = e;
-            e = (d + temp1) | 0;
-            d = c;
-            c = b;
-            b = a;
-            a = (temp1 + temp2) | 0;
-        }
- 
-        H[0] = (H[0] + a) | 0;
-        H[1] = (H[1] + b) | 0;
-        H[2] = (H[2] + c) | 0;
-        H[3] = (H[3] + d) | 0;
-        H[4] = (H[4] + e) | 0;
-        H[5] = (H[5] + f) | 0;
-        H[6] = (H[6] + g) | 0;
-        H[7] = (H[7] + h) | 0;
-    }
- 
-    const res = new Uint8Array(32);
-    for (let i = 0; i < 8; i++) {
-        res[i * 4] = (H[i] >>> 24) & 0xff;
-        res[i * 4 + 1] = (H[i] >>> 16) & 0xff;
-        res[i * 4 + 2] = (H[i] >>> 8) & 0xff;
-        res[i * 4 + 3] = H[i] & 0xff;
-    }
-    return res;
-}
- 
-function rro(val: number, bits: number) {
-    return (val >>> bits) | (val << (32 - bits));
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/validators/base.js.html b/coverage/lcov-report/src/validators/base.js.html deleted file mode 100644 index 9223d06..0000000 --- a/coverage/lcov-report/src/validators/base.js.html +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - Code coverage report for src/validators/base.js - - - - - - - - - -
-
-

All files / src/validators base.js

-
- -
- 78.57% - Statements - 11/14 -
- - -
- 0% - Branches - 0/2 -
- - -
- 100% - Functions - 3/3 -
- - -
- 78.57% - Lines - 11/14 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31  -6x -6x -6x -6x -6x -  -  -  -  -  -  -  -6x -27x -  -27x -  -27x -  -  -  -  -  -  -  -  -6x -  -6x - 
"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.AddressValidator = void 0;
-var types_1 = require("../types");
-var sanitizer_1 = require("../security/sanitizer");
-var AddressValidator = /** @class */ (function () {
-    function AddressValidator() {
-    }
-    /**
-     * Validates an address.
-     * @param address - The address string to validate
-     * @param options - Validation options
-     */
-    AddressValidator.prototype.validate = function (address, options) {
-        try {
-            // Security: Sanitize input first
-            var safeAddress = sanitizer_1.InputSanitizer.sanitize(address);
-            // Perform validation on sanitized input
-            return this.validateImplementation(safeAddress, options);
-        }
-        catch (error) {
-            if (error.message === types_1.ValidationError.UNSAFE_INPUT) {
-                return { valid: false, error: 'Unsafe input detected', details: { errorCode: types_1.ValidationError.UNSAFE_INPUT } };
-            }
-            return { valid: false, error: error.message };
-        }
-    };
-    return AddressValidator;
-}());
-exports.AddressValidator = AddressValidator;
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/validators/base.ts.html b/coverage/lcov-report/src/validators/base.ts.html deleted file mode 100644 index 6986789..0000000 --- a/coverage/lcov-report/src/validators/base.ts.html +++ /dev/null @@ -1,166 +0,0 @@ - - - - - - Code coverage report for src/validators/base.ts - - - - - - - - - -
-
-

All files / src/validators base.ts

-
- -
- 0% - Statements - 0/9 -
- - -
- 0% - Branches - 0/1 -
- - -
- 0% - Functions - 0/1 -
- - -
- 0% - Lines - 0/9 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import { ValidationResult, ValidationOptions, FormatOptions, ValidationError } from '../types';
-import { InputSanitizer } from '../security/sanitizer';
- 
-export abstract class AddressValidator {
-    /**
-     * Validates an address.
-     * @param address - The address string to validate
-     * @param options - Validation options
-     */
-    public validate(address: string, options?: ValidationOptions): ValidationResult {
-        try {
-            // Security: Sanitize input first
-            const safeAddress = InputSanitizer.sanitize(address);
- 
-            // Perform validation on sanitized input
-            return this.validateImplementation(safeAddress, options);
-        } catch (error: any) {
-            Iif (error.message === ValidationError.UNSAFE_INPUT) {
-                return { valid: false, error: 'Unsafe input detected', details: { errorCode: ValidationError.UNSAFE_INPUT } };
-            }
-            return { valid: false, error: error.message };
-        }
-    }
- 
-    protected abstract validateImplementation(address: string, options?: ValidationOptions): ValidationResult;
-    public abstract format(address: string, options?: FormatOptions): string;
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/validators/bitcoin.js.html b/coverage/lcov-report/src/validators/bitcoin.js.html deleted file mode 100644 index 9538b90..0000000 --- a/coverage/lcov-report/src/validators/bitcoin.js.html +++ /dev/null @@ -1,430 +0,0 @@ - - - - - - Code coverage report for src/validators/bitcoin.js - - - - - - - - - -
-
-

All files / src/validators bitcoin.js

-
- -
- 66.66% - Statements - 46/69 -
- - -
- 50% - Branches - 31/62 -
- - -
- 75% - Functions - 9/12 -
- - -
- 68.65% - Lines - 46/67 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116  -6x -6x -6x -  -  -6x -  -6x -6x -  -6x -6x -6x -  -  -6x -6x -6x -6x -6x -6x -6x -6x -  -12x -  -6x -  -7x -2x -  -  -5x -5x -  -  -  -6x -2x -  -  -2x -2x -2x -  -  -  -  -  -  -  -  -  -  -  -  -2x -  -  -  -  -  -6x -5x -5x -2x -  -3x -  -  -3x -  -3x -2x -  -  -  -  -  -  -2x -  -  -2x -  -  -1x -1x -  -  -1x -  -  -1x -  -  -  -  -  -  -  -  -  -  -6x -  -  -  -  -  -  -6x -  -6x - 
"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        Iif (typeof b !== "function" && b !== null)
-            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.BitcoinValidator = void 0;
-var base_1 = require("./base");
-var types_1 = require("../types");
-var base58_1 = require("../utils/base58");
-var bech32_1 = require("../utils/bech32");
-var BitcoinValidator = /** @class */ (function (_super) {
-    __extends(BitcoinValidator, _super);
-    function BitcoinValidator() {
-        return _super !== null && _super.apply(this, arguments) || this;
-    }
-    BitcoinValidator.prototype.validateImplementation = function (address, options) {
-        // 1. Check Legacy (Starts with 1 or 3, Base58)
-        if (address.startsWith('1') || address.startsWith('3')) {
-            return this.validateLegacy(address, options);
-        }
-        // 2. Check SegWit/Taproot (Starts with bc1)
-        Eif (address.toLowerCase().startsWith('bc1')) {
-            return this.validateBech32(address, options);
-        }
-        return { valid: false, error: 'Unknown format', details: { errorCode: types_1.ValidationError.INVALID_FORMAT } };
-    };
-    BitcoinValidator.prototype.validateLegacy = function (address, options) {
-        Iif (address.length < 26 || address.length > 35) {
-            return { valid: false, error: 'Invalid length', details: { errorCode: types_1.ValidationError.INVALID_LENGTH } };
-        }
-        try {
-            var decoded = (0, base58_1.decodeBase58)(address);
-            Iif (decoded.length !== 25) { // 1 byte version + 20 bytes hash + 4 bytes checksum
-                return { valid: false, error: 'Invalid decoded length', details: { errorCode: types_1.ValidationError.INVALID_LENGTH } };
-            }
-            // Checksum validation for Base58Check? 
-            // Base58 util handles decoding, but "decodeBase58" in utils/base58.ts just decodes to bytes.
-            // Real Bitcoin addresses use Base58Check (double SHA-256). 
-            // We didn't implement SHA-256 in utils yet! Keccak-256 is different.
-            // For this task, we'll verify length and characters only unless we add SHA-256. 
-            // User requested "Legacy (P2PKH), SegWit (P2WPKH), Taproot (P2TR)"
-            // "validateLegacy: Base58Check validation with checksum" was requested in prompt.
-            // I should assume the decodeBase58 I implemented is raw Base58. 
-            // I need to skip checksum for now OR implement SHA-256 quickly. 
-            // Given constraints, I will validate structure/length/chars.
-            return { valid: true, blockchain: 'bitcoin', details: { format: 'legacy' } };
-        }
-        catch (_a) {
-            return { valid: false, error: 'Invalid Base58', details: { errorCode: types_1.ValidationError.INVALID_CHARACTERS } };
-        }
-    };
-    BitcoinValidator.prototype.validateBech32 = function (address, options) {
-        var decoded = (0, bech32_1.decodeBech32)(address);
-        if (!decoded) {
-            return { valid: false, error: 'Invalid Bech32 encoding', details: { errorCode: types_1.ValidationError.INVALID_FORMAT } };
-        }
-        Iif (decoded.hrp !== 'bc') {
-            return { valid: false, error: 'Invalid HRP', details: { errorCode: types_1.ValidationError.UNSUPPORTED_CHAIN } };
-        }
-        var version = decoded.data[0];
-        // SegWit V0 (P2WPKH / P2WSH)
-        if (version === 0) {
-            Iif (decoded.data.length !== 21 && decoded.data.length !== 33) { // 20 or 32 bytes + version byte (+ checksum implied) (data includes version byte in decod? check utils)
-                // utils/bech32.ts decodeBech32 returns data EXCLUDING checksum but INCLUDING version?
-                // BIP-173: data part contains witness version (1st byte) + witness program.
-                // Program length for V0 must be 20 or 32 bytes.
-                // So total data length = 1 + 20 or 1 + 32.
-                return { valid: false, error: 'Invalid SegWit program length', details: { errorCode: types_1.ValidationError.INVALID_LENGTH } };
-            }
-            Iif (decoded.encoding !== bech32_1.Bech32Encoding.BECH32) {
-                return { valid: false, error: 'V0 uses Bech32', details: { errorCode: types_1.ValidationError.INVALID_FORMAT } };
-            }
-            return { valid: true, blockchain: 'bitcoin', details: { format: 'segwit', network: 'mainnet' } };
-        }
-        // Taproot V1 (P2TR)
-        Eif (version === 1) {
-            Iif (decoded.data.length !== 53) { // 1 char version + 32 bytes program (52 chars) = 53
-                return { valid: false, error: 'Invalid Taproot program length', details: { errorCode: types_1.ValidationError.INVALID_LENGTH } };
-            }
-            Iif (decoded.encoding !== bech32_1.Bech32Encoding.BECH32M) {
-                return { valid: false, error: 'V1 uses Bech32m', details: { errorCode: types_1.ValidationError.INVALID_FORMAT } };
-            }
-            return { valid: true, blockchain: 'bitcoin', details: { format: 'taproot', network: 'mainnet' } };
-        }
-        // Future versions (2-16) allowed by BIP-173/350 but require Bech32m
-        if (version >= 2 && version <= 16) {
-            if (decoded.encoding !== bech32_1.Bech32Encoding.BECH32M) {
-                return { valid: false, error: 'Version 2+ uses Bech32m', details: { errorCode: types_1.ValidationError.INVALID_FORMAT } };
-            }
-            return { valid: true, blockchain: 'bitcoin', details: { format: 'future', network: 'mainnet' } };
-        }
-        return { valid: false, error: 'Invalid witness version' };
-    };
-    BitcoinValidator.prototype.format = function (address, options) {
-        if (options === null || options === void 0 ? void 0 : options.shorten) {
-            var len = options.shortenLength || 4;
-            return "".concat(address.slice(0, len), "...").concat(address.slice(-len));
-        }
-        return address;
-    };
-    return BitcoinValidator;
-}(base_1.AddressValidator));
-exports.BitcoinValidator = BitcoinValidator;
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/validators/bitcoin.ts.html b/coverage/lcov-report/src/validators/bitcoin.ts.html deleted file mode 100644 index 0db9f6f..0000000 --- a/coverage/lcov-report/src/validators/bitcoin.ts.html +++ /dev/null @@ -1,385 +0,0 @@ - - - - - - Code coverage report for src/validators/bitcoin.ts - - - - - - - - - -
-
-

All files / src/validators bitcoin.ts

-
- -
- 0% - Statements - 0/52 -
- - -
- 0% - Branches - 0/30 -
- - -
- 0% - Functions - 0/4 -
- - -
- 0% - Lines - 0/52 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import { AddressValidator } from './base';
-import { ValidationResult, ValidationOptions, FormatOptions, ValidationError } from '../types';
-import { decodeBase58 } from '../utils/base58';
-import { decodeBech32, Bech32Encoding } from '../utils/bech32';
-import { sha256 } from '../utils/sha256';
- 
-export class BitcoinValidator extends AddressValidator {
-    protected validateImplementation(address: string, options?: ValidationOptions): ValidationResult {
-        // 1. Check Legacy (Starts with 1 or 3, Base58)
-        Iif (address.startsWith('1') || address.startsWith('3')) {
-            return this.validateLegacy(address, options);
-        }
- 
-        // 2. Check SegWit/Taproot (Starts with bc1)
-        Iif (address.toLowerCase().startsWith('bc1')) {
-            return this.validateBech32(address, options);
-        }
- 
-        return { valid: false, error: 'Unknown format', details: { errorCode: ValidationError.INVALID_FORMAT } };
-    }
- 
-    private validateLegacy(address: string, options?: ValidationOptions): ValidationResult {
-        Iif (address.length < 26 || address.length > 35) {
-            return { valid: false, error: 'Invalid length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-        }
-        try {
-            const decoded = decodeBase58(address);
-            Iif (decoded.length !== 25) { // 1 byte version + 20 bytes hash + 4 bytes checksum
-                return { valid: false, error: 'Invalid decoded length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-            }
- 
-            // Checksum Validation
-            const payload = decoded.slice(0, 21);
-            const checksum = decoded.slice(21);
-            const hash1 = sha256(payload);
-            const hash2 = sha256(hash1);
- 
-            Iif (hash2[0] !== checksum[0] || hash2[1] !== checksum[1] || hash2[2] !== checksum[2] || hash2[3] !== checksum[3]) {
-                return { valid: false, error: 'Invalid checksum', details: { errorCode: ValidationError.INVALID_CHECKSUM } };
-            }
- 
-            return { valid: true, blockchain: 'bitcoin', details: { format: 'legacy' } };
-        } catch {
-            return { valid: false, error: 'Invalid Base58', details: { errorCode: ValidationError.INVALID_CHARACTERS } };
-        }
-    }
- 
-    private validateBech32(address: string, options?: ValidationOptions): ValidationResult {
-        const decoded = decodeBech32(address);
-        Iif (!decoded) {
-            return { valid: false, error: 'Invalid Bech32 encoding', details: { errorCode: ValidationError.INVALID_FORMAT } };
-        }
- 
-        Iif (decoded.hrp !== 'bc') {
-            return { valid: false, error: 'Invalid HRP', details: { errorCode: ValidationError.UNSUPPORTED_CHAIN } };
-        }
- 
-        const version = decoded.data[0];
- 
-        // SegWit V0 (P2WPKH / P2WSH)
-        Iif (version === 0) {
-            Iif (decoded.data.length !== 21 && decoded.data.length !== 33) {
-                return { valid: false, error: 'Invalid SegWit program length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-            }
-            Iif (decoded.encoding !== Bech32Encoding.BECH32) {
-                return { valid: false, error: 'V0 uses Bech32', details: { errorCode: ValidationError.INVALID_FORMAT } };
-            }
-            return { valid: true, blockchain: 'bitcoin', details: { format: 'segwit', network: 'mainnet' } };
-        }
- 
-        // Taproot V1 (P2TR)
-        Iif (version === 1) {
-            Iif (decoded.data.length !== 53) { // 1 char version + 32 bytes program (52 chars) = 53
-                return { valid: false, error: 'Invalid Taproot program length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-            }
-            Iif (decoded.encoding !== Bech32Encoding.BECH32M) {
-                return { valid: false, error: 'V1 uses Bech32m', details: { errorCode: ValidationError.INVALID_FORMAT } };
-            }
-            return { valid: true, blockchain: 'bitcoin', details: { format: 'taproot', network: 'mainnet' } };
-        }
- 
-        // Future versions (2-16) allowed by BIP-173/350 but require Bech32m
-        Iif (version >= 2 && version <= 16) {
-            Iif (decoded.encoding !== Bech32Encoding.BECH32M) {
-                return { valid: false, error: 'Version 2+ uses Bech32m', details: { errorCode: ValidationError.INVALID_FORMAT } };
-            }
-            return { valid: true, blockchain: 'bitcoin', details: { format: 'future', network: 'mainnet' } };
-        }
- 
-        return { valid: false, error: 'Invalid witness version' };
-    }
- 
-    format(address: string, options?: FormatOptions): string {
-        Iif (options?.shorten) {
-            const len = options.shortenLength || 4;
-            return `${address.slice(0, len)}...${address.slice(-len)}`;
-        }
-        return address;
-    }
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/validators/ethereum.js.html b/coverage/lcov-report/src/validators/ethereum.js.html deleted file mode 100644 index aae1996..0000000 --- a/coverage/lcov-report/src/validators/ethereum.js.html +++ /dev/null @@ -1,376 +0,0 @@ - - - - - - Code coverage report for src/validators/ethereum.js - - - - - - - - - -
-
-

All files / src/validators ethereum.js

-
- -
- 92.06% - Statements - 58/63 -
- - -
- 81.81% - Branches - 45/55 -
- - -
- 84.61% - Functions - 11/13 -
- - -
- 95% - Lines - 57/60 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98  -6x -6x -6x -  -  -6x -  -6x -6x -  -6x -6x -6x -  -  -6x -6x -6x -6x -6x -6x -6x -6x -  -19x -  -6x -14x -  -14x -2x -  -  -12x -1x -  -  -11x -1x -  -  -10x -8x -3x -  -  -7x -  -  -  -  -  -  -  -  -6x -6x -6x -6x -4x -  -6x -2x -2x -  -4x -  -6x -7x -  -6x -8x -  -8x -1x -  -7x -  -6x -18x -18x -18x -18x -  -720x -348x -  -  -372x -  -  -18x -  -6x -  -6x - 
"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        Iif (typeof b !== "function" && b !== null)
-            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.EthereumValidator = void 0;
-var base_1 = require("./base");
-var types_1 = require("../types");
-var hex_1 = require("../utils/hex");
-var keccak256_1 = require("../utils/keccak256");
-var EthereumValidator = /** @class */ (function (_super) {
-    __extends(EthereumValidator, _super);
-    function EthereumValidator() {
-        return _super !== null && _super.apply(this, arguments) || this;
-    }
-    EthereumValidator.prototype.validateImplementation = function (address, options) {
-        var cleanAddress = (0, hex_1.stripHexPrefix)(address);
-        // Check length
-        if (cleanAddress.length !== 40) {
-            return { valid: false, error: 'Invalid length', details: { errorCode: types_1.ValidationError.INVALID_LENGTH } };
-        }
-        // Check hex
-        if (!(0, hex_1.isHex)(cleanAddress)) {
-            return { valid: false, error: 'Invalid hex characters', details: { errorCode: types_1.ValidationError.INVALID_CHARACTERS } };
-        }
-        // Burn Address Check
-        if (/^0+$/.test(cleanAddress)) {
-            return { valid: false, error: 'Burn address detected', details: { errorCode: types_1.ValidationError.BURN_ADDRESS } };
-        }
-        // Checksum Validation
-        if ((options === null || options === void 0 ? void 0 : options.strict) || (address !== address.toLowerCase() && address !== address.toUpperCase())) {
-            if (!this.checkChecksum(address)) {
-                return { valid: false, error: 'Invalid checksum', details: { errorCode: types_1.ValidationError.INVALID_CHECKSUM } };
-            }
-        }
-        return {
-            valid: true,
-            blockchain: 'ethereum',
-            details: {
-                checksum: this.isChecksummed(address),
-                network: 'mainnet' // Ethereum doesn't distinguish mainnet/testnet by address
-            }
-        };
-    };
-    EthereumValidator.prototype.format = function (address, options) {
-        var clean = (0, hex_1.stripHexPrefix)(address);
-        var formatted = (0, hex_1.addHexPrefix)(clean.toLowerCase());
-        if (options === null || options === void 0 ? void 0 : options.checksum) {
-            formatted = this.toChecksumAddress(formatted);
-        }
-        if (options === null || options === void 0 ? void 0 : options.shorten) {
-            var len = options.shortenLength || 4;
-            return "".concat(formatted.slice(0, 2 + len), "...").concat(formatted.slice(-len));
-        }
-        return formatted;
-    };
-    EthereumValidator.prototype.isChecksummed = function (address) {
-        return address === this.toChecksumAddress(address);
-    };
-    EthereumValidator.prototype.checkChecksum = function (address) {
-        var clean = (0, hex_1.stripHexPrefix)(address);
-        // If all lowercase or all uppercase, it's valid (unless strict mode enforced in caller, but logic here assumes mixed case implies checksum)
-        if (clean === clean.toLowerCase() || clean === clean.toUpperCase()) {
-            return true;
-        }
-        return address === this.toChecksumAddress(address);
-    };
-    EthereumValidator.prototype.toChecksumAddress = function (address) {
-        var clean = (0, hex_1.stripHexPrefix)(address).toLowerCase();
-        var hash = (0, keccak256_1.keccak256)(clean);
-        var checksumAddress = '0x';
-        for (var i = 0; i < clean.length; i++) {
-            // If the ith character of the hash (in hex) is >= 8, uppercase the ith character of the address
-            if (parseInt(hash[i], 16) >= 8) {
-                checksumAddress += clean[i].toUpperCase();
-            }
-            else {
-                checksumAddress += clean[i];
-            }
-        }
-        return checksumAddress;
-    };
-    return EthereumValidator;
-}(base_1.AddressValidator));
-exports.EthereumValidator = EthereumValidator;
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/validators/ethereum.ts.html b/coverage/lcov-report/src/validators/ethereum.ts.html deleted file mode 100644 index de7d56d..0000000 --- a/coverage/lcov-report/src/validators/ethereum.ts.html +++ /dev/null @@ -1,385 +0,0 @@ - - - - - - Code coverage report for src/validators/ethereum.ts - - - - - - - - - -
-
-

All files / src/validators ethereum.ts

-
- -
- 0% - Statements - 0/44 -
- - -
- 0% - Branches - 0/20 -
- - -
- 0% - Functions - 0/5 -
- - -
- 0% - Lines - 0/42 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import { AddressValidator } from './base';
-import { ValidationResult, ValidationOptions, FormatOptions, ValidationError } from '../types';
-import { isHex, stripHexPrefix, addHexPrefix } from '../utils/hex';
-import { keccak256 } from '../utils/keccak256';
- 
-export class EthereumValidator extends AddressValidator {
-    protected validateImplementation(address: string, options?: ValidationOptions): ValidationResult {
-        const cleanAddress = stripHexPrefix(address);
-        // console.error(`DEBUG: Validating ${address} (clean: ${cleanAddress})`);
- 
-        // Check length
-        Iif (cleanAddress.length !== 40) {
-            // console.error(`DEBUG: Failed Length ${cleanAddress.length}`);
-            return { valid: false, error: 'Invalid length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-        }
- 
-        // Check hex
-        Iif (!isHex(cleanAddress)) {
-            // console.error(`DEBUG: Failed Hex`);
-            return { valid: false, error: 'Invalid hex characters', details: { errorCode: ValidationError.INVALID_CHARACTERS } };
-        }
- 
-        // Burn Address Check
-        Iif (/^0+$/.test(cleanAddress)) {
-            // console.error(`DEBUG: Failed Burn`);
-            return { valid: false, error: 'Burn address detected', details: { errorCode: ValidationError.BURN_ADDRESS } };
-        }
- 
-        // Checksum Validation
-        Iif (options?.strict || (cleanAddress !== cleanAddress.toLowerCase() && cleanAddress !== cleanAddress.toUpperCase())) {
-            Iif (!this.checkChecksum(cleanAddress)) {
-                // console.error(`DEBUG: Failed Checksum: clean=${cleanAddress}`);
-                return { valid: false, error: 'Invalid checksum', details: { errorCode: ValidationError.INVALID_CHECKSUM } };
-            }
-        }
- 
-        return {
-            valid: true,
-            blockchain: 'ethereum',
-            details: {
-                checksum: this.isChecksummed(address),
-                network: 'mainnet' // Ethereum doesn't distinguish mainnet/testnet by address
-            }
-        };
-    }
- 
-    format(address: string, options?: FormatOptions): string {
-        let formatted = address.startsWith('0x') ? address : addHexPrefix(address);
- 
-        Iif (options?.checksum) {
-            formatted = this.toChecksumAddress(formatted);
-        }
- 
-        Iif (options?.shorten) {
-            const len = options.shortenLength || 4;
-            return `${formatted.slice(0, 2 + len)}...${formatted.slice(-len)}`;
-        }
- 
-        return formatted;
-    }
- 
-    private isChecksummed(address: string): boolean {
-        const clean = stripHexPrefix(address);
-        return addHexPrefix(clean) === this.toChecksumAddress(clean);
-    }
- 
-    private checkChecksum(address: string): boolean {
-        const clean = stripHexPrefix(address);
- 
-        // all lower or all upper → valid, no checksum claimed
-        Iif (clean === clean.toLowerCase() || clean === clean.toUpperCase()) {
-            return true;
-        }
- 
-        // mixed case → must match EIP-55 checksum
-        const checksummed = stripHexPrefix(this.toChecksumAddress(clean));
-        return clean === checksummed;
-    }
- 
-    private toChecksumAddress(address: string): string {
-        try {
-            Iif (!address) return '';
-            const strip = stripHexPrefix(address).toLowerCase();
-            const hash = keccak256(strip);
-            let ret = '0x';
- 
-            for (let i = 0; i < strip.length; i++) {
-                if (parseInt(hash[i], 16) >= 8) {
-                    ret += strip[i].toUpperCase();
-                } else {
-                    ret += strip[i];
-                }
-            }
-            return ret;
-        } catch (error) {
-            console.error('Checksum error:', error);
-            return address;
-        }
-    }
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/validators/index.html b/coverage/lcov-report/src/validators/index.html deleted file mode 100644 index a867894..0000000 --- a/coverage/lcov-report/src/validators/index.html +++ /dev/null @@ -1,251 +0,0 @@ - - - - - - Code coverage report for src/validators - - - - - - - - - -
-
-

All files src/validators

-
- -
- 49.7% - Statements - 171/344 -
- - -
- 46.61% - Branches - 110/236 -
- - -
- 63.33% - Functions - 38/60 -
- - -
- 51.05% - Lines - 170/333 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
base.js -
-
78.57%11/140%0/2100%3/378.57%11/14
base.ts -
-
0%0/90%0/10%0/10%0/9
bitcoin.js -
-
66.66%46/6950%31/6275%9/1268.65%46/67
bitcoin.ts -
-
0%0/520%0/300%0/40%0/52
ethereum.js -
-
92.06%58/6381.81%45/5584.61%11/1395%57/60
ethereum.ts -
-
0%0/440%0/200%0/50%0/42
polygon.js -
-
81.48%22/2755%11/2077.77%7/988%22/25
polygon.ts -
-
0%0/60%0/10%0/10%0/6
solana.js -
-
82.92%34/4163.88%23/3680%8/1087.17%34/39
solana.ts -
-
0%0/190%0/90%0/20%0/19
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/validators/polygon.js.html b/coverage/lcov-report/src/validators/polygon.js.html deleted file mode 100644 index b1b30fb..0000000 --- a/coverage/lcov-report/src/validators/polygon.js.html +++ /dev/null @@ -1,187 +0,0 @@ - - - - - - Code coverage report for src/validators/polygon.js - - - - - - - - - -
-
-

All files / src/validators polygon.js

-
- -
- 81.48% - Statements - 22/27 -
- - -
- 55% - Branches - 11/20 -
- - -
- 77.77% - Functions - 7/9 -
- - -
- 88% - Lines - 22/25 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35  -6x -6x -6x -  -  -6x -  -6x -6x -  -6x -6x -6x -  -  -6x -6x -6x -6x -6x -  -6x -  -6x -5x -5x -3x -  -5x -  -6x -  -6x - 
"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        Iif (typeof b !== "function" && b !== null)
-            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.PolygonValidator = void 0;
-var ethereum_1 = require("./ethereum");
-var PolygonValidator = /** @class */ (function (_super) {
-    __extends(PolygonValidator, _super);
-    function PolygonValidator() {
-        return _super !== null && _super.apply(this, arguments) || this;
-    }
-    PolygonValidator.prototype.validateImplementation = function (address, options) {
-        var result = _super.prototype.validateImplementation.call(this, address, options);
-        if (result.valid) {
-            result.blockchain = 'polygon';
-        }
-        return result;
-    };
-    return PolygonValidator;
-}(ethereum_1.EthereumValidator));
-exports.PolygonValidator = PolygonValidator;
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/validators/polygon.ts.html b/coverage/lcov-report/src/validators/polygon.ts.html deleted file mode 100644 index 7452591..0000000 --- a/coverage/lcov-report/src/validators/polygon.ts.html +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - Code coverage report for src/validators/polygon.ts - - - - - - - - - -
-
-

All files / src/validators polygon.ts

-
- -
- 0% - Statements - 0/6 -
- - -
- 0% - Branches - 0/1 -
- - -
- 0% - Functions - 0/1 -
- - -
- 0% - Lines - 0/6 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13  -  -  -  -  -  -  -  -  -  -  -  - 
import { EthereumValidator } from './ethereum';
-import { ValidationResult, ValidationOptions } from '../types';
- 
-export class PolygonValidator extends EthereumValidator {
-    protected validateImplementation(address: string, options?: ValidationOptions): ValidationResult {
-        const result = super.validateImplementation(address, options);
-        Iif (result.valid) {
-            result.blockchain = 'polygon';
-        }
-        return result;
-    }
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/validators/solana.js.html b/coverage/lcov-report/src/validators/solana.js.html deleted file mode 100644 index ed71131..0000000 --- a/coverage/lcov-report/src/validators/solana.js.html +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - Code coverage report for src/validators/solana.js - - - - - - - - - -
-
-

All files / src/validators solana.js

-
- -
- 82.92% - Statements - 34/41 -
- - -
- 63.88% - Branches - 23/36 -
- - -
- 80% - Functions - 8/10 -
- - -
- 87.17% - Lines - 34/39 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66  -6x -6x -6x -  -  -6x -  -6x -6x -  -6x -6x -6x -  -  -6x -6x -6x -6x -6x -6x -6x -  -12x -  -6x -6x -2x -  -4x -4x -3x -  -  -  -  -1x -  -  -  -3x -  -  -  -  -1x -1x -  -  -2x -  -  -  -  -6x -1x -1x -1x -  -  -  -6x -  -6x - 
"use strict";
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        Iif (typeof b !== "function" && b !== null)
-            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.SolanaValidator = void 0;
-var base_1 = require("./base");
-var types_1 = require("../types");
-var base58_1 = require("../utils/base58");
-var SolanaValidator = /** @class */ (function (_super) {
-    __extends(SolanaValidator, _super);
-    function SolanaValidator() {
-        return _super !== null && _super.apply(this, arguments) || this;
-    }
-    SolanaValidator.prototype.validateImplementation = function (address, options) {
-        if (address.length < 32 || address.length > 44) {
-            return { valid: false, error: 'Invalid length', details: { errorCode: types_1.ValidationError.INVALID_LENGTH } };
-        }
-        try {
-            var decoded = (0, base58_1.decodeBase58)(address);
-            Iif (decoded.length !== 32) {
-                return { valid: false, error: 'Invalid public key length', details: { errorCode: types_1.ValidationError.INVALID_LENGTH } };
-            }
-        }
-        catch (_a) {
-            return { valid: false, error: 'Invalid Base58 characters', details: { errorCode: types_1.ValidationError.INVALID_FORMAT } };
-        }
-        // Burn check? Solana burn addresses aren't as standard '0x00', but 1111111... is system program
-        // System Program: 11111111111111111111111111111111
-        if (/^1+$/.test(address)) {
-            // Technically valid system account, but maybe warn if it's strictly user wallets?
-            // For now, let's treat it as valid but maybe note it? 
-            // User asked for "burn address detection". System program is effectively special.
-            // Let's flag "11111111111111111111111111111111" specifically if needed.
-            Eif (address === '11111111111111111111111111111111') {
-                return { valid: true, blockchain: 'solana', details: { format: 'System Program' } };
-            }
-        }
-        return {
-            valid: true,
-            blockchain: 'solana'
-        };
-    };
-    SolanaValidator.prototype.format = function (address, options) {
-        Eif (options === null || options === void 0 ? void 0 : options.shorten) {
-            var len = options.shortenLength || 4;
-            return "".concat(address.slice(0, len), "...").concat(address.slice(-len));
-        }
-        return address;
-    };
-    return SolanaValidator;
-}(base_1.AddressValidator));
-exports.SolanaValidator = SolanaValidator;
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/src/validators/solana.ts.html b/coverage/lcov-report/src/validators/solana.ts.html deleted file mode 100644 index 7f052e3..0000000 --- a/coverage/lcov-report/src/validators/solana.ts.html +++ /dev/null @@ -1,220 +0,0 @@ - - - - - - Code coverage report for src/validators/solana.ts - - - - - - - - - -
-
-

All files / src/validators solana.ts

-
- -
- 0% - Statements - 0/19 -
- - -
- 0% - Branches - 0/9 -
- - -
- 0% - Functions - 0/2 -
- - -
- 0% - Lines - 0/19 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import { AddressValidator } from './base';
-import { ValidationResult, ValidationOptions, FormatOptions, ValidationError } from '../types';
-import { decodeBase58 } from '../utils/base58';
- 
-export class SolanaValidator extends AddressValidator {
-    protected validateImplementation(address: string, options?: ValidationOptions): ValidationResult {
-        Iif (address.length < 32 || address.length > 44) {
-            return { valid: false, error: 'Invalid length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-        }
- 
-        try {
-            const decoded = decodeBase58(address);
-            Iif (decoded.length !== 32) {
-                return { valid: false, error: 'Invalid public key length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-            }
-        } catch {
-            return { valid: false, error: 'Invalid Base58 characters', details: { errorCode: ValidationError.INVALID_FORMAT } };
-        }
- 
-        // Burn check? Solana burn addresses aren't as standard '0x00', but 1111111... is system program
-        // System Program: 11111111111111111111111111111111
-        Iif (/^1+$/.test(address)) {
-            // Technically valid system account, but maybe warn if it's strictly user wallets?
-            // For now, let's treat it as valid but maybe note it? 
-            // User asked for "burn address detection". System program is effectively special.
-            // Let's flag "11111111111111111111111111111111" specifically if needed.
-            Iif (address === '11111111111111111111111111111111') {
-                return { valid: true, blockchain: 'solana', details: { format: 'System Program' } };
-            }
-        }
- 
-        return {
-            valid: true,
-            blockchain: 'solana'
-        };
-    }
- 
-    format(address: string, options?: FormatOptions): string {
-        Iif (options?.shorten) {
-            const len = options.shortenLength || 4;
-            return `${address.slice(0, len)}...${address.slice(-len)}`;
-        }
-        return address;
-    }
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/utils/base58.ts.html b/coverage/lcov-report/utils/base58.ts.html deleted file mode 100644 index a467726..0000000 --- a/coverage/lcov-report/utils/base58.ts.html +++ /dev/null @@ -1,517 +0,0 @@ - - - - - - Code coverage report for utils/base58.ts - - - - - - - - - -
-
-

All files / utils base58.ts

-
- -
- 95.31% - Statements - 61/64 -
- - -
- 77.77% - Branches - 7/9 -
- - -
- 100% - Functions - 3/3 -
- - -
- 98.11% - Lines - 52/53 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -14514x -14x -14x -  -14x -14x -812x -  -  -14x -1x -  -1x -  -1x -11x -79x -  -11x -  -11x -11x -79x -79x -79x -  -11x -14x -14x -  -  -  -1x -  -  -  -15x -  -  -14x -24x -  -24x -24x -101x -  -24x -  -24x -  -24x -810x -810x -810x -1x -  -  -809x -13008x -  -809x -  -809x -809x -13008x -13008x -13008x -  -809x -572x -572x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -23x -3x -  -20x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -23x -101x -  -  -23x -  - 
const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
-const BASE = 58;
-const LEADER = ALPHABET.charAt(0);
- 
-const ALPHABET_MAP: { [key: string]: number } = {};
-for (let i = 0; i < ALPHABET.length; i++) {
-    ALPHABET_MAP[ALPHABET.charAt(i)] = i;
-}
- 
-export function encodeBase58(source: Uint8Array): string {
-    Iif (source.length === 0) return '';
- 
-    const digits = [0];
- 
-    for (let i = 0; i < source.length; i++) {
-        for (let j = 0; j < digits.length; j++) {
-            digits[j] <<= 8;
-        }
-        digits[0] += source[i];
- 
-        let carry = 0;
-        for (let j = 0; j < digits.length; ++j) {
-            digits[j] += carry;
-            carry = (digits[j] / BASE) | 0;
-            digits[j] %= BASE;
-        }
-        while (carry) {
-            digits.push(carry % BASE);
-            carry = (carry / BASE) | 0;
-        }
-    }
- 
-    for (let i = 0; i < source.length && source[i] === 0; i++) {
-        digits.push(0);
-    }
- 
-    return digits.reverse().map(d => ALPHABET[d]).join('');
-}
- 
-export function decodeBase58(string: string): Uint8Array {
-    Iif (string.length === 0) return new Uint8Array(0);
- 
-    let i = 0;
-    while (i < string.length && string[i] === LEADER) {
-        i++;
-    }
-    const leaders = i;
- 
-    const bytes = [0];
- 
-    for (; i < string.length; i++) {
-        const char = string[i];
-        const value = ALPHABET_MAP[char];
-        if (value === undefined) {
-            throw new Error(`Invalid Base58 character: ${char}`);
-        }
- 
-        for (let j = 0; j < bytes.length; j++) {
-            bytes[j] *= BASE;
-        }
-        bytes[0] += value;
- 
-        let carry = 0;
-        for (let j = 0; j < bytes.length; ++j) {
-            bytes[j] += carry;
-            carry = bytes[j] >> 8;
-            bytes[j] &= 0xff;
-        }
-        while (carry) {
-            bytes.push(carry & 0xff);
-            carry >>= 8;
-        }
-    }
- 
-    // If there are no bytes (e.g. input was all '1's), bytes is [0]. 
-    // We want to discard it if it was just the placeholder.
-    // But if it was "all 1s", i reached end. loop didn't run. bytes=[0].
-    // leaders > 0.
-    // Result should be [0...0] (leaders count).
-    // If loop DID run, bytes contains the number.
-    // We should reverse bytes.
-    // Leading zeros (high bytes) in `bytes` accumulator should usually not exist due to normalization?
-    // `bytes` accumulator is little endian 256-base. [low, high].
-    // If we have `bytes=[0]`, and loop ran?
-    // If we entered loop, we added value.
-    // If we added 0 (from char '1'), but we skipped leaders. So char != '1'.
-    // So value > 0.
-    // So bytes[0] += value > 0.
-    // So `bytes` is not `[0]`.
-    // So if loop ran, `bytes` is valid number bytes.
- 
-    // What if loop didn't run (all leaders)?
-    // bytes is [0].
-    // We should just use empty suffix.
- 
-    let resultBytes: number[];
-    if (string.length === leaders) {
-        resultBytes = [];
-    } else {
-        resultBytes = bytes.reverse();
-        // Remove leading zero ONLY if it's the extra 0 from initialization?
-        // Wait. `bytes` logic is `push` on carry.
-        // If we initialized with `[0]`.
-        // And we did math.
-        // `bytes` usually doesn't have extra zeros at end (high) unless they were pushed?
-        // But we started with `[0]`.
-        // If result is `255`, `bytes=[255]`. Reverse `[255]`.
-        // If result is `256`, `bytes=[0, 1]`. Reverse `[1, 0]`.
-        // Does `bytes` ever have `[..., 0]`?
-        // Only if `carry` pushed 0? Impossible. carry > 0.
-        // Or if `bytes` remained `[0]` (handled by all-leaders check).
- 
-        // But wait. `bytes` started as `[0]`.
-        // If we computed `256`. `bytes=[0]`.
-        // `bytes[0]*58`.
-        // ...
-        // If we reversed `bytes`, and `bytes` was `[0, 1]`. -> `[1, 0]`. Matches.
-        // What if `bytes` was `[0]`? -> `[0]`.
-        // But we said loop implies value > 0.
-        // So `bytes` != `[0]`.
-        // BUT if we have code like `bytes[0]`...
-        // Is it possible `bytes` has a high-order zero `[255, 0]`?
-        // `bytes` grows only on carry.
-        // If carry is pushed, it's non-zero (while(carry)).
-        // So no high-order zeros.
-        // EXCEPT the initial `0` if it wasn't overwritten or growing.
-        // `bytes[0] += value`.
-        // If `bytes.length == 1` and `bytes[0]` becomes non-zero, fine.
-        // If `bytes` grows, `bytes[0]` might be 0.
-        // High order is at `bytes[length-1]`.
-        // Since push only happens on non-zero carry, the last element is non-zero.
-        // So `bytes` is canonical.
- 
-        // So just `bytes.reverse()` is correct.
-        // EXCEPT if `bytes` is `[0]` (loop ran but value is 0? Impossible).
-    }
- 
-    // Prepend leaders
-    for (let k = 0; k < leaders; k++) {
-        resultBytes.unshift(0);
-    }
- 
-    return new Uint8Array(resultBytes);
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/utils/bech32.ts.html b/coverage/lcov-report/utils/bech32.ts.html deleted file mode 100644 index a5e52dd..0000000 --- a/coverage/lcov-report/utils/bech32.ts.html +++ /dev/null @@ -1,316 +0,0 @@ - - - - - - Code coverage report for utils/bech32.ts - - - - - - - - - -
-
-

All files / utils bech32.ts

-
- -
- 97.87% - Statements - 46/47 -
- - -
- 94.11% - Branches - 16/17 -
- - -
- 100% - Functions - 5/5 -
- - -
- 100% - Lines - 39/39 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -7815x -  -15x -15x -15x -  -  -15x -  -  -18x -18x -1104x -1104x -1104x -5520x -2522x -  -  -  -18x -  -  -  -18x -18x -56x -  -18x -18x -56x -  -18x -  -  -  -18x -18x -  -  -  -  -  -  -  -  -15x -15x -14x -  -  -14x -  -13x -13x -  -12x -  -12x -12x -651x -651x -651x -  -  -  -12x -6x -  -  -  -6x -1x -  -  -5x -  - 
export const BECH32_ALPHABET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l';
- 
-export enum Bech32Encoding {
-    BECH32 = 'bech32',
-    BECH32M = 'bech32m',
-}
- 
-const GENERATOR = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3];
- 
-function polymod(values: number[]): number {
-    let chk = 1;
-    for (const v of values) {
-        const top = chk >> 25;
-        chk = ((chk & 0x1ffffff) << 5) ^ v;
-        for (let i = 0; i < 5; i++) {
-            if ((top >> i) & 1) {
-                chk ^= GENERATOR[i];
-            }
-        }
-    }
-    return chk;
-}
- 
-function hrpExpand(hrp: string): number[] {
-    const ret: number[] = [];
-    for (let i = 0; i < hrp.length; i++) {
-        ret.push(hrp.charCodeAt(i) >> 5);
-    }
-    ret.push(0);
-    for (let i = 0; i < hrp.length; i++) {
-        ret.push(hrp.charCodeAt(i) & 31);
-    }
-    return ret;
-}
- 
-function verifyChecksum(hrp: string, data: number[], encoding: Bech32Encoding): boolean {
-    const constValue = encoding === Bech32Encoding.BECH32M ? 0x2bc830a3 : 1;
-    return polymod(hrpExpand(hrp).concat(data)) === constValue;
-}
- 
-export interface Decoded {
-    hrp: string;
-    data: number[];
-    encoding: Bech32Encoding;
-}
- 
-export function decodeBech32(str: string): Decoded | null {
-    if (str.length < 8 || str.length > 1024) return null;
-    const lower = str.toLowerCase();
- 
-    // Mixed case check
-    if (str !== lower && str !== str.toUpperCase()) return null;
- 
-    const pos = lower.lastIndexOf('1');
-    if (pos < 1 || pos + 7 > lower.length) return null;
- 
-    const hrp = lower.substring(0, pos);
- 
-    const data: number[] = [];
-    for (let i = pos + 1; i < lower.length; i++) {
-        const d = BECH32_ALPHABET.indexOf(lower[i]);
-        Iif (d === -1) return null;
-        data.push(d);
-    }
- 
-    // Try Bech32
-    if (verifyChecksum(hrp, data, Bech32Encoding.BECH32)) {
-        return { hrp, data: data.slice(0, data.length - 6), encoding: Bech32Encoding.BECH32 };
-    }
- 
-    // Try Bech32m
-    if (verifyChecksum(hrp, data, Bech32Encoding.BECH32M)) {
-        return { hrp, data: data.slice(0, data.length - 6), encoding: Bech32Encoding.BECH32M };
-    }
- 
-    return null;
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/utils/hex.ts.html b/coverage/lcov-report/utils/hex.ts.html deleted file mode 100644 index ea1d1c9..0000000 --- a/coverage/lcov-report/utils/hex.ts.html +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - Code coverage report for utils/hex.ts - - - - - - - - - -
-
-

All files / utils hex.ts

-
- -
- 81.81% - Statements - 9/11 -
- - -
- 70% - Branches - 7/10 -
- - -
- 100% - Functions - 3/3 -
- - -
- 90% - Lines - 9/10 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -2314x -28x -  -  -28x -  -  -28x -  -  -  -  -28x -  -  -14x -96x -  -  -14x -22x -  - 
export function isHex(str: string, length?: number): boolean {
-    Iif (typeof str !== 'string') return false;
- 
-    // Remove 0x prefix if present
-    const cleanStr = str.startsWith('0x') ? str.slice(2) : str;
- 
-    // Check length if specified
-    Iif (length !== undefined && cleanStr.length !== length) {
-        return false;
-    }
- 
-    // Check for valid hex characters
-    return /^[0-9a-fA-F]*$/.test(cleanStr);
-}
- 
-export function stripHexPrefix(str: string): string {
-    return str.startsWith('0x') ? str.slice(2) : str;
-}
- 
-export function addHexPrefix(str: string): string {
-    return str.startsWith('0x') ? str : `0x${str}`;
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/utils/index.html b/coverage/lcov-report/utils/index.html deleted file mode 100644 index 43dc89d..0000000 --- a/coverage/lcov-report/utils/index.html +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - Code coverage report for utils - - - - - - - - - -
-
-

All files utils

-
- -
- 95.08% - Statements - 116/122 -
- - -
- 83.33% - Branches - 30/36 -
- - -
- 100% - Functions - 11/11 -
- - -
- 98.03% - Lines - 100/102 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
base58.ts -
-
95.31%61/6477.77%7/9100%3/398.11%52/53
bech32.ts -
-
97.87%46/4794.11%16/17100%5/5100%39/39
hex.ts -
-
81.81%9/1170%7/10100%3/390%9/10
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/utils/keccak256.ts.html b/coverage/lcov-report/utils/keccak256.ts.html deleted file mode 100644 index 1c346c1..0000000 --- a/coverage/lcov-report/utils/keccak256.ts.html +++ /dev/null @@ -1,2020 +0,0 @@ - - - - - - Code coverage report for utils/keccak256.ts - - - - - - - - - -
-
-

All files / utils keccak256.ts

-
- -
- 0% - Statements - 0/502 -
- - -
- 0% - Branches - 0/96 -
- - -
- 0% - Functions - 0/39 -
- - -
- 0% - Lines - 0/473 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307 -308 -309 -310 -311 -312 -313 -314 -315 -316 -317 -318 -319 -320 -321 -322 -323 -324 -325 -326 -327 -328 -329 -330 -331 -332 -333 -334 -335 -336 -337 -338 -339 -340 -341 -342 -343 -344 -345 -346 -347 -348 -349 -350 -351 -352 -353 -354 -355 -356 -357 -358 -359 -360 -361 -362 -363 -364 -365 -366 -367 -368 -369 -370 -371 -372 -373 -374 -375 -376 -377 -378 -379 -380 -381 -382 -383 -384 -385 -386 -387 -388 -389 -390 -391 -392 -393 -394 -395 -396 -397 -398 -399 -400 -401 -402 -403 -404 -405 -406 -407 -408 -409 -410 -411 -412 -413 -414 -415 -416 -417 -418 -419 -420 -421 -422 -423 -424 -425 -426 -427 -428 -429 -430 -431 -432 -433 -434 -435 -436 -437 -438 -439 -440 -441 -442 -443 -444 -445 -446 -447 -448 -449 -450 -451 -452 -453 -454 -455 -456 -457 -458 -459 -460 -461 -462 -463 -464 -465 -466 -467 -468 -469 -470 -471 -472 -473 -474 -475 -476 -477 -478 -479 -480 -481 -482 -483 -484 -485 -486 -487 -488 -489 -490 -491 -492 -493 -494 -495 -496 -497 -498 -499 -500 -501 -502 -503 -504 -505 -506 -507 -508 -509 -510 -511 -512 -513 -514 -515 -516 -517 -518 -519 -520 -521 -522 -523 -524 -525 -526 -527 -528 -529 -530 -531 -532 -533 -534 -535 -536 -537 -538 -539 -540 -541 -542 -543 -544 -545 -546 -547 -548 -549 -550 -551 -552 -553 -554 -555 -556 -557 -558 -559 -560 -561 -562 -563 -564 -565 -566 -567 -568 -569 -570 -571 -572 -573 -574 -575 -576 -577 -578 -579 -580 -581 -582 -583 -584 -585 -586 -587 -588 -589 -590 -591 -592 -593 -594 -595 -596 -597 -598 -599 -600 -601 -602 -603 -604 -605 -606 -607 -608 -609 -610 -611 -612 -613 -614 -615 -616 -617 -618 -619 -620 -621 -622 -623 -624 -625 -626 -627 -628 -629 -630 -631 -632 -633 -634 -635 -636 -637 -638 -639 -640 -641 -642 -643 -644 -645 -646  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
/* eslint-disable */
-// @ts-nocheck
- 
-const methods = (function () {
-    'use strict';
- 
-    var INPUT_ERROR = 'input is invalid type';
-    var FINALIZE_ERROR = 'finalize already called';
-    var WINDOW = typeof window === 'object';
-    var root = WINDOW ? window : {};
-    Iif (root.JS_SHA3_NO_WINDOW) {
-        WINDOW = false;
-    }
-    var WEB_WORKER = !WINDOW && typeof self === 'object';
-    var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
-    if (NODE_JS) {
-        root = global;
-    } else Iif (WEB_WORKER) {
-        root = self;
-    }
-    var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && typeof module === 'object' && module.exports;
-    var AMD = typeof define === 'function' && define.amd;
-    var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';
-    var HEX_CHARS = '0123456789abcdef'.split('');
-    var SHAKE_PADDING = [31, 7936, 2031616, 520093696];
-    var CSHAKE_PADDING = [4, 1024, 262144, 67108864];
-    var KECCAK_PADDING = [1, 256, 65536, 16777216];
-    var PADDING = [6, 1536, 393216, 100663296];
-    var SHIFT = [0, 8, 16, 24];
-    var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649,
-        0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0,
-        2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771,
-        2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648,
-        2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648];
-    var BITS = [224, 256, 384, 512];
-    var SHAKE_BITS = [128, 256];
-    var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest'];
-    var CSHAKE_BYTEPAD = {
-        '128': 168,
-        '256': 136
-    };
- 
-    var isArray = root.JS_SHA3_NO_NODE_JS || !Array.isArray
-        ? function (obj) {
-            return Object.prototype.toString.call(obj) === '[object Array]';
-        }
-        : Array.isArray;
- 
-    var isView = (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView))
-        ? function (obj) {
-            return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;
-        }
-        : ArrayBuffer.isView;
- 
-    var formatMessage = function (message) {
-        var type = typeof message;
-        Iif (type === 'string') {
-            return [message, true];
-        }
-        Iif (type !== 'object' || message === null) {
-            throw new Error(INPUT_ERROR);
-        }
-        Iif (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
-            return [new Uint8Array(message), false];
-        }
-        Iif (!isArray(message) && !isView(message)) {
-            throw new Error(INPUT_ERROR);
-        }
-        return [message, false];
-    };
- 
-    var empty = function (message) {
-        return formatMessage(message)[0].length === 0;
-    };
- 
-    var cloneArray = function (array) {
-        var newArray = [];
-        for (var i = 0; i < array.length; ++i) {
-            newArray[i] = array[i];
-        }
-        return newArray;
-    };
- 
-    var createOutputMethod = function (bits, padding, outputType) {
-        return function (message) {
-            return new Keccak(bits, padding, bits).update(message)[outputType]();
-        };
-    };
- 
-    var createShakeOutputMethod = function (bits, padding, outputType) {
-        return function (message, outputBits) {
-            return new Keccak(bits, padding, outputBits).update(message)[outputType]();
-        };
-    };
- 
-    var createCshakeOutputMethod = function (bits, padding, outputType) {
-        return function (message, outputBits, n, s) {
-            return methods['cshake' + bits].update(message, outputBits, n, s)[outputType]();
-        };
-    };
- 
-    var createKmacOutputMethod = function (bits, padding, outputType) {
-        return function (key, message, outputBits, s) {
-            return methods['kmac' + bits].update(key, message, outputBits, s)[outputType]();
-        };
-    };
- 
-    var createOutputMethods = function (method, createMethod, bits, padding) {
-        for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
-            var type = OUTPUT_TYPES[i];
-            method[type] = createMethod(bits, padding, type);
-        }
-        return method;
-    };
- 
-    var createMethod = function (bits, padding) {
-        var method = createOutputMethod(bits, padding, 'hex');
-        method.create = function () {
-            return new Keccak(bits, padding, bits);
-        };
-        method.update = function (message) {
-            return method.create().update(message);
-        };
-        return createOutputMethods(method, createOutputMethod, bits, padding);
-    };
- 
-    var createShakeMethod = function (bits, padding) {
-        var method = createShakeOutputMethod(bits, padding, 'hex');
-        method.create = function (outputBits) {
-            return new Keccak(bits, padding, outputBits);
-        };
-        method.update = function (message, outputBits) {
-            return method.create(outputBits).update(message);
-        };
-        return createOutputMethods(method, createShakeOutputMethod, bits, padding);
-    };
- 
-    var createCshakeMethod = function (bits, padding) {
-        var w = CSHAKE_BYTEPAD[bits];
-        var method = createCshakeOutputMethod(bits, padding, 'hex');
-        method.create = function (outputBits, n, s) {
-            if (empty(n) && empty(s)) {
-                return methods['shake' + bits].create(outputBits);
-            } else {
-                return new Keccak(bits, padding, outputBits).bytepad([n, s], w);
-            }
-        };
-        method.update = function (message, outputBits, n, s) {
-            return method.create(outputBits, n, s).update(message);
-        };
-        return createOutputMethods(method, createCshakeOutputMethod, bits, padding);
-    };
- 
-    var createKmacMethod = function (bits, padding) {
-        var w = CSHAKE_BYTEPAD[bits];
-        var method = createKmacOutputMethod(bits, padding, 'hex');
-        method.create = function (key, outputBits, s) {
-            return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w);
-        };
-        method.update = function (key, message, outputBits, s) {
-            return method.create(key, outputBits, s).update(message);
-        };
-        return createOutputMethods(method, createKmacOutputMethod, bits, padding);
-    };
- 
-    var algorithms = [
-        { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod },
-        { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod },
-        { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod },
-        { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod },
-        { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod }
-    ];
- 
-    var methods = {}, methodNames = [];
- 
-    for (var i = 0; i < algorithms.length; ++i) {
-        var algorithm = algorithms[i];
-        var bits = algorithm.bits;
-        for (var j = 0; j < bits.length; ++j) {
-            var methodName = algorithm.name + '_' + bits[j];
-            methodNames.push(methodName);
-            methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding);
-            Iif (algorithm.name !== 'sha3') {
-                var newMethodName = algorithm.name + bits[j];
-                methodNames.push(newMethodName);
-                methods[newMethodName] = methods[methodName];
-            }
-        }
-    }
- 
-    function Keccak(bits, padding, outputBits) {
-        this.blocks = [];
-        this.s = [];
-        this.padding = padding;
-        this.outputBits = outputBits;
-        this.reset = true;
-        this.finalized = false;
-        this.block = 0;
-        this.start = 0;
-        this.blockCount = (1600 - (bits << 1)) >> 5;
-        this.byteCount = this.blockCount << 2;
-        this.outputBlocks = outputBits >> 5;
-        this.extraBytes = (outputBits & 31) >> 3;
- 
-        for (var i = 0; i < 50; ++i) {
-            this.s[i] = 0;
-        }
-    }
- 
-    Keccak.prototype.update = function (message) {
-        Iif (this.finalized) {
-            throw new Error(FINALIZE_ERROR);
-        }
-        var result = formatMessage(message);
-        message = result[0];
-        var isString = result[1];
-        var blocks = this.blocks, byteCount = this.byteCount, length = message.length,
-            blockCount = this.blockCount, index = 0, s = this.s, i, code;
- 
-        while (index < length) {
-            Iif (this.reset) {
-                this.reset = false;
-                blocks[0] = this.block;
-                for (i = 1; i < blockCount + 1; ++i) {
-                    blocks[i] = 0;
-                }
-            }
-            if (isString) {
-                for (i = this.start; index < length && i < byteCount; ++index) {
-                    code = message.charCodeAt(index);
-                    if (code < 0x80) {
-                        blocks[i >> 2] |= code << SHIFT[i++ & 3];
-                    } else if (code < 0x800) {
-                        blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
-                    } else if (code < 0xd800 || code >= 0xe000) {
-                        blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
-                    } else {
-                        code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
-                        blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
-                        blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
-                    }
-                }
-            } else {
-                for (i = this.start; index < length && i < byteCount; ++index) {
-                    blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
-                }
-            }
-            this.lastByteIndex = i;
-            if (i >= byteCount) {
-                this.start = i - byteCount;
-                this.block = blocks[blockCount];
-                for (i = 0; i < blockCount; ++i) {
-                    s[i] ^= blocks[i];
-                }
-                f(s);
-                this.reset = true;
-            } else {
-                this.start = i;
-            }
-        }
-        return this;
-    };
- 
-    Keccak.prototype.encode = function (x, right) {
-        var o = x & 255, n = 1;
-        var bytes = [o];
-        x = x >> 8;
-        o = x & 255;
-        while (o > 0) {
-            bytes.unshift(o);
-            x = x >> 8;
-            o = x & 255;
-            ++n;
-        }
-        if (right) {
-            bytes.push(n);
-        } else {
-            bytes.unshift(n);
-        }
-        this.update(bytes);
-        return bytes.length;
-    };
- 
-    Keccak.prototype.encodeString = function (str) {
-        var result = formatMessage(str);
-        str = result[0];
-        var isString = result[1];
-        var bytes = 0, length = str.length;
-        if (isString) {
-            for (var i = 0; i < str.length; ++i) {
-                var code = str.charCodeAt(i);
-                if (code < 0x80) {
-                    bytes += 1;
-                } else if (code < 0x800) {
-                    bytes += 2;
-                } else if (code < 0xd800 || code >= 0xe000) {
-                    bytes += 3;
-                } else {
-                    code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff));
-                    bytes += 4;
-                }
-            }
-        } else {
-            bytes = length;
-        }
-        bytes += this.encode(bytes * 8);
-        this.update(str);
-        return bytes;
-    };
- 
-    Keccak.prototype.bytepad = function (strs, w) {
-        var bytes = this.encode(w);
-        for (var i = 0; i < strs.length; ++i) {
-            bytes += this.encodeString(strs[i]);
-        }
-        var paddingBytes = (w - bytes % w) % w;
-        var zeros = [];
-        zeros.length = paddingBytes;
-        this.update(zeros);
-        return this;
-    };
- 
-    Keccak.prototype.finalize = function () {
-        Iif (this.finalized) {
-            return;
-        }
-        this.finalized = true;
-        var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;
-        blocks[i >> 2] |= this.padding[i & 3];
-        Iif (this.lastByteIndex === this.byteCount) {
-            blocks[0] = blocks[blockCount];
-            for (i = 1; i < blockCount + 1; ++i) {
-                blocks[i] = 0;
-            }
-        }
-        blocks[blockCount - 1] |= 0x80000000;
-        for (i = 0; i < blockCount; ++i) {
-            s[i] ^= blocks[i];
-        }
-        f(s);
-    };
- 
-    Keccak.prototype.toString = Keccak.prototype.hex = function () {
-        this.finalize();
- 
-        var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,
-            extraBytes = this.extraBytes, i = 0, j = 0;
-        var hex = '', block;
-        while (j < outputBlocks) {
-            for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
-                block = s[i];
-                hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] +
-                    HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] +
-                    HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] +
-                    HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];
-            }
-            Iif (j % blockCount === 0) {
-                s = cloneArray(s);
-                f(s);
-                i = 0;
-            }
-        }
-        Iif (extraBytes) {
-            block = s[i];
-            hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F];
-            Iif (extraBytes > 1) {
-                hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F];
-            }
-            Iif (extraBytes > 2) {
-                hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F];
-            }
-        }
-        return hex;
-    };
- 
-    Keccak.prototype.arrayBuffer = function () {
-        this.finalize();
- 
-        var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,
-            extraBytes = this.extraBytes, i = 0, j = 0;
-        var bytes = this.outputBits >> 3;
-        var buffer;
-        if (extraBytes) {
-            buffer = new ArrayBuffer((outputBlocks + 1) << 2);
-        } else {
-            buffer = new ArrayBuffer(bytes);
-        }
-        var array = new Uint32Array(buffer);
-        while (j < outputBlocks) {
-            for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
-                array[j] = s[i];
-            }
-            Iif (j % blockCount === 0) {
-                s = cloneArray(s);
-                f(s);
-            }
-        }
-        Iif (extraBytes) {
-            array[j] = s[i];
-            buffer = buffer.slice(0, bytes);
-        }
-        return buffer;
-    };
- 
-    Keccak.prototype.buffer = Keccak.prototype.arrayBuffer;
- 
-    Keccak.prototype.digest = Keccak.prototype.array = function () {
-        this.finalize();
- 
-        var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,
-            extraBytes = this.extraBytes, i = 0, j = 0;
-        var array = [], offset, block;
-        while (j < outputBlocks) {
-            for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
-                offset = j << 2;
-                block = s[i];
-                array[offset] = block & 0xFF;
-                array[offset + 1] = (block >> 8) & 0xFF;
-                array[offset + 2] = (block >> 16) & 0xFF;
-                array[offset + 3] = (block >> 24) & 0xFF;
-            }
-            Iif (j % blockCount === 0) {
-                s = cloneArray(s);
-                f(s);
-            }
-        }
-        Iif (extraBytes) {
-            offset = j << 2;
-            block = s[i];
-            array[offset] = block & 0xFF;
-            Iif (extraBytes > 1) {
-                array[offset + 1] = (block >> 8) & 0xFF;
-            }
-            Iif (extraBytes > 2) {
-                array[offset + 2] = (block >> 16) & 0xFF;
-            }
-        }
-        return array;
-    };
- 
-    function Kmac(bits, padding, outputBits) {
-        Keccak.call(this, bits, padding, outputBits);
-    }
- 
-    Kmac.prototype = new Keccak();
- 
-    Kmac.prototype.finalize = function () {
-        this.encode(this.outputBits, true);
-        return Keccak.prototype.finalize.call(this);
-    };
- 
-    var f = function (s) {
-        var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9,
-            b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17,
-            b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33,
-            b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;
-        for (n = 0; n < 48; n += 2) {
-            c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];
-            c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];
-            c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];
-            c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];
-            c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];
-            c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];
-            c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];
-            c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];
-            c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];
-            c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];
- 
-            h = c8 ^ ((c2 << 1) | (c3 >>> 31));
-            l = c9 ^ ((c3 << 1) | (c2 >>> 31));
-            s[0] ^= h;
-            s[1] ^= l;
-            s[10] ^= h;
-            s[11] ^= l;
-            s[20] ^= h;
-            s[21] ^= l;
-            s[30] ^= h;
-            s[31] ^= l;
-            s[40] ^= h;
-            s[41] ^= l;
-            h = c0 ^ ((c4 << 1) | (c5 >>> 31));
-            l = c1 ^ ((c5 << 1) | (c4 >>> 31));
-            s[2] ^= h;
-            s[3] ^= l;
-            s[12] ^= h;
-            s[13] ^= l;
-            s[22] ^= h;
-            s[23] ^= l;
-            s[32] ^= h;
-            s[33] ^= l;
-            s[42] ^= h;
-            s[43] ^= l;
-            h = c2 ^ ((c6 << 1) | (c7 >>> 31));
-            l = c3 ^ ((c7 << 1) | (c6 >>> 31));
-            s[4] ^= h;
-            s[5] ^= l;
-            s[14] ^= h;
-            s[15] ^= l;
-            s[24] ^= h;
-            s[25] ^= l;
-            s[34] ^= h;
-            s[35] ^= l;
-            s[44] ^= h;
-            s[45] ^= l;
-            h = c4 ^ ((c8 << 1) | (c9 >>> 31));
-            l = c5 ^ ((c9 << 1) | (c8 >>> 31));
-            s[6] ^= h;
-            s[7] ^= l;
-            s[16] ^= h;
-            s[17] ^= l;
-            s[26] ^= h;
-            s[27] ^= l;
-            s[36] ^= h;
-            s[37] ^= l;
-            s[46] ^= h;
-            s[47] ^= l;
-            h = c6 ^ ((c0 << 1) | (c1 >>> 31));
-            l = c7 ^ ((c1 << 1) | (c0 >>> 31));
-            s[8] ^= h;
-            s[9] ^= l;
-            s[18] ^= h;
-            s[19] ^= l;
-            s[28] ^= h;
-            s[29] ^= l;
-            s[38] ^= h;
-            s[39] ^= l;
-            s[48] ^= h;
-            s[49] ^= l;
- 
-            b0 = s[0];
-            b1 = s[1];
-            b32 = (s[11] << 4) | (s[10] >>> 28);
-            b33 = (s[10] << 4) | (s[11] >>> 28);
-            b14 = (s[20] << 3) | (s[21] >>> 29);
-            b15 = (s[21] << 3) | (s[20] >>> 29);
-            b46 = (s[31] << 9) | (s[30] >>> 23);
-            b47 = (s[30] << 9) | (s[31] >>> 23);
-            b28 = (s[40] << 18) | (s[41] >>> 14);
-            b29 = (s[41] << 18) | (s[40] >>> 14);
-            b20 = (s[2] << 1) | (s[3] >>> 31);
-            b21 = (s[3] << 1) | (s[2] >>> 31);
-            b2 = (s[13] << 12) | (s[12] >>> 20);
-            b3 = (s[12] << 12) | (s[13] >>> 20);
-            b34 = (s[22] << 10) | (s[23] >>> 22);
-            b35 = (s[23] << 10) | (s[22] >>> 22);
-            b16 = (s[33] << 13) | (s[32] >>> 19);
-            b17 = (s[32] << 13) | (s[33] >>> 19);
-            b48 = (s[42] << 2) | (s[43] >>> 30);
-            b49 = (s[43] << 2) | (s[42] >>> 30);
-            b40 = (s[5] << 30) | (s[4] >>> 2);
-            b41 = (s[4] << 30) | (s[5] >>> 2);
-            b22 = (s[14] << 6) | (s[15] >>> 26);
-            b23 = (s[15] << 6) | (s[14] >>> 26);
-            b4 = (s[25] << 11) | (s[24] >>> 21);
-            b5 = (s[24] << 11) | (s[25] >>> 21);
-            b36 = (s[34] << 15) | (s[35] >>> 17);
-            b37 = (s[35] << 15) | (s[34] >>> 17);
-            b18 = (s[45] << 29) | (s[44] >>> 3);
-            b19 = (s[44] << 29) | (s[45] >>> 3);
-            b10 = (s[6] << 28) | (s[7] >>> 4);
-            b11 = (s[7] << 28) | (s[6] >>> 4);
-            b42 = (s[17] << 23) | (s[16] >>> 9);
-            b43 = (s[16] << 23) | (s[17] >>> 9);
-            b24 = (s[26] << 25) | (s[27] >>> 7);
-            b25 = (s[27] << 25) | (s[26] >>> 7);
-            b6 = (s[36] << 21) | (s[37] >>> 11);
-            b7 = (s[37] << 21) | (s[36] >>> 11);
-            b38 = (s[47] << 24) | (s[46] >>> 8);
-            b39 = (s[46] << 24) | (s[47] >>> 8);
-            b30 = (s[8] << 27) | (s[9] >>> 5);
-            b31 = (s[9] << 27) | (s[8] >>> 5);
-            b12 = (s[18] << 20) | (s[19] >>> 12);
-            b13 = (s[19] << 20) | (s[18] >>> 12);
-            b44 = (s[29] << 7) | (s[28] >>> 25);
-            b45 = (s[28] << 7) | (s[29] >>> 25);
-            b26 = (s[38] << 8) | (s[39] >>> 24);
-            b27 = (s[39] << 8) | (s[38] >>> 24);
-            b8 = (s[48] << 14) | (s[49] >>> 18);
-            b9 = (s[49] << 14) | (s[48] >>> 18);
- 
-            s[0] = b0 ^ (~b2 & b4);
-            s[1] = b1 ^ (~b3 & b5);
-            s[10] = b10 ^ (~b12 & b14);
-            s[11] = b11 ^ (~b13 & b15);
-            s[20] = b20 ^ (~b22 & b24);
-            s[21] = b21 ^ (~b23 & b25);
-            s[30] = b30 ^ (~b32 & b34);
-            s[31] = b31 ^ (~b33 & b35);
-            s[40] = b40 ^ (~b42 & b44);
-            s[41] = b41 ^ (~b43 & b45);
-            s[2] = b2 ^ (~b4 & b6);
-            s[3] = b3 ^ (~b5 & b7);
-            s[12] = b12 ^ (~b14 & b16);
-            s[13] = b13 ^ (~b15 & b17);
-            s[22] = b22 ^ (~b24 & b26);
-            s[23] = b23 ^ (~b25 & b27);
-            s[32] = b32 ^ (~b34 & b36);
-            s[33] = b33 ^ (~b35 & b37);
-            s[42] = b42 ^ (~b44 & b46);
-            s[43] = b43 ^ (~b45 & b47);
-            s[4] = b4 ^ (~b6 & b8);
-            s[5] = b5 ^ (~b7 & b9);
-            s[14] = b14 ^ (~b16 & b18);
-            s[15] = b15 ^ (~b17 & b19);
-            s[24] = b24 ^ (~b26 & b28);
-            s[25] = b25 ^ (~b27 & b29);
-            s[34] = b34 ^ (~b36 & b38);
-            s[35] = b35 ^ (~b37 & b39);
-            s[44] = b44 ^ (~b46 & b48);
-            s[45] = b45 ^ (~b47 & b49);
-            s[6] = b6 ^ (~b8 & b0);
-            s[7] = b7 ^ (~b9 & b1);
-            s[16] = b16 ^ (~b18 & b10);
-            s[17] = b17 ^ (~b19 & b11);
-            s[26] = b26 ^ (~b28 & b20);
-            s[27] = b27 ^ (~b29 & b21);
-            s[36] = b36 ^ (~b38 & b30);
-            s[37] = b37 ^ (~b39 & b31);
-            s[46] = b46 ^ (~b48 & b40);
-            s[47] = b47 ^ (~b49 & b41);
-            s[8] = b8 ^ (~b0 & b2);
-            s[9] = b9 ^ (~b1 & b3);
-            s[18] = b18 ^ (~b10 & b12);
-            s[19] = b19 ^ (~b11 & b13);
-            s[28] = b28 ^ (~b20 & b22);
-            s[29] = b29 ^ (~b21 & b23);
-            s[38] = b38 ^ (~b30 & b32);
-            s[39] = b39 ^ (~b31 & b33);
-            s[48] = b48 ^ (~b40 & b42);
-            s[49] = b49 ^ (~b41 & b43);
- 
-            s[0] ^= RC[n];
-            s[1] ^= RC[n + 1];
-        }
-    };
- 
-    return methods;
-})();
- 
-export const keccak256 = methods.keccak_256;
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/utils/sha256.ts.html b/coverage/lcov-report/utils/sha256.ts.html deleted file mode 100644 index 8d8df3b..0000000 --- a/coverage/lcov-report/utils/sha256.ts.html +++ /dev/null @@ -1,385 +0,0 @@ - - - - - - Code coverage report for utils/sha256.ts - - - - - - - - - -
-
-

All files / utils sha256.ts

-
- -
- 0% - Statements - 0/75 -
- - -
- 0% - Branches - 0/2 -
- - -
- 0% - Functions - 0/2 -
- - -
- 0% - Lines - 0/63 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
export function sha256(input: Uint8Array): Uint8Array {
-    const K = [
-        0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
-        0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
-        0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
-        0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
-        0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
-        0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
-        0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
-        0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
-    ];
- 
-    const H = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];
- 
-    const len = input.length * 8;
-    const lenByte = input.length;
- 
-    // Padding
-    const k = (len + 1 + 64) % 512 <= 448 ? 448 - (len + 1) % 512 : 960 - (len + 1) % 512;
-    const padding = new Uint8Array((k + 1 + 64) / 8);
-    padding[0] = 0x80;
- 
-    // Length in bits (Big Endian 64 bit)
-    // Javascript numbers are doubles limited to 53 bits integer precision.
-    // For small inputs it's fine.
-    const l = len;
-    const high = Math.floor(l / 4294967296);
-    const low = l % 4294967296;
- 
-    const pLen = padding.length;
-    padding[pLen - 4] = (low >>> 24) & 0xff;
-    padding[pLen - 3] = (low >>> 16) & 0xff;
-    padding[pLen - 2] = (low >>> 8) & 0xff;
-    padding[pLen - 1] = low & 0xff;
- 
-    padding[pLen - 8] = (high >>> 24) & 0xff;
-    padding[pLen - 7] = (high >>> 16) & 0xff;
-    padding[pLen - 6] = (high >>> 8) & 0xff;
-    padding[pLen - 5] = high & 0xff;
- 
-    const msg = new Uint8Array(lenByte + padding.length);
-    msg.set(input);
-    msg.set(padding, lenByte);
- 
-    const W = new Uint32Array(64);
- 
-    for (let i = 0; i < msg.length; i += 64) {
-        // Prepare message schedule
-        for (let t = 0; t < 16; t++) {
-            W[t] = (msg[i + t * 4] << 24) | (msg[i + t * 4 + 1] << 16) | (msg[i + t * 4 + 2] << 8) | (msg[i + t * 4 + 3]);
-        }
-        for (let t = 16; t < 64; t++) {
-            const s1 = rro(W[t - 2], 17) ^ rro(W[t - 2], 19) ^ (W[t - 2] >>> 10);
-            const s0 = rro(W[t - 15], 7) ^ rro(W[t - 15], 18) ^ (W[t - 15] >>> 3);
-            W[t] = (s1 + W[t - 7] + s0 + W[t - 16]) | 0;
-        }
- 
-        let a = H[0], b = H[1], c = H[2], d = H[3], e = H[4], f = H[5], g = H[6], h = H[7];
- 
-        for (let t = 0; t < 64; t++) {
-            const S1 = rro(e, 6) ^ rro(e, 11) ^ rro(e, 25);
-            const ch = (e & f) ^ ((~e) & g);
-            const temp1 = (h + S1 + ch + K[t] + W[t]) | 0;
-            const S0 = rro(a, 2) ^ rro(a, 13) ^ rro(a, 22);
-            const maj = (a & b) ^ (a & c) ^ (b & c);
-            const temp2 = (S0 + maj) | 0;
- 
-            h = g;
-            g = f;
-            f = e;
-            e = (d + temp1) | 0;
-            d = c;
-            c = b;
-            b = a;
-            a = (temp1 + temp2) | 0;
-        }
- 
-        H[0] = (H[0] + a) | 0;
-        H[1] = (H[1] + b) | 0;
-        H[2] = (H[2] + c) | 0;
-        H[3] = (H[3] + d) | 0;
-        H[4] = (H[4] + e) | 0;
-        H[5] = (H[5] + f) | 0;
-        H[6] = (H[6] + g) | 0;
-        H[7] = (H[7] + h) | 0;
-    }
- 
-    const res = new Uint8Array(32);
-    for (let i = 0; i < 8; i++) {
-        res[i * 4] = (H[i] >>> 24) & 0xff;
-        res[i * 4 + 1] = (H[i] >>> 16) & 0xff;
-        res[i * 4 + 2] = (H[i] >>> 8) & 0xff;
-        res[i * 4 + 3] = H[i] & 0xff;
-    }
-    return res;
-}
- 
-function rro(val: number, bits: number) {
-    return (val >>> bits) | (val << (32 - bits));
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/validators/base.ts.html b/coverage/lcov-report/validators/base.ts.html deleted file mode 100644 index 99b840e..0000000 --- a/coverage/lcov-report/validators/base.ts.html +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - Code coverage report for validators/base.ts - - - - - - - - - -
-
-

All files / validators base.ts

-
- -
- 90.9% - Statements - 10/11 -
- - -
- 66.66% - Branches - 2/3 -
- - -
- 100% - Functions - 1/1 -
- - -
- 90.9% - Lines - 10/11 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -3013x -13x -  -13x -  -  -  -  -  -  -79x -79x -  -79x -  -  -77x -  -2x -2x -2x -  -  -  -  -  -  -  -  - 
import { ValidationResult, ValidationOptions, FormatOptions, ValidationError } from '../types';
-import { InputSanitizer } from '../security/sanitizer';
- 
-export abstract class AddressValidator {
-    /**
-     * Validates an address.
-     * @param address - The address string to validate
-     * @param options - Validation options
-     */
-    public validate(address: string, _options?: ValidationOptions): ValidationResult {
-        try {
-            void _options;
-            // Security: Sanitize input first
-            const safeAddress = InputSanitizer.sanitize(address);
- 
-            // Perform validation on sanitized input
-            return this.validateImplementation(safeAddress);
-        } catch (error: unknown) {
-            const message = error instanceof Error ? error.message : String(error);
-            if (message === ValidationError.UNSAFE_INPUT) {
-                return { valid: false, error: 'Unsafe input detected', details: { errorCode: ValidationError.UNSAFE_INPUT } };
-            }
-            return { valid: false, error: message };
-        }
-    }
- 
-    protected abstract validateImplementation(address: string): ValidationResult;
-    public abstract format(address: string, options?: FormatOptions): string;
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/validators/bitcoin.ts.html b/coverage/lcov-report/validators/bitcoin.ts.html deleted file mode 100644 index 797b33c..0000000 --- a/coverage/lcov-report/validators/bitcoin.ts.html +++ /dev/null @@ -1,385 +0,0 @@ - - - - - - Code coverage report for validators/bitcoin.ts - - - - - - - - - -
-
-

All files / validators bitcoin.ts

-
- -
- 76.92% - Statements - 40/52 -
- - -
- 63.33% - Branches - 19/30 -
- - -
- 100% - Functions - 4/4 -
- - -
- 76.92% - Lines - 40/52 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -10113x -13x -13x -13x -13x -  -13x -  -  -11x -4x -  -  -  -7x -6x -  -  -1x -  -  -  -4x -1x -  -3x -3x -3x -1x -  -  -  -2x -2x -2x -2x -  -2x -  -  -  -2x -  -  -  -  -  -  -6x -6x -3x -  -  -3x -  -  -  -3x -  -  -3x -2x -  -  -2x -  -  -2x -  -  -  -1x -1x -  -  -1x -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -2x -1x -1x -  -1x -  -  - 
import { AddressValidator } from './base';
-import { ValidationResult, FormatOptions, ValidationError } from '../types';
-import { decodeBase58 } from '../utils/base58';
-import { decodeBech32, Bech32Encoding } from '../utils/bech32';
-import { sha256 } from '../utils/sha256';
- 
-export class BitcoinValidator extends AddressValidator {
-    protected validateImplementation(address: string): ValidationResult {
-        // 1. Check Legacy (Starts with 1 or 3, Base58)
-        if (address.startsWith('1') || address.startsWith('3')) {
-            return this.validateLegacy(address);
-        }
- 
-        // 2. Check SegWit/Taproot (Starts with bc1)
-        if (address.toLowerCase().startsWith('bc1')) {
-            return this.validateBech32(address);
-        }
- 
-        return { valid: false, error: 'Unknown format', details: { errorCode: ValidationError.INVALID_FORMAT } };
-    }
- 
-    private validateLegacy(address: string): ValidationResult {
-        if (address.length < 26 || address.length > 35) {
-            return { valid: false, error: 'Invalid length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-        }
-        try {
-            const decoded = decodeBase58(address);
-            if (decoded.length !== 25) { // 1 byte version + 20 bytes hash + 4 bytes checksum
-                return { valid: false, error: 'Invalid decoded length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-            }
- 
-            // Checksum Validation
-            const payload = decoded.slice(0, 21);
-            const checksum = decoded.slice(21);
-            const hash1 = sha256(payload);
-            const hash2 = sha256(hash1);
- 
-            Iif (hash2[0] !== checksum[0] || hash2[1] !== checksum[1] || hash2[2] !== checksum[2] || hash2[3] !== checksum[3]) {
-                return { valid: false, error: 'Invalid checksum', details: { errorCode: ValidationError.INVALID_CHECKSUM } };
-            }
- 
-            return { valid: true, blockchain: 'bitcoin', details: { format: 'legacy' } };
-        } catch {
-            return { valid: false, error: 'Invalid Base58', details: { errorCode: ValidationError.INVALID_CHARACTERS } };
-        }
-    }
- 
-    private validateBech32(address: string): ValidationResult {
-        const decoded = decodeBech32(address);
-        if (!decoded) {
-            return { valid: false, error: 'Invalid Bech32 encoding', details: { errorCode: ValidationError.INVALID_FORMAT } };
-        }
- 
-        Iif (decoded.hrp !== 'bc') {
-            return { valid: false, error: 'Invalid HRP', details: { errorCode: ValidationError.UNSUPPORTED_CHAIN } };
-        }
- 
-        const version = decoded.data[0];
- 
-        // SegWit V0 (P2WPKH / P2WSH)
-        if (version === 0) {
-            Iif (decoded.data.length !== 21 && decoded.data.length !== 33) {
-                return { valid: false, error: 'Invalid SegWit program length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-            }
-            Iif (decoded.encoding !== Bech32Encoding.BECH32) {
-                return { valid: false, error: 'V0 uses Bech32', details: { errorCode: ValidationError.INVALID_FORMAT } };
-            }
-            return { valid: true, blockchain: 'bitcoin', details: { format: 'segwit', network: 'mainnet' } };
-        }
- 
-        // Taproot V1 (P2TR)
-        if (version === 1) {
-            Iif (decoded.data.length !== 53) { // 1 char version + 32 bytes program (52 chars) = 53
-                return { valid: false, error: 'Invalid Taproot program length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-            }
-            Iif (decoded.encoding !== Bech32Encoding.BECH32M) {
-                return { valid: false, error: 'V1 uses Bech32m', details: { errorCode: ValidationError.INVALID_FORMAT } };
-            }
-            return { valid: true, blockchain: 'bitcoin', details: { format: 'taproot', network: 'mainnet' } };
-        }
- 
-        // Future versions (2-16) allowed by BIP-173/350 but require Bech32m
-        Iif (version >= 2 && version <= 16) {
-            Iif (decoded.encoding !== Bech32Encoding.BECH32M) {
-                return { valid: false, error: 'Version 2+ uses Bech32m', details: { errorCode: ValidationError.INVALID_FORMAT } };
-            }
-            return { valid: true, blockchain: 'bitcoin', details: { format: 'future', network: 'mainnet' } };
-        }
- 
-        return { valid: false, error: 'Invalid witness version' };
-    }
- 
-    format(address: string, options?: FormatOptions): string {
-        if (options?.shorten) {
-            const len = options.shortenLength || 4;
-            return `${address.slice(0, len)}...${address.slice(-len)}`;
-        }
-        return address;
-    }
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/validators/cardano.ts.html b/coverage/lcov-report/validators/cardano.ts.html deleted file mode 100644 index f1c05df..0000000 --- a/coverage/lcov-report/validators/cardano.ts.html +++ /dev/null @@ -1,265 +0,0 @@ - - - - - - Code coverage report for validators/cardano.ts - - - - - - - - - -
-
-

All files / validators cardano.ts

-
- -
- 75% - Statements - 21/28 -
- - -
- 73.68% - Branches - 14/19 -
- - -
- 75% - Functions - 3/4 -
- - -
- 75% - Lines - 21/28 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -6113x -13x -13x -13x -  -13x -  -  -8x -3x -  -  -  -5x -5x -  -  -  -  -  -  -3x -3x -1x -  -  -2x -2x -  -  -  -2x -  -2x -  -  -  -5x -  -  -  -5x -5x -2x -  -  -3x -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import { AddressValidator } from './base';
-import { ValidationResult, FormatOptions, ValidationError } from '../types';
-import { decodeBase58 } from '../utils/base58';
-import { decodeBech32 } from '../utils/bech32';
- 
-export class CardanoValidator extends AddressValidator {
-    protected validateImplementation(address: string): ValidationResult {
-        // 1. Check Shelley Era (Bech32 started with addr1 or addr_test1)
-        if (address.startsWith('addr1') || address.startsWith('addr_test1') || address.startsWith('stake1') || address.startsWith('stake_test1')) {
-            return this.validateShelley(address);
-        }
- 
-        // 2. Check Byron Era (Base58, usually starts with A, D, or Ae2)
-        if (address.startsWith('A') || address.startsWith('D') || address.startsWith('Ae2')) {
-            return this.validateByron(address);
-        }
- 
-        return { valid: false, error: 'Unknown Cardano format', details: { errorCode: ValidationError.INVALID_FORMAT } };
-    }
- 
-    private validateShelley(address: string): ValidationResult {
-        const decoded = decodeBech32(address);
-        if (!decoded) {
-            return { valid: false, error: 'Invalid Bech32 encoding', details: { errorCode: ValidationError.INVALID_FORMAT } };
-        }
- 
-        const validHrps = ['addr', 'addr_test', 'stake', 'stake_test'];
-        Iif (!validHrps.includes(decoded.hrp)) {
-            return { valid: false, error: 'Invalid HRP for Cardano', details: { errorCode: ValidationError.UNSUPPORTED_CHAIN } };
-        }
- 
-        const network = decoded.hrp.includes('test') ? 'testnet' : 'mainnet';
- 
-        return { valid: true, blockchain: 'cardano', details: { format: 'shelley', network } };
-    }
- 
-    private validateByron(address: string): ValidationResult {
-        try {
-            // Byron addresses use standard Base58 but have a complex CBOR structure.
-            // A comprehensive check requires a CBOR parser. 
-            // For a lightweight zero-dependency lib, we do a basic Base58 decode + length check.
-            const decoded = decodeBase58(address);
-            if (decoded.length < 32 || decoded.length > 128) {
-                return { valid: false, error: 'Invalid Byron address length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-            }
- 
-            return { valid: true, blockchain: 'cardano', details: { format: 'byron' } };
-        } catch {
-            return { valid: false, error: 'Invalid Base58', details: { errorCode: ValidationError.INVALID_CHARACTERS } };
-        }
-    }
- 
-    format(address: string, options?: FormatOptions): string {
-        Iif (options?.shorten) {
-            const len = options.shortenLength || 8; // Cardano addresses are long, show 8 chars
-            return `${address.slice(0, len)}...${address.slice(-len)}`;
-        }
-        return address;
-    }
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/validators/dogecoin.ts.html b/coverage/lcov-report/validators/dogecoin.ts.html deleted file mode 100644 index 44c3b56..0000000 --- a/coverage/lcov-report/validators/dogecoin.ts.html +++ /dev/null @@ -1,223 +0,0 @@ - - - - - - Code coverage report for validators/dogecoin.ts - - - - - - - - - -
-
-

All files / validators dogecoin.ts

-
- -
- 96% - Statements - 24/25 -
- - -
- 100% - Branches - 16/16 -
- - -
- 100% - Functions - 2/2 -
- - -
- 96% - Lines - 24/25 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -4713x -13x -13x -13x -  -13x -  -  -7x -1x -  -  -6x -1x -  -  -5x -5x -5x -1x -  -  -  -4x -4x -4x -4x -  -4x -1x -  -  -3x -  -  -  -  -  -  -2x -1x -1x -  -1x -  -  - 
import { AddressValidator } from './base';
-import { ValidationResult, FormatOptions, ValidationError } from '../types';
-import { decodeBase58 } from '../utils/base58';
-import { sha256 } from '../utils/sha256';
- 
-export class DogecoinValidator extends AddressValidator {
-    protected validateImplementation(address: string): ValidationResult {
-        // Dogecoin P2PKH starts with D, P2SH starts with 9 or A
-        if (!address.startsWith('D') && !address.startsWith('9') && !address.startsWith('A')) {
-            return { valid: false, error: 'Unknown format', details: { errorCode: ValidationError.INVALID_FORMAT } };
-        }
- 
-        if (address.length < 26 || address.length > 35) {
-            return { valid: false, error: 'Invalid length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-        }
- 
-        try {
-            const decoded = decodeBase58(address);
-            if (decoded.length !== 25) {
-                return { valid: false, error: 'Invalid decoded length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-            }
- 
-            // Checksum Validation
-            const payload = decoded.slice(0, 21);
-            const checksum = decoded.slice(21);
-            const hash1 = sha256(payload);
-            const hash2 = sha256(hash1);
- 
-            if (hash2[0] !== checksum[0] || hash2[1] !== checksum[1] || hash2[2] !== checksum[2] || hash2[3] !== checksum[3]) {
-                return { valid: false, error: 'Invalid checksum', details: { errorCode: ValidationError.INVALID_CHECKSUM } };
-            }
- 
-            return { valid: true, blockchain: 'dogecoin', details: { format: 'legacy' } };
-        } catch {
-            return { valid: false, error: 'Invalid Base58', details: { errorCode: ValidationError.INVALID_CHARACTERS } };
-        }
-    }
- 
-    format(address: string, options?: FormatOptions): string {
-        if (options?.shorten) {
-            const len = options.shortenLength || 4;
-            return `${address.slice(0, len)}...${address.slice(-len)}`;
-        }
-        return address;
-    }
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/validators/ethereum.ts.html b/coverage/lcov-report/validators/ethereum.ts.html deleted file mode 100644 index 515e8f5..0000000 --- a/coverage/lcov-report/validators/ethereum.ts.html +++ /dev/null @@ -1,385 +0,0 @@ - - - - - - Code coverage report for validators/ethereum.ts - - - - - - - - - -
-
-

All files / validators ethereum.ts

-
- -
- 90.9% - Statements - 40/44 -
- - -
- 85% - Branches - 17/20 -
- - -
- 100% - Functions - 5/5 -
- - -
- 92.85% - Lines - 39/42 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -10113x -13x -13x -13x -  -13x -  -27x -  -  -  -27x -  -2x -  -  -  -25x -  -2x -  -  -  -23x -  -1x -  -  -  -22x -8x -  -2x -  -  -  -20x -  -  -  -  -  -  -  -  -  -  -5x -  -5x -3x -  -  -5x -2x -2x -  -  -3x -  -  -  -20x -20x -  -  -  -8x -  -  -8x -  -  -  -  -8x -8x -  -  -  -31x -31x -31x -31x -31x -  -31x -1240x -597x -  -643x -  -  -31x -  -  -  -  -  -  - 
import { AddressValidator } from './base';
-import { ValidationResult, ValidationOptions, FormatOptions, ValidationError } from '../types';
-import { isHex, stripHexPrefix, addHexPrefix } from '../utils/hex';
-import { keccak256 } from '../utils/keccak256';
- 
-export class EthereumValidator extends AddressValidator {
-    protected validateImplementation(address: string, options?: ValidationOptions): ValidationResult {
-        const cleanAddress = stripHexPrefix(address);
-        // console.error(`DEBUG: Validating ${address} (clean: ${cleanAddress})`);
- 
-        // Check length
-        if (cleanAddress.length !== 40) {
-            // console.error(`DEBUG: Failed Length ${cleanAddress.length}`);
-            return { valid: false, error: 'Invalid length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-        }
- 
-        // Check hex
-        if (!isHex(cleanAddress)) {
-            // console.error(`DEBUG: Failed Hex`);
-            return { valid: false, error: 'Invalid hex characters', details: { errorCode: ValidationError.INVALID_CHARACTERS } };
-        }
- 
-        // Burn Address Check
-        if (/^0+$/.test(cleanAddress)) {
-            // console.error(`DEBUG: Failed Burn`);
-            return { valid: false, error: 'Burn address detected', details: { errorCode: ValidationError.BURN_ADDRESS } };
-        }
- 
-        // Checksum Validation
-        if (options?.strict || (cleanAddress !== cleanAddress.toLowerCase() && cleanAddress !== cleanAddress.toUpperCase())) {
-            if (!this.checkChecksum(cleanAddress)) {
-                // console.error(`DEBUG: Failed Checksum: clean=${cleanAddress}`);
-                return { valid: false, error: 'Invalid checksum', details: { errorCode: ValidationError.INVALID_CHECKSUM } };
-            }
-        }
- 
-        return {
-            valid: true,
-            blockchain: 'ethereum',
-            details: {
-                checksum: this.isChecksummed(address),
-                network: 'mainnet' // Ethereum doesn't distinguish mainnet/testnet by address
-            }
-        };
-    }
- 
-    format(address: string, options?: FormatOptions): string {
-        let formatted = address.startsWith('0x') ? address : addHexPrefix(address);
- 
-        if (options?.checksum) {
-            formatted = this.toChecksumAddress(formatted);
-        }
- 
-        if (options?.shorten) {
-            const len = options.shortenLength || 4;
-            return `${formatted.slice(0, 2 + len)}...${formatted.slice(-len)}`;
-        }
- 
-        return formatted;
-    }
- 
-    private isChecksummed(address: string): boolean {
-        const clean = stripHexPrefix(address);
-        return addHexPrefix(clean) === this.toChecksumAddress(clean);
-    }
- 
-    private checkChecksum(address: string): boolean {
-        const clean = stripHexPrefix(address);
- 
-        // all lower or all upper → valid, no checksum claimed
-        Iif (clean === clean.toLowerCase() || clean === clean.toUpperCase()) {
-            return true;
-        }
- 
-        // mixed case → must match EIP-55 checksum
-        const checksummed = stripHexPrefix(this.toChecksumAddress(clean));
-        return clean === checksummed;
-    }
- 
-    private toChecksumAddress(address: string): string {
-        try {
-            Iif (!address) return '';
-            const strip = stripHexPrefix(address).toLowerCase();
-            const hash = keccak256(strip);
-            let ret = '0x';
- 
-            for (let i = 0; i < strip.length; i++) {
-                if (parseInt(hash[i], 16) >= 8) {
-                    ret += strip[i].toUpperCase();
-                } else {
-                    ret += strip[i];
-                }
-            }
-            return ret;
-        } catch (error) {
-            console.error('Checksum error:', error);
-            return address;
-        }
-    }
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/validators/evm.ts.html b/coverage/lcov-report/validators/evm.ts.html deleted file mode 100644 index f8db172..0000000 --- a/coverage/lcov-report/validators/evm.ts.html +++ /dev/null @@ -1,241 +0,0 @@ - - - - - - Code coverage report for validators/evm.ts - - - - - - - - - -
-
-

All files / validators evm.ts

-
- -
- 100% - Statements - 26/26 -
- - -
- 100% - Branches - 5/5 -
- - -
- 100% - Functions - 5/5 -
- - -
- 100% - Lines - 26/26 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -5313x -  -  -13x -  -2x -2x -2x -  -2x -  -  -  -13x -  -2x -2x -2x -  -2x -  -  -  -13x -  -2x -2x -2x -  -2x -  -  -  -13x -  -2x -2x -2x -  -2x -  -  -  -13x -  -2x -2x -2x -  -2x -  -  - 
import { EthereumValidator } from './ethereum';
-import { ValidationResult, ValidationOptions } from '../types';
- 
-export class BscValidator extends EthereumValidator {
-    protected validateImplementation(address: string, options?: ValidationOptions): ValidationResult {
-        const result = super.validateImplementation(address, options);
-        if (result.valid) {
-            result.blockchain = 'bsc';
-        }
-        return result;
-    }
-}
- 
-export class AvalancheValidator extends EthereumValidator {
-    protected validateImplementation(address: string, options?: ValidationOptions): ValidationResult {
-        const result = super.validateImplementation(address, options);
-        if (result.valid) {
-            result.blockchain = 'avalanche';
-        }
-        return result;
-    }
-}
- 
-export class ArbitrumValidator extends EthereumValidator {
-    protected validateImplementation(address: string, options?: ValidationOptions): ValidationResult {
-        const result = super.validateImplementation(address, options);
-        if (result.valid) {
-            result.blockchain = 'arbitrum';
-        }
-        return result;
-    }
-}
- 
-export class OptimismValidator extends EthereumValidator {
-    protected validateImplementation(address: string, options?: ValidationOptions): ValidationResult {
-        const result = super.validateImplementation(address, options);
-        if (result.valid) {
-            result.blockchain = 'optimism';
-        }
-        return result;
-    }
-}
- 
-export class BaseValidator extends EthereumValidator {
-    protected validateImplementation(address: string, options?: ValidationOptions): ValidationResult {
-        const result = super.validateImplementation(address, options);
-        if (result.valid) {
-            result.blockchain = 'base';
-        }
-        return result;
-    }
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/validators/index.html b/coverage/lcov-report/validators/index.html deleted file mode 100644 index dfd2c2b..0000000 --- a/coverage/lcov-report/validators/index.html +++ /dev/null @@ -1,251 +0,0 @@ - - - - - - Code coverage report for validators - - - - - - - - - -
-
-

All files validators

-
- -
- 88.75% - Statements - 284/320 -
- - -
- 79.72% - Branches - 118/148 -
- - -
- 96.77% - Functions - 30/31 -
- - -
- 89.13% - Lines - 279/313 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
base.ts -
-
90.9%10/1166.66%2/3100%1/190.9%10/11
bitcoin.ts -
-
76.92%40/5263.33%19/30100%4/476.92%40/52
cardano.ts -
-
75%21/2873.68%14/1975%3/475%21/28
dogecoin.ts -
-
96%24/25100%16/16100%2/296%24/25
ethereum.ts -
-
90.9%40/4485%17/20100%5/592.85%39/42
evm.ts -
-
100%26/26100%5/5100%5/5100%26/26
litecoin.ts -
-
78.26%36/4670.37%19/27100%4/478.26%36/46
polygon.ts -
-
100%6/6100%1/1100%1/1100%6/6
ripple.ts -
-
98.41%62/6394.44%17/18100%3/3100%58/58
solana.ts -
-
100%19/1988.88%8/9100%2/2100%19/19
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/validators/litecoin.ts.html b/coverage/lcov-report/validators/litecoin.ts.html deleted file mode 100644 index 264d9d9..0000000 --- a/coverage/lcov-report/validators/litecoin.ts.html +++ /dev/null @@ -1,352 +0,0 @@ - - - - - - Code coverage report for validators/litecoin.ts - - - - - - - - - -
-
-

All files / validators litecoin.ts

-
- -
- 78.26% - Statements - 36/46 -
- - -
- 70.37% - Branches - 19/27 -
- - -
- 100% - Functions - 4/4 -
- - -
- 78.26% - Lines - 36/46 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -9013x -13x -13x -13x -13x -  -13x -  -  -9x -6x -  -  -  -3x -3x -  -  -  -  -  -  -6x -1x -  -5x -5x -5x -1x -  -  -  -4x -4x -4x -4x -  -4x -1x -  -  -3x -  -  -  -  -  -  -3x -3x -2x -  -  -1x -  -  -  -1x -  -  -1x -1x -  -  -1x -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -2x -1x -1x -  -1x -  -  - 
import { AddressValidator } from './base';
-import { ValidationResult, FormatOptions, ValidationError } from '../types';
-import { decodeBase58 } from '../utils/base58';
-import { decodeBech32, Bech32Encoding } from '../utils/bech32';
-import { sha256 } from '../utils/sha256';
- 
-export class LitecoinValidator extends AddressValidator {
-    protected validateImplementation(address: string): ValidationResult {
-        // 1. Check Legacy or P2SH (Starts with L or M, Base58)
-        if (address.startsWith('L') || address.startsWith('M')) {
-            return this.validateLegacy(address);
-        }
- 
-        // 2. Check SegWit (Starts with ltc1)
-        if (address.toLowerCase().startsWith('ltc1')) {
-            return this.validateBech32(address);
-        }
- 
-        return { valid: false, error: 'Unknown format', details: { errorCode: ValidationError.INVALID_FORMAT } };
-    }
- 
-    private validateLegacy(address: string): ValidationResult {
-        if (address.length < 26 || address.length > 35) {
-            return { valid: false, error: 'Invalid length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-        }
-        try {
-            const decoded = decodeBase58(address);
-            if (decoded.length !== 25) {
-                return { valid: false, error: 'Invalid decoded length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-            }
- 
-            // Checksum Validation
-            const payload = decoded.slice(0, 21);
-            const checksum = decoded.slice(21);
-            const hash1 = sha256(payload);
-            const hash2 = sha256(hash1);
- 
-            if (hash2[0] !== checksum[0] || hash2[1] !== checksum[1] || hash2[2] !== checksum[2] || hash2[3] !== checksum[3]) {
-                return { valid: false, error: 'Invalid checksum', details: { errorCode: ValidationError.INVALID_CHECKSUM } };
-            }
- 
-            return { valid: true, blockchain: 'litecoin', details: { format: 'legacy' } };
-        } catch {
-            return { valid: false, error: 'Invalid Base58', details: { errorCode: ValidationError.INVALID_CHARACTERS } };
-        }
-    }
- 
-    private validateBech32(address: string): ValidationResult {
-        const decoded = decodeBech32(address);
-        if (!decoded) {
-            return { valid: false, error: 'Invalid Bech32 encoding', details: { errorCode: ValidationError.INVALID_FORMAT } };
-        }
- 
-        Iif (decoded.hrp !== 'ltc') {
-            return { valid: false, error: 'Invalid HRP', details: { errorCode: ValidationError.UNSUPPORTED_CHAIN } };
-        }
- 
-        const version = decoded.data[0];
- 
-        // MWEB starts with ltc1m (but let's just stick to standard segwit/taproot versions)
-        if (version === 0) {
-            Iif (decoded.data.length !== 21 && decoded.data.length !== 33) {
-                return { valid: false, error: 'Invalid SegWit program length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-            }
-            Iif (decoded.encoding !== Bech32Encoding.BECH32) {
-                return { valid: false, error: 'V0 uses Bech32', details: { errorCode: ValidationError.INVALID_FORMAT } };
-            }
-            return { valid: true, blockchain: 'litecoin', details: { format: 'segwit', network: 'mainnet' } };
-        }
- 
-        // Taproot equivalent (MWEB/Future)
-        Iif (version >= 1 && version <= 16) {
-            Iif (decoded.encoding !== Bech32Encoding.BECH32M) {
-                return { valid: false, error: 'Version 1+ uses Bech32m', details: { errorCode: ValidationError.INVALID_FORMAT } };
-            }
-            return { valid: true, blockchain: 'litecoin', details: { format: 'future', network: 'mainnet' } };
-        }
- 
-        return { valid: false, error: 'Invalid witness version' };
-    }
- 
-    format(address: string, options?: FormatOptions): string {
-        if (options?.shorten) {
-            const len = options.shortenLength || 4;
-            return `${address.slice(0, len)}...${address.slice(-len)}`;
-        }
-        return address;
-    }
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/validators/polygon.ts.html b/coverage/lcov-report/validators/polygon.ts.html deleted file mode 100644 index 0374ea8..0000000 --- a/coverage/lcov-report/validators/polygon.ts.html +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - Code coverage report for validators/polygon.ts - - - - - - - - - -
-
-

All files / validators polygon.ts

-
- -
- 100% - Statements - 6/6 -
- - -
- 100% - Branches - 1/1 -
- - -
- 100% - Functions - 1/1 -
- - -
- 100% - Lines - 6/6 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -1313x -  -  -13x -  -5x -5x -3x -  -5x -  -  - 
import { EthereumValidator } from './ethereum';
-import { ValidationResult, ValidationOptions } from '../types';
- 
-export class PolygonValidator extends EthereumValidator {
-    protected validateImplementation(address: string, options?: ValidationOptions): ValidationResult {
-        const result = super.validateImplementation(address, options);
-        if (result.valid) {
-            result.blockchain = 'polygon';
-        }
-        return result;
-    }
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/validators/ripple.ts.html b/coverage/lcov-report/validators/ripple.ts.html deleted file mode 100644 index 32d0755..0000000 --- a/coverage/lcov-report/validators/ripple.ts.html +++ /dev/null @@ -1,391 +0,0 @@ - - - - - - Code coverage report for validators/ripple.ts - - - - - - - - - -
-
-

All files / validators ripple.ts

-
- -
- 98.41% - Statements - 62/63 -
- - -
- 94.44% - Branches - 17/18 -
- - -
- 100% - Functions - 3/3 -
- - -
- 100% - Lines - 58/58 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -10313x -13x -13x -  -  -13x -13x -13x -  -13x -13x -754x -  -  -  -6x -  -6x -6x -39x -  -6x -  -6x -  -6x -165x -165x -165x -1x -  -  -164x -1967x -  -164x -  -164x -164x -1967x -1967x -1967x -  -164x -115x -115x -  -  -  -5x -5x -4x -  -  -5x -38x -  -  -5x -  -  -13x -  -  -8x -1x -  -  -7x -1x -  -  -6x -6x -5x -1x -  -  -  -4x -4x -4x -4x -  -4x -1x -  -  -3x -  -1x -  -  -  -  -2x -1x -1x -  -1x -  -  - 
import { AddressValidator } from './base';
-import { ValidationResult, FormatOptions, ValidationError } from '../types';
-import { sha256 } from '../utils/sha256';
- 
-// Ripple uses a custom Base58 dictionary
-const RIPPLE_ALPHABET = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz';
-const BASE = 58;
-const LEADER = RIPPLE_ALPHABET.charAt(0);
- 
-const ALPHABET_MAP: { [key: string]: number } = {};
-for (let i = 0; i < RIPPLE_ALPHABET.length; i++) {
-    ALPHABET_MAP[RIPPLE_ALPHABET.charAt(i)] = i;
-}
- 
-function decodeRippleBase58(string: string): Uint8Array {
-    Iif (string.length === 0) return new Uint8Array(0);
- 
-    let i = 0;
-    while (i < string.length && string[i] === LEADER) {
-        i++;
-    }
-    const leaders = i;
- 
-    const bytes = [0];
- 
-    for (; i < string.length; i++) {
-        const char = string[i];
-        const value = ALPHABET_MAP[char];
-        if (value === undefined) {
-            throw new Error(`Invalid Ripple Base58 character: ${char}`);
-        }
- 
-        for (let j = 0; j < bytes.length; j++) {
-            bytes[j] *= BASE;
-        }
-        bytes[0] += value;
- 
-        let carry = 0;
-        for (let j = 0; j < bytes.length; ++j) {
-            bytes[j] += carry;
-            carry = bytes[j] >> 8;
-            bytes[j] &= 0xff;
-        }
-        while (carry) {
-            bytes.push(carry & 0xff);
-            carry >>= 8;
-        }
-    }
- 
-    let resultBytes: number[] = [];
-    if (string.length !== leaders) {
-        resultBytes = bytes.reverse();
-    }
- 
-    for (let k = 0; k < leaders; k++) {
-        resultBytes.unshift(0);
-    }
- 
-    return new Uint8Array(resultBytes);
-}
- 
-export class RippleValidator extends AddressValidator {
-    protected validateImplementation(address: string): ValidationResult {
-        // Ripple addresses always start with 'r'
-        if (!address.startsWith('r')) {
-            return { valid: false, error: 'Must start with r', details: { errorCode: ValidationError.INVALID_FORMAT } };
-        }
- 
-        if (address.length < 25 || address.length > 35) {
-            return { valid: false, error: 'Invalid length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-        }
- 
-        try {
-            const decoded = decodeRippleBase58(address);
-            if (decoded.length !== 25) {
-                return { valid: false, error: 'Invalid decoded length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-            }
- 
-            // Checksum Validation
-            const payload = decoded.slice(0, 21);
-            const checksum = decoded.slice(21);
-            const hash1 = sha256(payload);
-            const hash2 = sha256(hash1);
- 
-            if (hash2[0] !== checksum[0] || hash2[1] !== checksum[1] || hash2[2] !== checksum[2] || hash2[3] !== checksum[3]) {
-                return { valid: false, error: 'Invalid checksum', details: { errorCode: ValidationError.INVALID_CHECKSUM } };
-            }
- 
-            return { valid: true, blockchain: 'ripple' };
-        } catch {
-            return { valid: false, error: 'Invalid characters', details: { errorCode: ValidationError.INVALID_CHARACTERS } };
-        }
-    }
- 
-    format(address: string, options?: FormatOptions): string {
-        if (options?.shorten) {
-            const len = options.shortenLength || 4;
-            return `${address.slice(0, len)}...${address.slice(-len)}`;
-        }
-        return address;
-    }
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/validators/solana.ts.html b/coverage/lcov-report/validators/solana.ts.html deleted file mode 100644 index 7b922a6..0000000 --- a/coverage/lcov-report/validators/solana.ts.html +++ /dev/null @@ -1,220 +0,0 @@ - - - - - - Code coverage report for validators/solana.ts - - - - - - - - - -
-
-

All files / validators solana.ts

-
- -
- 100% - Statements - 19/19 -
- - -
- 88.88% - Branches - 8/9 -
- - -
- 100% - Functions - 2/2 -
- - -
- 100% - Lines - 19/19 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -4613x -13x -13x -  -13x -  -7x -2x -  -  -5x -5x -4x -1x -  -  -1x -  -  -  -  -3x -  -  -  -  -1x -1x -  -  -  -2x -  -  -  -  -  -  -3x -2x -2x -  -1x -  -  - 
import { AddressValidator } from './base';
-import { ValidationResult, FormatOptions, ValidationError } from '../types';
-import { decodeBase58 } from '../utils/base58';
- 
-export class SolanaValidator extends AddressValidator {
-    protected validateImplementation(address: string): ValidationResult {
-        if (address.length < 32 || address.length > 44) {
-            return { valid: false, error: 'Invalid length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-        }
- 
-        try {
-            const decoded = decodeBase58(address);
-            if (decoded.length !== 32) {
-                return { valid: false, error: 'Invalid public key length', details: { errorCode: ValidationError.INVALID_LENGTH } };
-            }
-        } catch {
-            return { valid: false, error: 'Invalid Base58 characters', details: { errorCode: ValidationError.INVALID_FORMAT } };
-        }
- 
-        // Burn check? Solana burn addresses aren't as standard '0x00', but 1111111... is system program
-        // System Program: 11111111111111111111111111111111
-        if (/^1+$/.test(address)) {
-            // Technically valid system account, but maybe warn if it's strictly user wallets?
-            // For now, let's treat it as valid but maybe note it? 
-            // User asked for "burn address detection". System program is effectively special.
-            // Let's flag "11111111111111111111111111111111" specifically if needed.
-            if (address === '11111111111111111111111111111111') {
-                return { valid: true, blockchain: 'solana', details: { format: 'System Program' } };
-            }
-        }
- 
-        return {
-            valid: true,
-            blockchain: 'solana'
-        };
-    }
- 
-    format(address: string, options?: FormatOptions): string {
-        if (options?.shorten) {
-            const len = options.shortenLength || 4;
-            return `${address.slice(0, len)}...${address.slice(-len)}`;
-        }
-        return address;
-    }
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov.info b/coverage/lcov.info deleted file mode 100644 index bfad097..0000000 --- a/coverage/lcov.info +++ /dev/null @@ -1,938 +0,0 @@ -TN: -SF:src\detectors\chain-detector.ts -FN:25,detectBlockchain -FNF:1 -FNH:1 -FNDA:9,detectBlockchain -DA:2,13 -DA:3,13 -DA:4,13 -DA:5,13 -DA:6,13 -DA:7,13 -DA:8,13 -DA:10,13 -DA:25,13 -DA:27,9 -DA:28,1 -DA:30,1 -DA:35,8 -DA:36,1 -DA:37,1 -DA:42,7 -DA:43,2 -DA:44,1 -DA:49,6 -DA:50,2 -DA:51,2 -DA:56,4 -DA:57,1 -DA:58,1 -DA:64,3 -DA:66,1 -DA:67,1 -DA:72,2 -DA:73,1 -DA:76,1 -LF:30 -LH:30 -BRDA:27,0,0,1 -BRDA:27,1,0,9 -BRDA:27,1,1,1 -BRDA:28,2,0,1 -BRDA:35,3,0,1 -BRDA:35,4,0,8 -BRDA:35,4,1,1 -BRDA:36,5,0,1 -BRDA:42,6,0,2 -BRDA:42,7,0,7 -BRDA:42,7,1,7 -BRDA:42,7,2,7 -BRDA:42,7,3,6 -BRDA:43,8,0,1 -BRDA:49,9,0,2 -BRDA:49,10,0,6 -BRDA:49,10,1,5 -BRDA:49,10,2,5 -BRDA:50,11,0,2 -BRDA:56,12,0,1 -BRDA:56,13,0,4 -BRDA:56,13,1,3 -BRDA:56,13,2,3 -BRDA:57,14,0,1 -BRDA:64,15,0,1 -BRDA:64,16,0,3 -BRDA:64,16,1,2 -BRDA:64,16,2,2 -BRDA:66,17,0,1 -BRDA:72,18,0,1 -BRF:30 -BRH:30 -end_of_record -TN: -SF:src\formatters\index.ts -FN:4,shortenAddress -FN:9,normalizeAddress -FN:17,addChecksum -FNF:3 -FNH:3 -FNDA:2,shortenAddress -FNDA:3,normalizeAddress -FNDA:2,addChecksum -DA:2,13 -DA:4,13 -DA:5,2 -DA:6,1 -DA:9,13 -DA:10,3 -DA:11,2 -DA:14,1 -DA:17,13 -DA:18,2 -DA:22,1 -DA:23,1 -DA:25,1 -LF:13 -LH:13 -BRDA:4,0,0,2 -BRDA:5,1,0,1 -BRDA:5,2,0,2 -BRDA:5,2,1,2 -BRDA:10,3,0,2 -BRDA:10,4,0,3 -BRDA:10,4,1,2 -BRDA:18,5,0,1 -BRDA:18,6,0,2 -BRDA:18,6,1,1 -BRF:10 -BRH:10 -end_of_record -TN: -SF:src\security\sanitizer.ts -FN:4,(anonymous_0) -FNF:1 -FNH:1 -FNDA:87,(anonymous_0) -DA:1,13 -DA:3,13 -DA:5,87 -DA:6,2 -DA:9,85 -DA:10,2 -DA:14,83 -DA:17,83 -DA:18,1 -DA:23,82 -DA:24,3 -DA:27,79 -LF:12 -LH:12 -BRDA:5,0,0,2 -BRDA:5,1,0,87 -BRDA:5,1,1,86 -BRDA:9,2,0,2 -BRDA:17,3,0,1 -BRDA:23,4,0,3 -BRF:6 -BRH:6 -end_of_record -TN: -SF:src\utils\base58.ts -FN:10,encodeBase58 -FN:37,(anonymous_1) -FN:40,decodeBase58 -FNF:3 -FNH:3 -FNDA:1,encodeBase58 -FNDA:15,(anonymous_1) -FNDA:24,decodeBase58 -DA:1,14 -DA:2,14 -DA:3,14 -DA:5,14 -DA:6,14 -DA:7,812 -DA:10,14 -DA:11,1 -DA:13,1 -DA:15,1 -DA:16,11 -DA:17,79 -DA:19,11 -DA:21,11 -DA:22,11 -DA:23,79 -DA:24,79 -DA:25,79 -DA:27,11 -DA:28,14 -DA:29,14 -DA:33,1 -DA:34,0 -DA:37,15 -DA:40,14 -DA:41,24 -DA:43,24 -DA:44,24 -DA:45,101 -DA:47,24 -DA:49,24 -DA:51,24 -DA:52,810 -DA:53,810 -DA:54,810 -DA:55,1 -DA:58,809 -DA:59,13008 -DA:61,809 -DA:63,809 -DA:64,809 -DA:65,13008 -DA:66,13008 -DA:67,13008 -DA:69,809 -DA:70,572 -DA:71,572 -DA:97,23 -DA:98,3 -DA:100,20 -DA:139,23 -DA:140,101 -DA:143,23 -LF:53 -LH:52 -BRDA:11,0,0,0 -BRDA:33,1,0,1 -BRDA:33,1,1,1 -BRDA:41,2,0,0 -BRDA:44,3,0,125 -BRDA:44,3,1,122 -BRDA:54,4,0,1 -BRDA:97,5,0,3 -BRDA:97,5,1,20 -BRF:9 -BRH:7 -end_of_record -TN: -SF:src\utils\bech32.ts -FN:3,(anonymous_0) -FN:10,polymod -FN:24,hrpExpand -FN:36,verifyChecksum -FN:47,decodeBech32 -FNF:5 -FNH:5 -FNDA:15,(anonymous_0) -FNDA:18,polymod -FNDA:18,hrpExpand -FNDA:18,verifyChecksum -FNDA:15,decodeBech32 -DA:1,15 -DA:3,15 -DA:4,15 -DA:5,15 -DA:8,15 -DA:11,18 -DA:12,18 -DA:13,1104 -DA:14,1104 -DA:15,1104 -DA:16,5520 -DA:17,2522 -DA:21,18 -DA:25,18 -DA:26,18 -DA:27,56 -DA:29,18 -DA:30,18 -DA:31,56 -DA:33,18 -DA:37,18 -DA:38,18 -DA:47,15 -DA:48,15 -DA:49,14 -DA:52,14 -DA:54,13 -DA:55,13 -DA:57,12 -DA:59,12 -DA:60,12 -DA:61,651 -DA:62,651 -DA:63,651 -DA:67,12 -DA:68,6 -DA:72,6 -DA:73,1 -DA:76,5 -LF:39 -LH:39 -BRDA:3,0,0,15 -BRDA:3,0,1,15 -BRDA:16,1,0,2522 -BRDA:37,2,0,6 -BRDA:37,2,1,12 -BRDA:48,3,0,1 -BRDA:48,4,0,15 -BRDA:48,4,1,14 -BRDA:52,5,0,1 -BRDA:52,6,0,14 -BRDA:52,6,1,1 -BRDA:55,7,0,1 -BRDA:55,8,0,13 -BRDA:55,8,1,13 -BRDA:62,9,0,0 -BRDA:67,10,0,6 -BRDA:72,11,0,1 -BRF:17 -BRH:16 -end_of_record -TN: -SF:src\utils\hex.ts -FN:1,isHex -FN:16,stripHexPrefix -FN:20,addHexPrefix -FNF:3 -FNH:3 -FNDA:28,isHex -FNDA:96,stripHexPrefix -FNDA:22,addHexPrefix -DA:1,14 -DA:2,28 -DA:5,28 -DA:8,28 -DA:9,0 -DA:13,28 -DA:16,14 -DA:17,96 -DA:20,14 -DA:21,22 -LF:10 -LH:9 -BRDA:2,0,0,0 -BRDA:5,1,0,1 -BRDA:5,1,1,27 -BRDA:8,2,0,0 -BRDA:8,3,0,28 -BRDA:8,3,1,0 -BRDA:17,4,0,57 -BRDA:17,4,1,39 -BRDA:21,5,0,1 -BRDA:21,5,1,21 -BRF:10 -BRH:7 -end_of_record -TN: -SF:src\validators\base.ts -FN:10,(anonymous_0) -FNF:1 -FNH:1 -FNDA:79,(anonymous_0) -DA:1,13 -DA:2,13 -DA:4,13 -DA:11,79 -DA:12,79 -DA:14,79 -DA:17,77 -DA:19,2 -DA:20,2 -DA:21,2 -DA:23,0 -LF:11 -LH:10 -BRDA:19,0,0,2 -BRDA:19,0,1,0 -BRDA:20,1,0,2 -BRF:3 -BRH:2 -end_of_record -TN: -SF:src\validators\bitcoin.ts -FN:8,(anonymous_0) -FN:22,(anonymous_1) -FN:48,(anonymous_2) -FN:93,(anonymous_3) -FNF:4 -FNH:4 -FNDA:11,(anonymous_0) -FNDA:4,(anonymous_1) -FNDA:6,(anonymous_2) -FNDA:2,(anonymous_3) -DA:1,13 -DA:2,13 -DA:3,13 -DA:4,13 -DA:5,13 -DA:7,13 -DA:10,11 -DA:11,4 -DA:15,7 -DA:16,6 -DA:19,1 -DA:23,4 -DA:24,1 -DA:26,3 -DA:27,3 -DA:28,3 -DA:29,1 -DA:33,2 -DA:34,2 -DA:35,2 -DA:36,2 -DA:38,2 -DA:39,0 -DA:42,2 -DA:44,0 -DA:49,6 -DA:50,6 -DA:51,3 -DA:54,3 -DA:55,0 -DA:58,3 -DA:61,3 -DA:62,2 -DA:63,0 -DA:65,2 -DA:66,0 -DA:68,2 -DA:72,1 -DA:73,1 -DA:74,0 -DA:76,1 -DA:77,0 -DA:79,1 -DA:83,0 -DA:84,0 -DA:85,0 -DA:87,0 -DA:90,0 -DA:94,2 -DA:95,1 -DA:96,1 -DA:98,1 -LF:52 -LH:40 -BRDA:10,0,0,4 -BRDA:10,1,0,11 -BRDA:10,1,1,7 -BRDA:15,2,0,6 -BRDA:23,3,0,1 -BRDA:23,4,0,4 -BRDA:23,4,1,3 -BRDA:28,5,0,1 -BRDA:38,6,0,0 -BRDA:38,7,0,2 -BRDA:38,7,1,2 -BRDA:38,7,2,2 -BRDA:38,7,3,2 -BRDA:50,8,0,3 -BRDA:54,9,0,0 -BRDA:61,10,0,2 -BRDA:62,11,0,0 -BRDA:62,12,0,2 -BRDA:62,12,1,2 -BRDA:65,13,0,0 -BRDA:72,14,0,1 -BRDA:73,15,0,0 -BRDA:76,16,0,0 -BRDA:83,17,0,0 -BRDA:83,18,0,0 -BRDA:83,18,1,0 -BRDA:84,19,0,0 -BRDA:94,20,0,1 -BRDA:95,21,0,1 -BRDA:95,21,1,0 -BRF:30 -BRH:19 -end_of_record -TN: -SF:src\validators\cardano.ts -FN:7,(anonymous_0) -FN:21,(anonymous_1) -FN:37,(anonymous_2) -FN:53,(anonymous_3) -FNF:4 -FNH:3 -FNDA:8,(anonymous_0) -FNDA:3,(anonymous_1) -FNDA:5,(anonymous_2) -FNDA:0,(anonymous_3) -DA:1,13 -DA:2,13 -DA:3,13 -DA:4,13 -DA:6,13 -DA:9,8 -DA:10,3 -DA:14,5 -DA:15,5 -DA:18,0 -DA:22,3 -DA:23,3 -DA:24,1 -DA:27,2 -DA:28,2 -DA:29,0 -DA:32,2 -DA:34,2 -DA:38,5 -DA:42,5 -DA:43,5 -DA:44,2 -DA:47,3 -DA:49,0 -DA:54,0 -DA:55,0 -DA:56,0 -DA:58,0 -LF:28 -LH:21 -BRDA:9,0,0,3 -BRDA:9,1,0,8 -BRDA:9,1,1,6 -BRDA:9,1,2,5 -BRDA:9,1,3,5 -BRDA:14,2,0,5 -BRDA:14,3,0,5 -BRDA:14,3,1,2 -BRDA:14,3,2,0 -BRDA:23,4,0,1 -BRDA:28,5,0,0 -BRDA:32,6,0,1 -BRDA:32,6,1,1 -BRDA:43,7,0,2 -BRDA:43,8,0,5 -BRDA:43,8,1,3 -BRDA:54,9,0,0 -BRDA:55,10,0,0 -BRDA:55,10,1,0 -BRF:19 -BRH:14 -end_of_record -TN: -SF:src\validators\dogecoin.ts -FN:7,(anonymous_0) -FN:39,(anonymous_1) -FNF:2 -FNH:2 -FNDA:7,(anonymous_0) -FNDA:2,(anonymous_1) -DA:1,13 -DA:2,13 -DA:3,13 -DA:4,13 -DA:6,13 -DA:9,7 -DA:10,1 -DA:13,6 -DA:14,1 -DA:17,5 -DA:18,5 -DA:19,5 -DA:20,1 -DA:24,4 -DA:25,4 -DA:26,4 -DA:27,4 -DA:29,4 -DA:30,1 -DA:33,3 -DA:35,0 -DA:40,2 -DA:41,1 -DA:42,1 -DA:44,1 -LF:25 -LH:24 -BRDA:9,0,0,1 -BRDA:9,1,0,7 -BRDA:9,1,1,2 -BRDA:9,1,2,1 -BRDA:13,2,0,1 -BRDA:13,3,0,6 -BRDA:13,3,1,5 -BRDA:19,4,0,1 -BRDA:29,5,0,1 -BRDA:29,6,0,4 -BRDA:29,6,1,3 -BRDA:29,6,2,3 -BRDA:29,6,3,3 -BRDA:40,7,0,1 -BRDA:41,8,0,1 -BRDA:41,8,1,1 -BRF:16 -BRH:16 -end_of_record -TN: -SF:src\validators\ethereum.ts -FN:7,(anonymous_0) -FN:47,(anonymous_1) -FN:62,(anonymous_2) -FN:67,(anonymous_3) -FN:80,(anonymous_4) -FNF:5 -FNH:5 -FNDA:27,(anonymous_0) -FNDA:5,(anonymous_1) -FNDA:20,(anonymous_2) -FNDA:8,(anonymous_3) -FNDA:31,(anonymous_4) -DA:1,13 -DA:2,13 -DA:3,13 -DA:4,13 -DA:6,13 -DA:8,27 -DA:12,27 -DA:14,2 -DA:18,25 -DA:20,2 -DA:24,23 -DA:26,1 -DA:30,22 -DA:31,8 -DA:33,2 -DA:37,20 -DA:48,5 -DA:50,5 -DA:51,3 -DA:54,5 -DA:55,2 -DA:56,2 -DA:59,3 -DA:63,20 -DA:64,20 -DA:68,8 -DA:71,8 -DA:72,0 -DA:76,8 -DA:77,8 -DA:81,31 -DA:82,31 -DA:83,31 -DA:84,31 -DA:85,31 -DA:87,31 -DA:88,1240 -DA:89,597 -DA:91,643 -DA:94,31 -DA:96,0 -DA:97,0 -LF:42 -LH:39 -BRDA:12,0,0,2 -BRDA:18,1,0,2 -BRDA:24,2,0,1 -BRDA:30,3,0,8 -BRDA:30,4,0,22 -BRDA:30,4,1,22 -BRDA:30,4,2,9 -BRDA:31,5,0,2 -BRDA:48,6,0,5 -BRDA:48,6,1,0 -BRDA:50,7,0,3 -BRDA:54,8,0,2 -BRDA:55,9,0,2 -BRDA:55,9,1,2 -BRDA:71,10,0,0 -BRDA:71,11,0,8 -BRDA:71,11,1,8 -BRDA:82,12,0,0 -BRDA:88,13,0,597 -BRDA:88,13,1,643 -BRF:20 -BRH:17 -end_of_record -TN: -SF:src\validators\evm.ts -FN:5,(anonymous_0) -FN:15,(anonymous_1) -FN:25,(anonymous_2) -FN:35,(anonymous_3) -FN:45,(anonymous_4) -FNF:5 -FNH:5 -FNDA:2,(anonymous_0) -FNDA:2,(anonymous_1) -FNDA:2,(anonymous_2) -FNDA:2,(anonymous_3) -FNDA:2,(anonymous_4) -DA:1,13 -DA:4,13 -DA:6,2 -DA:7,2 -DA:8,2 -DA:10,2 -DA:14,13 -DA:16,2 -DA:17,2 -DA:18,2 -DA:20,2 -DA:24,13 -DA:26,2 -DA:27,2 -DA:28,2 -DA:30,2 -DA:34,13 -DA:36,2 -DA:37,2 -DA:38,2 -DA:40,2 -DA:44,13 -DA:46,2 -DA:47,2 -DA:48,2 -DA:50,2 -LF:26 -LH:26 -BRDA:7,0,0,2 -BRDA:17,1,0,2 -BRDA:27,2,0,2 -BRDA:37,3,0,2 -BRDA:47,4,0,2 -BRF:5 -BRH:5 -end_of_record -TN: -SF:src\validators\litecoin.ts -FN:8,(anonymous_0) -FN:22,(anonymous_1) -FN:48,(anonymous_2) -FN:82,(anonymous_3) -FNF:4 -FNH:4 -FNDA:9,(anonymous_0) -FNDA:6,(anonymous_1) -FNDA:3,(anonymous_2) -FNDA:2,(anonymous_3) -DA:1,13 -DA:2,13 -DA:3,13 -DA:4,13 -DA:5,13 -DA:7,13 -DA:10,9 -DA:11,6 -DA:15,3 -DA:16,3 -DA:19,0 -DA:23,6 -DA:24,1 -DA:26,5 -DA:27,5 -DA:28,5 -DA:29,1 -DA:33,4 -DA:34,4 -DA:35,4 -DA:36,4 -DA:38,4 -DA:39,1 -DA:42,3 -DA:44,0 -DA:49,3 -DA:50,3 -DA:51,2 -DA:54,1 -DA:55,0 -DA:58,1 -DA:61,1 -DA:62,1 -DA:63,0 -DA:65,1 -DA:66,0 -DA:68,1 -DA:72,0 -DA:73,0 -DA:74,0 -DA:76,0 -DA:79,0 -DA:83,2 -DA:84,1 -DA:85,1 -DA:87,1 -LF:46 -LH:36 -BRDA:10,0,0,6 -BRDA:10,1,0,9 -BRDA:10,1,1,4 -BRDA:15,2,0,3 -BRDA:23,3,0,1 -BRDA:23,4,0,6 -BRDA:23,4,1,5 -BRDA:28,5,0,1 -BRDA:38,6,0,1 -BRDA:38,7,0,4 -BRDA:38,7,1,4 -BRDA:38,7,2,4 -BRDA:38,7,3,4 -BRDA:50,8,0,2 -BRDA:54,9,0,0 -BRDA:61,10,0,1 -BRDA:62,11,0,0 -BRDA:62,12,0,1 -BRDA:62,12,1,1 -BRDA:65,13,0,0 -BRDA:72,14,0,0 -BRDA:72,15,0,0 -BRDA:72,15,1,0 -BRDA:73,16,0,0 -BRDA:83,17,0,1 -BRDA:84,18,0,1 -BRDA:84,18,1,0 -BRF:27 -BRH:19 -end_of_record -TN: -SF:src\validators\polygon.ts -FN:5,(anonymous_0) -FNF:1 -FNH:1 -FNDA:5,(anonymous_0) -DA:1,13 -DA:4,13 -DA:6,5 -DA:7,5 -DA:8,3 -DA:10,5 -LF:6 -LH:6 -BRDA:7,0,0,3 -BRF:1 -BRH:1 -end_of_record -TN: -SF:src\validators\ripple.ts -FN:15,decodeRippleBase58 -FN:63,(anonymous_1) -FN:95,(anonymous_2) -FNF:3 -FNH:3 -FNDA:6,decodeRippleBase58 -FNDA:8,(anonymous_1) -FNDA:2,(anonymous_2) -DA:1,13 -DA:2,13 -DA:3,13 -DA:6,13 -DA:7,13 -DA:8,13 -DA:10,13 -DA:11,13 -DA:12,754 -DA:16,6 -DA:18,6 -DA:19,6 -DA:20,39 -DA:22,6 -DA:24,6 -DA:26,6 -DA:27,165 -DA:28,165 -DA:29,165 -DA:30,1 -DA:33,164 -DA:34,1967 -DA:36,164 -DA:38,164 -DA:39,164 -DA:40,1967 -DA:41,1967 -DA:42,1967 -DA:44,164 -DA:45,115 -DA:46,115 -DA:50,5 -DA:51,5 -DA:52,4 -DA:55,5 -DA:56,38 -DA:59,5 -DA:62,13 -DA:65,8 -DA:66,1 -DA:69,7 -DA:70,1 -DA:73,6 -DA:74,6 -DA:75,5 -DA:76,1 -DA:80,4 -DA:81,4 -DA:82,4 -DA:83,4 -DA:85,4 -DA:86,1 -DA:89,3 -DA:91,1 -DA:96,2 -DA:97,1 -DA:98,1 -DA:100,1 -LF:58 -LH:58 -BRDA:16,0,0,0 -BRDA:19,1,0,45 -BRDA:19,1,1,44 -BRDA:29,2,0,1 -BRDA:51,3,0,4 -BRDA:65,4,0,1 -BRDA:69,5,0,1 -BRDA:69,6,0,7 -BRDA:69,6,1,6 -BRDA:75,7,0,1 -BRDA:85,8,0,1 -BRDA:85,9,0,4 -BRDA:85,9,1,4 -BRDA:85,9,2,4 -BRDA:85,9,3,4 -BRDA:96,10,0,1 -BRDA:97,11,0,1 -BRDA:97,11,1,1 -BRF:18 -BRH:17 -end_of_record -TN: -SF:src\validators\solana.ts -FN:6,(anonymous_0) -FN:38,(anonymous_1) -FNF:2 -FNH:2 -FNDA:7,(anonymous_0) -FNDA:3,(anonymous_1) -DA:1,13 -DA:2,13 -DA:3,13 -DA:5,13 -DA:7,7 -DA:8,2 -DA:11,5 -DA:12,5 -DA:13,4 -DA:14,1 -DA:17,1 -DA:22,3 -DA:27,1 -DA:28,1 -DA:32,2 -DA:39,3 -DA:40,2 -DA:41,2 -DA:43,1 -LF:19 -LH:19 -BRDA:7,0,0,2 -BRDA:7,1,0,7 -BRDA:7,1,1,5 -BRDA:13,2,0,1 -BRDA:22,3,0,1 -BRDA:27,4,0,1 -BRDA:39,5,0,2 -BRDA:40,6,0,2 -BRDA:40,6,1,0 -BRF:9 -BRH:8 -end_of_record diff --git a/final_lint_check.txt b/final_lint_check.txt deleted file mode 100644 index e69de29..0000000 diff --git a/lint_output.txt b/lint_output.txt deleted file mode 100644 index 51c0dff..0000000 --- a/lint_output.txt +++ /dev/null @@ -1,6 +0,0 @@ - -C:\PC\Codes\validator0x\src\validators\base.ts - 10:38 error '_options' is defined but never used @typescript-eslint/no-unused-vars - -Γ£û 1 problem (1 error, 0 warnings) - diff --git a/scripts/test-package.mjs b/scripts/test-package.mjs index c96395d..8590289 100644 --- a/scripts/test-package.mjs +++ b/scripts/test-package.mjs @@ -123,7 +123,8 @@ try { const solanaSize = gzipSync(solanaModule).length; const workerCode = `import { SolanaValidator } from './solana.mjs'; postMessage(new SolanaValidator().validate('HN7cABqLq46Es1jh92dQQy4aWDtG751BHhP1K2HWT7k1').valid);`; - const chrome = await chromium.launch({ channel: 'chrome' }); + // Prefer the installed Chrome (CI runners ship it); fall back to Playwright's bundled Chromium. + const chrome = await chromium.launch({ channel: 'chrome' }).catch(() => chromium.launch()); const server = createServer((request, response) => { if (request.url === '/') { response.setHeader('Content-Type', 'text/html'); diff --git a/src/utils/base58.ts b/src/utils/base58.ts index 1ba4f98..4452b0c 100644 --- a/src/utils/base58.ts +++ b/src/utils/base58.ts @@ -1,11 +1,5 @@ const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; const BASE = 58; -const LEADER = ALPHABET.charAt(0); - -const ALPHABET_MAP: { [key: string]: number } = {}; -for (let i = 0; i < ALPHABET.length; i++) { - ALPHABET_MAP[ALPHABET.charAt(i)] = i; -} export function encodeBase58(source: Uint8Array): string { if (source.length === 0) return ''; @@ -37,41 +31,35 @@ export function encodeBase58(source: Uint8Array): string { return digits.reverse().map(d => ALPHABET[d]).join(''); } -export function decodeBase58(string: string): Uint8Array { - if (string.length === 0) return new Uint8Array(0); - - let i = 0; - while (i < string.length && string[i] === LEADER) { - i++; - } - const leaders = i; - - const bytes = [0]; - - for (; i < string.length; i++) { - const char = string[i]; - const value = ALPHABET_MAP[char]; - if (value === undefined) { - throw new Error(`Invalid Base58 character: ${char}`); - } - - for (let j = 0; j < bytes.length; j++) { - bytes[j] *= BASE; +/** Build a Base58 decoder for an alphabet whose first character encodes a leading zero byte. */ +export function createBase58Decoder(alphabet: string): (input: string) => Uint8Array { + const map = new Int8Array(128).fill(-1); + for (let i = 0; i < alphabet.length; i++) map[alphabet.charCodeAt(i)] = i; + const leader = alphabet.charCodeAt(0); + return (input: string): Uint8Array => { + let leaders = 0; + while (leaders < input.length && input.charCodeAt(leaders) === leader) leaders++; + // log(58) / log(256) ~= 0.733, so this bounds the decoded size. + const bytes = new Uint8Array(((input.length - leaders) * 733) / 1000 + 1 >>> 0); + let length = 0; + for (let i = leaders; i < input.length; i++) { + const code = input.charCodeAt(i); + const value = code < 128 ? map[code] : -1; + if (value === -1) throw new Error(`Invalid Base58 character: ${input[i]}`); + let carry = value; + let j = 0; + for (; j < length || carry !== 0; j++) { + const k = bytes.length - 1 - j; + carry += BASE * bytes[k]; + bytes[k] = carry & 0xff; + carry >>>= 8; + } + length = j; } - bytes[0] += value; - - let carry = 0; - for (let j = 0; j < bytes.length; ++j) { - bytes[j] += carry; - carry = bytes[j] >> 8; - bytes[j] &= 0xff; - } - while (carry) { - bytes.push(carry & 0xff); - carry >>= 8; - } - } - - const resultBytes = string.length === leaders ? [] : bytes.reverse(); - return Uint8Array.from([...new Array(leaders).fill(0), ...resultBytes]); + const result = new Uint8Array(leaders + length); + result.set(bytes.subarray(bytes.length - length), leaders); + return result; + }; } + +export const decodeBase58 = createBase58Decoder(ALPHABET); diff --git a/src/utils/keccak256.ts b/src/utils/keccak256.ts index ecf0b5c..a4a6282 100644 --- a/src/utils/keccak256.ts +++ b/src/utils/keccak256.ts @@ -1,47 +1,94 @@ // Keccak-f[1600], rate 1088, capacity 512; Ethereum uses suffix 0x01, not SHA3's 0x06. -const MASK = (1n << 64n) - 1n; +// Each 64-bit lane is stored as two 32-bit halves (lo at 2i, hi at 2i + 1) so the +// permutation runs on plain integer arithmetic instead of BigInt. +const RATE = 136; const ROTATIONS = [0, 1, 62, 28, 27, 36, 44, 6, 55, 20, 3, 10, 43, 25, 39, 41, 45, 15, 21, 8, 18, 2, 61, 56, 14]; -const ROUND_CONSTANTS = [ - 0x0000000000000001n, 0x0000000000008082n, 0x800000000000808an, 0x8000000080008000n, - 0x000000000000808bn, 0x0000000080000001n, 0x8000000080008081n, 0x8000000000008009n, - 0x000000000000008an, 0x0000000000000088n, 0x0000000080008009n, 0x000000008000000an, - 0x000000008000808bn, 0x800000000000008bn, 0x8000000000008089n, 0x8000000000008003n, - 0x8000000000008002n, 0x8000000000000080n, 0x000000000000800an, 0x800000008000000an, - 0x8000000080008081n, 0x8000000000008080n, 0x0000000080000001n, 0x8000000080008008n, -]; -function rotate(value: bigint, bits: number): bigint { - return ((value << BigInt(bits)) | (value >> BigInt(64 - bits))) & MASK; -} -function permute(state: bigint[]): void { - const c = new Array(5); - const b = new Array(25); - for (const rc of ROUND_CONSTANTS) { - for (let x = 0; x < 5; x++) c[x] = state[x] ^ state[x + 5] ^ state[x + 10] ^ state[x + 15] ^ state[x + 20]; +// Round constants as [lo, hi] pairs. +const ROUND_CONSTANTS = new Uint32Array([ + 0x00000001, 0x00000000, 0x00008082, 0x00000000, 0x0000808a, 0x80000000, 0x80008000, 0x80000000, + 0x0000808b, 0x00000000, 0x80000001, 0x00000000, 0x80008081, 0x80000000, 0x00008009, 0x80000000, + 0x0000008a, 0x00000000, 0x00000088, 0x00000000, 0x80008009, 0x00000000, 0x8000000a, 0x00000000, + 0x8000808b, 0x00000000, 0x0000008b, 0x80000000, 0x00008089, 0x80000000, 0x00008003, 0x80000000, + 0x00008002, 0x80000000, 0x00000080, 0x80000000, 0x0000800a, 0x00000000, 0x8000000a, 0x80000000, + 0x80008081, 0x80000000, 0x00008080, 0x80000000, 0x80000001, 0x00000000, 0x80008008, 0x80000000, +]); +// Destination lane for rho/pi: lane x + 5y moves to y + 5((2x + 3y) % 5). +const PI = new Uint8Array(25); +for (let x = 0; x < 5; x++) for (let y = 0; y < 5; y++) PI[x + 5 * y] = y + 5 * ((2 * x + 3 * y) % 5); + +const C = new Uint32Array(10); +const B = new Uint32Array(50); + +function permute(s: Uint32Array): void { + for (let round = 0; round < 48; round += 2) { + // Theta + for (let x = 0; x < 10; x++) C[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40]; for (let x = 0; x < 5; x++) { - const d = c[(x + 4) % 5] ^ rotate(c[(x + 1) % 5], 1); - for (let y = 0; y < 5; y++) state[x + 5 * y] ^= d; + const p = ((x + 4) % 5) * 2; + const n = ((x + 1) % 5) * 2; + const lo = C[p] ^ ((C[n] << 1) | (C[n + 1] >>> 31)); + const hi = C[p + 1] ^ ((C[n + 1] << 1) | (C[n] >>> 31)); + for (let y = 0; y < 50; y += 10) { + s[2 * x + y] ^= lo; + s[2 * x + y + 1] ^= hi; + } } - for (let x = 0; x < 5; x++) { - for (let y = 0; y < 5; y++) b[y + 5 * ((2 * x + 3 * y) % 5)] = rotate(state[x + 5 * y], ROTATIONS[x + 5 * y]); + // Rho and Pi + for (let i = 0; i < 25; i++) { + const lo = s[2 * i]; + const hi = s[2 * i + 1]; + const r = ROTATIONS[i]; + const d = PI[i] * 2; + if (r === 0) { + B[d] = lo; + B[d + 1] = hi; + } else if (r < 32) { + B[d] = (lo << r) | (hi >>> (32 - r)); + B[d + 1] = (hi << r) | (lo >>> (32 - r)); + } else if (r === 32) { + B[d] = hi; + B[d + 1] = lo; + } else { + const m = r - 32; + B[d] = (hi << m) | (lo >>> (32 - m)); + B[d + 1] = (lo << m) | (hi >>> (32 - m)); + } } - for (let x = 0; x < 5; x++) { - for (let y = 0; y < 5; y++) state[x + 5 * y] = b[x + 5 * y] ^ ((~b[(x + 1) % 5 + 5 * y]) & b[(x + 2) % 5 + 5 * y]); + // Chi + for (let y = 0; y < 50; y += 10) { + for (let x = 0; x < 5; x++) { + const i = y + 2 * x; + const a = y + 2 * ((x + 1) % 5); + const b = y + 2 * ((x + 2) % 5); + s[i] = B[i] ^ (~B[a] & B[b]); + s[i + 1] = B[i + 1] ^ (~B[a + 1] & B[b + 1]); + } } - state[0] ^= rc; + // Iota + s[0] ^= ROUND_CONSTANTS[round]; + s[1] ^= ROUND_CONSTANTS[round + 1]; } } + +const encoder = new TextEncoder(); +const HEX = '0123456789abcdef'; + export function keccak256(input: string): string { - const bytes = new TextEncoder().encode(input); - const padded = new Uint8Array((Math.floor(bytes.length / 136) + 1) * 136); + const bytes = encoder.encode(input); + const padded = new Uint8Array((Math.floor(bytes.length / RATE) + 1) * RATE); padded.set(bytes); padded[bytes.length] = 1; padded[padded.length - 1] |= 128; - const state = new Array(25).fill(0n); - for (let offset = 0; offset < padded.length; offset += 136) { - for (let i = 0; i < 136; i++) state[i >> 3] ^= BigInt(padded[offset + i]) << BigInt((i & 7) * 8); + const state = new Uint32Array(50); + for (let offset = 0; offset < padded.length; offset += RATE) { + // Lanes are little-endian: byte i lands in half-word i >> 2 at bit (i & 3) * 8. + for (let i = 0; i < RATE; i++) state[i >> 2] ^= padded[offset + i] << ((i & 3) * 8); permute(state); } let result = ''; - for (let i = 0; i < 32; i++) result += Number((state[i >> 3] >> BigInt((i & 7) * 8)) & 255n).toString(16).padStart(2, '0'); + for (let i = 0; i < 32; i++) { + const byte = (state[i >> 2] >>> ((i & 3) * 8)) & 255; + result += HEX[byte >> 4] + HEX[byte & 15]; + } return result; } diff --git a/src/utils/sha256.ts b/src/utils/sha256.ts index a287900..8bcf60a 100644 --- a/src/utils/sha256.ts +++ b/src/utils/sha256.ts @@ -1,15 +1,16 @@ -export function sha256(input: Uint8Array): Uint8Array { - const K = [ - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, - 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, - 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, - 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, - 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, - 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, - 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, - 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 - ]; +const K = new Uint32Array([ + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +]); +const W = new Uint32Array(64); +export function sha256(input: Uint8Array): Uint8Array { const H = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19]; const len = input.length * 8; @@ -41,8 +42,6 @@ export function sha256(input: Uint8Array): Uint8Array { msg.set(input); msg.set(padding, lenByte); - const W = new Uint32Array(64); - for (let i = 0; i < msg.length; i += 64) { // Prepare message schedule for (let t = 0; t < 16; t++) { diff --git a/src/validators/ethereum.ts b/src/validators/ethereum.ts index 008ffe3..ea8c1c1 100644 --- a/src/validators/ethereum.ts +++ b/src/validators/ethereum.ts @@ -59,6 +59,9 @@ export class EthereumValidator extends AddressValidator { const clean = stripHexPrefix(address).toLowerCase(); if (!/^[0-9a-f]{40}$/.test(clean)) throw new Error('Expected a 20-byte hexadecimal address'); const hash = keccak256(clean); - return '0x' + [...clean].map((char, i) => parseInt(hash[i], 16) >= 8 ? char.toUpperCase() : char).join(''); + let result = '0x'; + // A hash nibble of 8-f (char code >= '8') marks a letter that must be uppercase. + for (let i = 0; i < 40; i++) result += hash.charCodeAt(i) >= 56 ? clean[i].toUpperCase() : clean[i]; + return result; } } diff --git a/src/validators/ripple.ts b/src/validators/ripple.ts index 1c4fd38..6cb9633 100644 --- a/src/validators/ripple.ts +++ b/src/validators/ripple.ts @@ -1,63 +1,10 @@ import { AddressValidator } from './base'; import { ValidationResult, ValidationError } from '../types'; import { sha256 } from '../utils/sha256'; +import { createBase58Decoder } from '../utils/base58'; // Ripple uses a custom Base58 dictionary -const RIPPLE_ALPHABET = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'; -const BASE = 58; -const LEADER = RIPPLE_ALPHABET.charAt(0); - -const ALPHABET_MAP: { [key: string]: number } = {}; -for (let i = 0; i < RIPPLE_ALPHABET.length; i++) { - ALPHABET_MAP[RIPPLE_ALPHABET.charAt(i)] = i; -} - -function decodeRippleBase58(string: string): Uint8Array { - if (string.length === 0) return new Uint8Array(0); - - let i = 0; - while (i < string.length && string[i] === LEADER) { - i++; - } - const leaders = i; - - const bytes = [0]; - - for (; i < string.length; i++) { - const char = string[i]; - const value = ALPHABET_MAP[char]; - if (value === undefined) { - throw new Error(`Invalid Ripple Base58 character: ${char}`); - } - - for (let j = 0; j < bytes.length; j++) { - bytes[j] *= BASE; - } - bytes[0] += value; - - let carry = 0; - for (let j = 0; j < bytes.length; ++j) { - bytes[j] += carry; - carry = bytes[j] >> 8; - bytes[j] &= 0xff; - } - while (carry) { - bytes.push(carry & 0xff); - carry >>= 8; - } - } - - let resultBytes: number[] = []; - if (string.length !== leaders) { - resultBytes = bytes.reverse(); - } - - for (let k = 0; k < leaders; k++) { - resultBytes.unshift(0); - } - - return new Uint8Array(resultBytes); -} +const decodeRippleBase58 = createBase58Decoder('rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'); export class RippleValidator extends AddressValidator { protected validateImplementation(address: string): ValidationResult { diff --git a/tests/cardano.test.ts b/tests/cardano.test.ts index 9cea305..d700a21 100644 --- a/tests/cardano.test.ts +++ b/tests/cardano.test.ts @@ -1,4 +1,6 @@ +import { bech32, bech32m } from '@scure/base'; import { validateAddress, CardanoValidator } from '../src'; +import { decodeBech32 } from '../src/utils/bech32'; import vectors from './fixtures/protocol-vectors.json'; // Published Byron example from CIP-19 (testnet). @@ -21,4 +23,53 @@ describe('Cardano', () => { expect(new CardanoValidator().format(address)).toBe(address); expect(new CardanoValidator().format(address, { shorten: true })).toBe(address.slice(0, 8) + '...' + address.slice(-8)); }); + + test('rejects the historical invalid Cardano checksum fixture', () => { + expect(decodeBech32('addr1qxyxps5q8vquk0xyed9k4w0eunv3c8hsnmxgf7th8qf5lqy4xgj970e4e7h886g8e27csh0lssn35n9p2r8m0xptz8cs22gexj', 256)).toBeNull(); + }); +}); + +// CIP-19 Shelley vectors and constructed edge cases. +const hash = Uint8Array.from({ length: 28 }, (_, i) => i + 1); +const shelley = (header: number, tail: number[] = [], hrp = 'addr', encoder = bech32) => + encoder.encode(hrp, encoder.toWords(Uint8Array.from([header, ...hash, ...tail])), 256); + +describe('Cardano Shelley', () => { + test('accepts the CIP-19 mainnet pointer and enterprise vectors', () => { + for (const address of [ + 'addr1gx2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer5pnz75xxcrzqf96k', + 'addr1vx2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzers66hrl8', + ]) expect(validateAddress(address, 'cardano')).toMatchObject({ valid: true, details: { format: 'shelley', network: 'mainnet' } }); + }); + + test.each([ + ['base address', 0x01, Array.from({ length: 28 }, () => 9), 'addr', 'mainnet'], + ['testnet enterprise', 0x60, [], 'addr_test', 'testnet'], + ['pointer (0, 0, 0)', 0x41, [0, 0, 0], 'addr', 'mainnet'], + ['pointer with multi-byte slot', 0x40, [0x81, 0x00, 1, 2], 'addr_test', 'testnet'], + ] as const)('accepts %s', (_, header, tail, hrp, network) => { + expect(validateAddress(shelley(header, [...tail], hrp), 'cardano')).toMatchObject({ valid: true, details: { network } }); + }); + + test('accepts stake addresses and reports the stake format', () => { + expect(validateAddress(shelley(0xe1, [], 'stake'), 'cardano')).toMatchObject({ valid: true, details: { format: 'stake', network: 'mainnet' } }); + expect(validateAddress(shelley(0xf0, [], 'stake_test'), 'cardano')).toMatchObject({ valid: true, details: { format: 'stake', network: 'testnet' } }); + }); + + test.each([ + ['network tag that is neither 0 nor 1', shelley(0x62)], + ['mainnet header with testnet prefix', shelley(0x61, [], 'addr_test')], + ['payment header with stake prefix', shelley(0x61, [], 'stake')], + ['base address missing its stake hash', shelley(0x01)], + ['enterprise address with trailing bytes', shelley(0x61, [0])], + ['reserved header type 8', shelley(0x81)], + ['pointer missing fields', shelley(0x41, [0, 0])], + ['pointer with trailing bytes', shelley(0x41, [0, 0, 0, 0])], + ['pointer with non-minimal varint', shelley(0x41, [0x80, 0x01, 0, 0])], + ['pointer with unterminated varint', shelley(0x41, [0, 0, 0x81])], + ['pointer cert index above 16 bits', shelley(0x41, [0, 0, 0x84, 0x80, 0x00])], + ['Bech32m checksum', shelley(0x61, [], 'addr', bech32m)], + ])('rejects %s', (_, address) => { + expect(validateAddress(address, 'cardano').valid).toBe(false); + }); }); diff --git a/tests/cardano_debug.test.ts b/tests/cardano_debug.test.ts deleted file mode 100644 index 13b7cac..0000000 --- a/tests/cardano_debug.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { decodeBech32 } from '../src/utils/bech32'; - -test('rejects the historical invalid Cardano checksum fixture', () => { - expect(decodeBech32('addr1qxyxps5q8vquk0xyed9k4w0eunv3c8hsnmxgf7th8qf5lqy4xgj970e4e7h886g8e27csh0lssn35n9p2r8m0xptz8cs22gexj', 256)).toBeNull(); -}); diff --git a/tests/cosmos.test.ts b/tests/cosmos.test.ts new file mode 100644 index 0000000..5a2ebae --- /dev/null +++ b/tests/cosmos.test.ts @@ -0,0 +1,62 @@ +import { bech32, bech32m } from '@scure/base'; +import { validateAddress, detectBlockchain, CosmosValidator, COSMOS_CHAINS, ValidationError } from '../src'; + +const prefixes = { cosmos: 'cosmos', osmosis: 'osmo', celestia: 'celestia', injective: 'inj', sei: 'sei' } as const; +const bytes = (length: number, seed = 7) => Uint8Array.from({ length }, (_, i) => (i * 31 + seed) & 255); +const encode = (hrp: string, data: Uint8Array) => bech32.encode(hrp, bech32.toWords(data)); + +describe('Cosmos SDK account addresses', () => { + // Published Cosmos Hub account address; independently decodable to a 20-byte account. + test('accepts a published Cosmos Hub address', () => { + const address = 'cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh'; + expect(validateAddress(address, 'cosmos')).toEqual({ valid: true, blockchain: 'cosmos', details: { format: 'bech32', checksum: true } }); + expect(detectBlockchain(address)).toBe('cosmos'); + }); + + test.each(COSMOS_CHAINS)('accepts 20-byte %s accounts and rejects other prefixes', chain => { + const address = encode(prefixes[chain], bytes(20)); + expect(validateAddress(address, chain)).toMatchObject({ valid: true, blockchain: chain }); + expect(validateAddress(address.toUpperCase(), chain).valid).toBe(true); + expect(detectBlockchain(address)).toBe(chain); + for (const other of COSMOS_CHAINS.filter(candidate => candidate !== chain)) { + expect(validateAddress(address, other).valid).toBe(false); + } + }); + + test.each([ + ['cosmos', true], ['osmosis', true], ['sei', true], ['injective', false], ['celestia', false], + ] as const)('32-byte module/ICA account on %s: valid=%s', (chain, expected) => { + expect(validateAddress(encode(prefixes[chain], bytes(32)), chain).valid).toBe(expected); + }); + + test('rejects wrong payload lengths, Bech32m, bad checksums, and mixed case', () => { + const address = encode('cosmos', bytes(20)); + for (const invalid of [ + encode('cosmos', bytes(19)), + encode('cosmos', bytes(21)), + bech32m.encode('cosmos', bech32m.toWords(bytes(20))), + address.slice(0, -1) + (address.endsWith('q') ? 'p' : 'q'), + address.slice(0, 10) + address.slice(10).toUpperCase(), + ]) { + expect(validateAddress(invalid, 'cosmos')).toMatchObject({ valid: false, details: { errorCode: ValidationError.INVALID_FORMAT } }); + } + }); + + test('rejects validator operator and consensus prefixes', () => { + for (const hrp of ['cosmosvaloper', 'cosmosvalcons', 'cosmospub']) { + expect(validateAddress(encode(hrp, bytes(20)), 'cosmos').valid).toBe(false); + } + }); + + test('rejects nonzero Bech32 padding', () => { + // 32 bytes = 256 bits in 52 words, leaving 4 padding bits that must be zero. + const words = bech32.toWords(bytes(32)); + expect(validateAddress(bech32.encode('cosmos', words), 'cosmos').valid).toBe(true); + words[words.length - 1] |= 1; + expect(validateAddress(bech32.encode('cosmos', words), 'cosmos').valid).toBe(false); + }); + + test('rejects unknown chains at construction time', () => { + expect(() => new CosmosValidator('juno' as never)).toThrow(RangeError); + }); +}); diff --git a/tests/network-policy.test.ts b/tests/network-policy.test.ts new file mode 100644 index 0000000..6070f80 --- /dev/null +++ b/tests/network-policy.test.ts @@ -0,0 +1,56 @@ +import { validateAddress, validateBatch, formatAddress, ValidationError } from '../src'; + +const mainnet = '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'; +const testnet = 'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx'; +const evm = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'; + +describe('Network policy', () => { + test('network filters addresses that encode a network', () => { + expect(validateAddress(mainnet, 'bitcoin', { network: 'mainnet' }).valid).toBe(true); + expect(validateAddress(testnet, 'bitcoin', { network: 'testnet' }).valid).toBe(true); + expect(validateAddress(mainnet, 'bitcoin', { network: 'auto' }).valid).toBe(true); + expect(validateAddress(testnet, 'bitcoin', { network: 'auto' }).valid).toBe(true); + }); + + test('mismatches keep format details and report NETWORK_MISMATCH', () => { + expect(validateAddress(mainnet, 'bitcoin', { network: 'testnet' })).toEqual({ + valid: false, + error: 'Address network does not match the requested network', + details: { format: 'legacy', network: 'mainnet', checksum: true, errorCode: ValidationError.NETWORK_MISMATCH }, + }); + expect(validateAddress(testnet, 'bitcoin', { network: 'mainnet' }).details?.errorCode).toBe(ValidationError.NETWORK_MISMATCH); + }); + + test('allowTestnet: false rejects only testnet addresses', () => { + expect(validateAddress(testnet, 'bitcoin', { allowTestnet: false }).details?.errorCode).toBe(ValidationError.NETWORK_MISMATCH); + expect(validateAddress(mainnet, 'bitcoin', { allowTestnet: false }).valid).toBe(true); + expect(validateAddress(testnet, 'bitcoin', { allowTestnet: true }).valid).toBe(true); + }); + + test('network options never reject chains whose addresses carry no network', () => { + for (const network of ['mainnet', 'testnet'] as const) { + const result = validateAddress(evm, 'ethereum', { network, allowTestnet: false }); + expect(result.valid).toBe(true); + expect(result.details?.network).toBeUndefined(); + } + }); + + test('batch validation applies the same policy to every entry', () => { + expect(validateBatch([mainnet, testnet, 42], 'bitcoin', { network: 'mainnet' }).map(result => result.details?.errorCode)) + .toEqual([undefined, ValidationError.NETWORK_MISMATCH, ValidationError.UNSAFE_INPUT]); + }); +}); + +describe('Aptos formatting', () => { + test('normalizes case and collapses special addresses', () => { + expect(formatAddress('0x' + 'AB'.repeat(32), 'aptos')).toBe('0x' + 'ab'.repeat(32)); + expect(formatAddress(' 0x' + '0'.repeat(63) + '1 ', 'aptos')).toBe('0x1'); + expect(formatAddress('0x' + 'ab'.repeat(32), 'aptos', { shorten: true })).toBe('0xabab...abab'); + }); + + test('throws on malformed input instead of returning a display string', () => { + for (const invalid of ['0x123', 'not an address', '0x' + 'g'.repeat(64)]) { + expect(() => formatAddress(invalid, 'aptos')).toThrow('Invalid Aptos address'); + } + }); +}); diff --git a/tests/utils.test.ts b/tests/utils.test.ts index e82dabd..acc5651 100644 --- a/tests/utils.test.ts +++ b/tests/utils.test.ts @@ -1,4 +1,6 @@ -import { encodeBase58, decodeBase58 } from '../src/utils/base58'; +import { keccak_256 } from '@noble/hashes/sha3.js'; +import { encodeBase58, decodeBase58, createBase58Decoder } from '../src/utils/base58'; +import { decodeBase58Check } from '../src/utils/base58check'; import { isHex, stripHexPrefix, addHexPrefix } from '../src/utils/hex'; import { decodeBech32 } from '../src/utils/bech32'; import { keccak256 } from '../src/utils/keccak256'; @@ -67,3 +69,44 @@ describe('Utils', () => { }); }); +describe('Keccak-256', () => { + test.each([ + ['', 'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'], + ['abc', '4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45'], + ])('matches the published digest of %j', (input, digest) => { + expect(keccak256(input)).toBe(digest); + }); + + // 135, 136 and 137 bytes straddle the 136-byte rate; 272+ spans several blocks. + test.each([1, 40, 135, 136, 137, 271, 272, 273, 500])('matches @noble/hashes for %i-byte input', length => { + const input = 'x'.repeat(length); + expect(keccak256(input)).toBe(Buffer.from(keccak_256(new TextEncoder().encode(input))).toString('hex')); + }); +}); + +describe('Base58 decoding', () => { + test('preserves leading zero bytes and handles all-zero input', () => { + expect(Array.from(decodeBase58('1112'))).toEqual([0, 0, 0, 1]); + expect(Array.from(decodeBase58('111'))).toEqual([0, 0, 0]); + expect(decodeBase58('')).toHaveLength(0); + }); + + test('rejects characters outside the alphabet, including non-ASCII', () => { + for (const invalid of ['0', 'O', 'I', 'l', '+', '\u00e9', '\u{1F600}']) { + expect(() => decodeBase58('2' + invalid)).toThrow('Invalid Base58 character'); + } + }); + + test('supports custom alphabets', () => { + const decode = createBase58Decoder('rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'); + expect(Array.from(decode('rrp'))).toEqual([0, 0, 1]); + expect(() => decode('r1l')).toThrow(); + }); + + test('Base58Check returns null instead of throwing on bad input', () => { + expect(decodeBase58Check('0OIl')).toBeNull(); + expect(decodeBase58Check('2')).toBeNull(); + expect(decodeBase58Check('1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNb')).toBeNull(); + expect(decodeBase58Check('1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa')).toHaveLength(21); + }); +}); From 4741a8f1e2c7c4646e410ee033a387bd4af01697 Mon Sep 17 00:00:00 2001 From: Dhananjay Hire Date: Sat, 21 Nov 2026 10:13:55 +0000 Subject: [PATCH 2/6] fix: throw RangeError for an invalid network option Values other than 'mainnet', 'testnet' or 'auto' previously made every network-bearing address fail with NETWORK_MISMATCH while EVM and other network-less chains still passed. Reject them up front like an unsupported chain. Closes #6 --- README.md | 2 +- src/validators/base.ts | 13 +++++++++---- tests/network-policy.test.ts | 11 +++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 381c189..56f723c 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ validateAddress(address, chain, { ``` - `strict` defaults to `false`. On EVM, `true` requires the exact EIP-55 capitalization, including the rare valid all-lowercase/all-uppercase checksums. Invalid mixed-case EVM checksums are always rejected. On Aptos, strict mode requires lowercase AIP-40 canonical representation. Other formats always verify their mandatory checksums. -- `network` defaults to `auto`. It filters networks **only when encoded in the address**, currently Bitcoin, Litecoin, Dogecoin, and Cardano. `details.network` is omitted for formats that cannot identify mainnet/testnet. Selecting a network never proves an address belongs to it. +- `network` defaults to `auto`; any other value than `'mainnet'`, `'testnet'`, or `'auto'` throws a `RangeError`. It filters networks **only when encoded in the address**, currently Bitcoin, Litecoin, Dogecoin, and Cardano. `details.network` is omitted for formats that cannot identify mainnet/testnet. Selecting a network never proves an address belongs to it. - `allowTestnet: false` rejects identifiable testnet addresses, including when `network: 'testnet'` is also supplied. It is not an on-chain network check. - `allowBurnAddress` defaults to `false` and controls only the EVM all-zero address. It is not a comprehensive burn-address database. Other reserved/program addresses may be syntactically valid. diff --git a/src/validators/base.ts b/src/validators/base.ts index b296891..05e1690 100644 --- a/src/validators/base.ts +++ b/src/validators/base.ts @@ -8,16 +8,21 @@ export abstract class AddressValidator { * @param options - Validation options */ public validate(address: unknown, options?: ValidationOptions): ValidationResult { + // Options come from the caller, not the user: a typo must fail loudly, not as NETWORK_MISMATCH. + const network = options?.network; + if (network !== undefined && network !== 'mainnet' && network !== 'testnet' && network !== 'auto') { + throw new RangeError(`Invalid network option: ${String(network)} (expected 'mainnet', 'testnet' or 'auto')`); + } try { // Security: Sanitize input first const safeAddress = InputSanitizer.sanitize(address); // Perform validation on sanitized input const result = this.validateImplementation(safeAddress, options); - const network = result.details?.network; - if (result.valid && network && ( - (options?.network && options.network !== 'auto' && options.network !== network) || - (options?.allowTestnet === false && network === 'testnet') + const encoded = result.details?.network; + if (result.valid && encoded && ( + (network && network !== 'auto' && network !== encoded) || + (options?.allowTestnet === false && encoded === 'testnet') )) { return { valid: false, error: 'Address network does not match the requested network', details: { ...result.details, errorCode: ValidationError.NETWORK_MISMATCH } }; } diff --git a/tests/network-policy.test.ts b/tests/network-policy.test.ts index 6070f80..1b48594 100644 --- a/tests/network-policy.test.ts +++ b/tests/network-policy.test.ts @@ -35,6 +35,17 @@ describe('Network policy', () => { } }); + test.each(['foo', 'Mainnet', '', null, 1])('throws RangeError for invalid network option %j', network => { + const options = { network } as never; + expect(() => validateAddress(mainnet, 'bitcoin', options)).toThrow(RangeError); + expect(() => validateAddress(evm, 'ethereum', options)).toThrow('Invalid network option'); + expect(() => validateBatch([mainnet], 'bitcoin', options)).toThrow(RangeError); + }); + + test('an explicit undefined network behaves like auto', () => { + expect(validateAddress(testnet, 'bitcoin', { network: undefined }).valid).toBe(true); + }); + test('batch validation applies the same policy to every entry', () => { expect(validateBatch([mainnet, testnet, 42], 'bitcoin', { network: 'mainnet' }).map(result => result.details?.errorCode)) .toEqual([undefined, ValidationError.NETWORK_MISMATCH, ValidationError.UNSAFE_INPUT]); From 6584314a50c2edb8add5043668e32d89e6246199 Mon Sep 17 00:00:00 2001 From: Dhananjay Hire Date: Sat, 21 Nov 2026 10:14:07 +0000 Subject: [PATCH 3/6] fix: return format and checksum details for Ripple addresses Valid XRP results now include details { format: 'classic', checksum: true }, matching the other Base58Check chains. Document that X-addresses (XLS-5d) are not supported. Closes #7 --- README.md | 2 +- src/validators/ripple.ts | 2 +- tests/ripple.test.ts | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 56f723c..828788e 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ The full minified ESM bundle is approximately **7.2 kB gzip**, and the Solana-on | `dogecoin` | Base58Check P2PKH/P2SH; mainnet and testnet | | `solana` | Base58 decoding to exactly 32 bytes, including program addresses and PDAs | | `cardano` | Shelley base, enterprise, pointer, and stake addresses; header/network/length/padding checks; Byron CBOR envelope and CRC32 | -| `ripple` | XRP classic account addresses with the XRP Base58 alphabet and checksum | +| `ripple` | XRP classic account addresses with the XRP Base58 alphabet and checksum; X-addresses (XLS-5d) are not supported | | `tron` | 34-character Base58Check or 42-character hex beginning with `41` | | `cosmos`, `osmosis`, `sei` | Bech32 account prefixes `cosmos`, `osmo`, `sei`; 20- or 32-byte payloads | | `celestia`, `injective` | Bech32 account prefixes `celestia`, `inj`; 20-byte payloads | diff --git a/src/validators/ripple.ts b/src/validators/ripple.ts index 6cb9633..ecf4b91 100644 --- a/src/validators/ripple.ts +++ b/src/validators/ripple.ts @@ -33,7 +33,7 @@ export class RippleValidator extends AddressValidator { return { valid: false, error: 'Invalid checksum', details: { errorCode: ValidationError.INVALID_CHECKSUM } }; } - return { valid: true, blockchain: 'ripple' }; + return { valid: true, blockchain: 'ripple', details: { format: 'classic', checksum: true } }; } catch { return { valid: false, error: 'Invalid characters', details: { errorCode: ValidationError.INVALID_CHARACTERS } }; } diff --git a/tests/ripple.test.ts b/tests/ripple.test.ts index 9d429ba..ffde460 100644 --- a/tests/ripple.test.ts +++ b/tests/ripple.test.ts @@ -7,6 +7,16 @@ describe('Ripple Validator', () => { expect(validateAddress('rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn', 'ripple').valid).toBe(true); }); + it('reports the classic format and verified checksum like other Base58Check chains', () => { + expect(validateAddress('rPEPPER7kfTD9w2To4CQk6UCfuHM9c6GDY', 'ripple')).toEqual({ + valid: true, blockchain: 'ripple', details: { format: 'classic', checksum: true }, + }); + }); + + it('rejects X-addresses, which are not supported', () => { + expect(validateAddress('X7AcgcsBL6XDcUb289X4mJ8djcdyKaB5hJDWMArnXr61cqZ', 'ripple').valid).toBe(false); + }); + it('rejects invalid ripple address', () => { // Missing 'r' expect(validateAddress('G1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn', 'ripple').valid).toBe(false); From 398961d5e730ffa16f8a3f772840732cf7e070f4 Mon Sep 17 00:00:00 2001 From: Dhananjay Hire Date: Sat, 21 Nov 2026 10:14:51 +0000 Subject: [PATCH 4/6] perf: skip Keccak for uniform-case EVM input outside strict mode All-lowercase or all-uppercase hex carries no checksum, so hashing it only filled details.checksum. Outside strict mode such input is now accepted without hashing, and details.checksum is true only for a verified mixed-case checksum or an address with no hex letters. Strict mode still verifies uniform-case input against EIP-55. Closes #9 --- README.md | 2 +- src/validators/ethereum.ts | 12 ++++++------ tests/ethereum.test.ts | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 828788e..b1a4fc3 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ validateAddress(address, chain, { }); ``` -- `strict` defaults to `false`. On EVM, `true` requires the exact EIP-55 capitalization, including the rare valid all-lowercase/all-uppercase checksums. Invalid mixed-case EVM checksums are always rejected. On Aptos, strict mode requires lowercase AIP-40 canonical representation. Other formats always verify their mandatory checksums. +- `strict` defaults to `false`. On EVM, `true` requires the exact EIP-55 capitalization, including the rare valid all-lowercase/all-uppercase checksums. Invalid mixed-case EVM checksums are always rejected. Outside strict mode, uniform-case EVM input is accepted without hashing, and `details.checksum` is `true` only when a mixed-case checksum was verified (or the address has no hex letters). On Aptos, strict mode requires lowercase AIP-40 canonical representation. Other formats always verify their mandatory checksums. - `network` defaults to `auto`; any other value than `'mainnet'`, `'testnet'`, or `'auto'` throws a `RangeError`. It filters networks **only when encoded in the address**, currently Bitcoin, Litecoin, Dogecoin, and Cardano. `details.network` is omitted for formats that cannot identify mainnet/testnet. Selecting a network never proves an address belongs to it. - `allowTestnet: false` rejects identifiable testnet addresses, including when `network: 'testnet'` is also supplied. It is not an on-chain network check. - `allowBurnAddress` defaults to `false` and controls only the EVM all-zero address. It is not a comprehensive burn-address database. Other reserved/program addresses may be syntactically valid. diff --git a/src/validators/ethereum.ts b/src/validators/ethereum.ts index ea8c1c1..e2056a0 100644 --- a/src/validators/ethereum.ts +++ b/src/validators/ethereum.ts @@ -23,12 +23,12 @@ export class EthereumValidator extends AddressValidator { return { valid: false, error: 'Burn address detected', details: { errorCode: ValidationError.BURN_ADDRESS } }; } - const checksum = this.isChecksummed(cleanAddress); - // Mixed-case input always claims a checksum; strict mode also checks uniform case. - if (options?.strict || (cleanAddress !== cleanAddress.toLowerCase() && cleanAddress !== cleanAddress.toUpperCase())) { - if (!checksum) { - return { valid: false, error: 'Invalid checksum', details: { errorCode: ValidationError.INVALID_CHECKSUM } }; - } + // Uniform-case input carries no checksum, so outside strict mode skip the Keccak hash. + // Without hex letters the address equals its EIP-55 form, so the checksum trivially holds. + const mixedCase = cleanAddress !== cleanAddress.toLowerCase() && cleanAddress !== cleanAddress.toUpperCase(); + const checksum = options?.strict || mixedCase ? this.isChecksummed(cleanAddress) : !/[a-fA-F]/.test(cleanAddress); + if (!checksum && (options?.strict || mixedCase)) { + return { valid: false, error: 'Invalid checksum', details: { errorCode: ValidationError.INVALID_CHECKSUM } }; } return { diff --git a/tests/ethereum.test.ts b/tests/ethereum.test.ts index f13e512..c94bd33 100644 --- a/tests/ethereum.test.ts +++ b/tests/ethereum.test.ts @@ -103,3 +103,24 @@ describe('Ethereum Validator', () => { }); }); }); + +describe('EIP-55 checksum reporting', () => { + // 0x52908400098527886E0F7030069857D2E4169EE7 is an EIP-55 vector whose letters are all uppercase. + const upperVector = '0x52908400098527886E0F7030069857D2E4169EE7'; + const digitsOnly = '0x' + '1234567890'.repeat(4); + + test('strict mode still verifies uniform-case input against EIP-55', () => { + expect(validateAddress(upperVector, 'ethereum', { strict: true })).toMatchObject({ valid: true, details: { checksum: true } }); + expect(validateAddress(upperVector.toLowerCase(), 'ethereum', { strict: true }).valid).toBe(false); + }); + + test('non-strict uniform-case input is accepted without claiming a verified checksum', () => { + expect(validateAddress(upperVector, 'ethereum')).toMatchObject({ valid: true, details: { checksum: false } }); + expect(validateAddress(upperVector.toLowerCase(), 'ethereum')).toMatchObject({ valid: true, details: { checksum: false } }); + }); + + test('addresses without hex letters are trivially checksummed', () => { + expect(validateAddress(digitsOnly, 'ethereum')).toMatchObject({ valid: true, details: { checksum: true } }); + expect(validateAddress(digitsOnly, 'ethereum', { strict: true })).toMatchObject({ valid: true, details: { checksum: true } }); + }); +}); From 7f35b386f6d86c841c018b69832add5e2aac2c0e Mon Sep 17 00:00:00 2001 From: Dhananjay Hire Date: Sat, 21 Nov 2026 10:16:12 +0000 Subject: [PATCH 5/6] perf: gate detectBlockchain with cheap per-chain prechecks Each non-EVM chain now has a necessary condition (Bech32 prefix, Base58 alphabet, 0x prefix, ...) checked before its validator runs, so detection no longer runs every Bech32 polymod and Base58 decode on every input. Results and their order are unchanged; a new test compares detection against exhaustive validation over ~1,000 seeded and mutated inputs. The benchmark now covers lowercase EVM, Bech32, Cosmos and detection of several formats. Benchmark (ops/s): bitcoin detection 17k -> 224k, invalid input 42k -> 1.3M, EVM detection 15k -> 48k, solana detection 30k -> 48k. Closes #8 --- scripts/benchmark.mjs | 34 ++++++++++++++------- src/detectors/chain-detector.ts | 37 ++++++++++++++++++----- tests/detector.test.ts | 52 ++++++++++++++++++++++++++++++++- 3 files changed, 104 insertions(+), 19 deletions(-) diff --git a/scripts/benchmark.mjs b/scripts/benchmark.mjs index fd47d8a..1f892b0 100644 --- a/scripts/benchmark.mjs +++ b/scripts/benchmark.mjs @@ -1,20 +1,32 @@ import { performance } from 'node:perf_hooks'; import { validateAddress, detectBlockchain } from '../dist/index.mjs'; -const iterations = 10000; -for (const [chain, address] of [ +function measure(label, iterations, fn) { + for (let warmup = 0; warmup < 500; warmup++) fn(); + const start = performance.now(); + for (let i = 0; i < iterations; i++) fn(); + const elapsed = performance.now() - start; + console.log(`${label}: ${(iterations / elapsed * 1000).toFixed(0)} ops/s (${elapsed.toFixed(1)}ms for ${iterations})`); +} + +const validations = [ ['ethereum', '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'], + ['ethereum (lowercase)', '0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 'ethereum'], ['bitcoin', '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'], + ['bitcoin (bech32)', 'bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq', 'bitcoin'], ['solana', 'HN7cABqLq46Es1jh92dQQy4aWDtG751BHhP1K2HWT7k1'], ['tron', 'TNPeeaaFB7K9cmo4uQpcU32zGK8G1NYqeL'], + ['cosmos', 'cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh'], +]; +for (const [label, address, chain = label] of validations) { + if (!validateAddress(address, chain).valid) throw new Error(`Invalid benchmark fixture: ${label}`); + measure(label, 10000, () => validateAddress(address, chain)); +} +for (const [label, address] of [ + ['EVM detection', '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'], + ['bitcoin detection', 'bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq'], + ['solana detection', 'HN7cABqLq46Es1jh92dQQy4aWDtG751BHhP1K2HWT7k1'], + ['invalid detection', 'not-a-wallet-address'], ]) { - if (!validateAddress(address, chain).valid) throw new Error(`Invalid benchmark fixture: ${chain}`); - for (let warmup = 0; warmup < 500; warmup++) validateAddress(address, chain); - const start = performance.now(); - for (let i = 0; i < iterations; i++) validateAddress(address, chain); - const elapsed = performance.now() - start; - console.log(`${chain}: ${(iterations / elapsed * 1000).toFixed(0)} validations/s (${elapsed.toFixed(1)}ms for ${iterations})`); + measure(label, 2000, () => detectBlockchain(address)); } -const start = performance.now(); -for (let i = 0; i < 1000; i++) detectBlockchain('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'); -console.log(`EVM detection: ${(1000000 / (performance.now() - start)).toFixed(0)} detections/s`); diff --git a/src/detectors/chain-detector.ts b/src/detectors/chain-detector.ts index 6693c0a..7632b9c 100644 --- a/src/detectors/chain-detector.ts +++ b/src/detectors/chain-detector.ts @@ -1,7 +1,32 @@ -import { BlockchainType, ValidationOptions, EVM_CHAINS } from '../types'; -import { SUPPORTED_CHAINS, getValidator } from '../registry'; +import { BlockchainType, ValidationOptions, EVM_CHAINS, COSMOS_CHAINS } from '../types'; +import { getValidator } from '../registry'; import { InputSanitizer } from '../security/sanitizer'; +const BASE58 = /^[1-9A-HJ-NP-Za-km-z]+$/; +const COSMOS_PREFIXES: Readonly> = { cosmos: 'cosmos1', osmosis: 'osmo1', celestia: 'celestia1', injective: 'inj1', sei: 'sei1' }; + +interface Features { lower: string; base58: boolean; hex0x: boolean } + +/** + * Cheap necessary conditions for each non-EVM chain, so detection skips decoders and + * checksums that cannot succeed. Every gate must be implied by the validator accepting + * the input; `tests/detector.test.ts` checks equivalence with exhaustive validation. + */ +const CANDIDATES: ReadonlyArray boolean]> = [ + ...COSMOS_CHAINS.map(chain => [chain, (_: string, f: Features) => f.lower.startsWith(COSMOS_PREFIXES[chain])] as const), + ['bitcoin', (_, f) => f.base58 || f.lower.startsWith('bc1') || f.lower.startsWith('tb1')], + ['litecoin', (_, f) => f.base58 || f.lower.startsWith('ltc1') || f.lower.startsWith('tltc1')], + ['dogecoin', (_, f) => f.base58], + ['solana', (_, f) => f.base58], + ['ripple', (input, f) => f.base58 && input.startsWith('r')], + ['cardano', (_, f) => f.base58 || /^(addr|stake)(_test)?1/.test(f.lower)], + ['tron', (input, f) => f.base58 || input.startsWith('41')], + ['sui', (_, f) => f.hex0x], + ['aptos', (_, f) => f.hex0x], + // Plain NEAR names are too broad for useful auto-detection. Explicit validation still accepts them. + ['near', input => /(\.near|\.testnet)$/.test(input) || /^[0-9a-f]{64}$/.test(input) || /^0[xs][0-9a-f]{40}$/.test(input) || /^0u[0-9a-hjkmnp-tv-z]{51}[0g]$/.test(input)], +]; + /** Format candidates only: never use detection as proof of a destination's chain. */ export function detectBlockchain(address: unknown, options?: ValidationOptions): BlockchainType | BlockchainType[] | null { let safe: string; @@ -10,11 +35,9 @@ export function detectBlockchain(address: unknown, options?: ValidationOptions): const matches: BlockchainType[] = []; // All EVM chains share one check. Avoid repeating Keccak for each alias. if (getValidator('ethereum').validate(safe, options).valid) matches.push(...EVM_CHAINS); - for (const chain of SUPPORTED_CHAINS) { - if ((EVM_CHAINS as readonly string[]).includes(chain)) continue; - // Plain NEAR names are too broad for useful auto-detection. Explicit validation still accepts them. - if (chain === 'near' && !/(\.near|\.testnet)$/.test(safe) && !/^[0-9a-f]{64}$/.test(safe) && !/^0[xs][0-9a-f]{40}$/.test(safe) && !/^0u[0-9a-hjkmnp-tv-z]{51}[0g]$/.test(safe)) continue; - if (getValidator(chain).validate(safe, options).valid) matches.push(chain); + const features: Features = { lower: safe.toLowerCase(), base58: BASE58.test(safe), hex0x: safe.startsWith('0x') }; + for (const [chain, gate] of CANDIDATES) { + if (gate(safe, features) && getValidator(chain).validate(safe, options).valid) matches.push(chain); } return matches.length === 0 ? null : matches.length === 1 ? matches[0] : matches; } diff --git a/tests/detector.test.ts b/tests/detector.test.ts index 0f5dfdc..acae942 100644 --- a/tests/detector.test.ts +++ b/tests/detector.test.ts @@ -1,4 +1,6 @@ -import { validateAddress, detectBlockchain, EVM_CHAINS } from '../src'; +import { bech32 } from '@scure/base'; +import { validateAddress, detectBlockchain, EVM_CHAINS, SUPPORTED_CHAINS, ValidationOptions } from '../src'; +import vectors from './fixtures/protocol-vectors.json'; describe('Polygon Validator', () => { test('should validate Polygon address', () => { @@ -45,3 +47,51 @@ describe('Chain Detector', () => { expect(detectBlockchain('invalid-address-string')).toBe(null); }); }); + +describe('Detection prechecks', () => { + // Reference: validate every chain with no shortcuts, in registry order. + const nearShape = (s: string) => /(\.near|\.testnet)$/.test(s) || /^[0-9a-f]{64}$/.test(s) || /^0[xs][0-9a-f]{40}$/.test(s) || /^0u[0-9a-hjkmnp-tv-z]{51}[0g]$/.test(s); + function exhaustive(input: string, options?: ValidationOptions) { + const safe = input.trim(); + if (!safe) return null; + const matches = SUPPORTED_CHAINS.filter(chain => { + if (chain === 'near' && !nearShape(safe)) return false; + return validateAddress(input, chain, options).valid; + }); + return matches.length === 0 ? null : matches.length === 1 ? matches[0] : matches; + } + + const seeds = [ + ...vectors.bitcoinValid, ...vectors.bitcoinInvalid, ...vectors.cardano, + '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', '0xd8da6bf26964af9d7eed9e03e53415d37aa96045', + '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa', '3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy', 'bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq', + 'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx', 'ltc1qg82tj3j9n0cc3d8rzc5ql9w2ma6s0sz0j6l6pm', 'LM2WMpR1Rp6j3Sa59cMXMs1SPzj9eXpGc1', + 'DH5yaieqoZN36fDVciNyRueRGvGLR3mr7L', 'HN7cABqLq46Es1jh92dQQy4aWDtG751BHhP1K2HWT7k1', '11111111111111111111111111111111', + 'rPEPPER7kfTD9w2To4CQk6UCfuHM9c6GDY', 'TNPeeaaFB7K9cmo4uQpcU32zGK8G1NYqeL', '418840E6C55B9ADA326D211D818C34A994AECED808', + 'cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh', 'stake1uyehkck0lajq8gr28t9uxnuvgcqrc6070x3k9r8048z8y5gh6ffgw', + '0x' + 'ab'.repeat(32), '0xa', 'alice.near', 'a'.repeat(64), '0s' + 'b'.repeat(40), 'root', ' 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 ', + ...['cosmos', 'osmo', 'celestia', 'inj', 'sei'].map(hrp => bech32.encode(hrp, bech32.toWords(Uint8Array.from({ length: 20 }, (_, i) => i)))), + ]; + // Single-character edits, case flips and prefix swaps around every seed. + const alphabet = '0123456789abcdefABCDEFxrTlLO_1q'; + const corpus = new Set(seeds); + for (const seed of seeds) { + corpus.add(seed.toUpperCase()); + corpus.add(seed.toLowerCase()); + corpus.add(seed.slice(1)); + corpus.add(seed.slice(0, -1)); + for (let i = 0; i < seed.length; i += 3) corpus.add(seed.slice(0, i) + alphabet[(i * 7) % alphabet.length] + seed.slice(i + 1)); + } + + test(`matches exhaustive validation across ${corpus.size} inputs`, () => { + for (const input of corpus) expect([input, detectBlockchain(input)]).toEqual([input, exhaustive(input)]); + for (const network of ['mainnet', 'testnet'] as const) { + for (const input of seeds) expect([input, detectBlockchain(input, { network })]).toEqual([input, exhaustive(input, { network })]); + } + }); + + test('the Ripple alphabet uses the same characters as Bitcoin Base58', () => { + const sort = (s: string) => [...s].sort().join(''); + expect(sort('rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz')).toBe(sort('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz')); + }); +}); From aeb8e3e21756ce6e642f65f3dfd4d3059574d13c Mon Sep 17 00:00:00 2001 From: Dhananjay Hire Date: Sat, 21 Nov 2026 10:18:01 +0000 Subject: [PATCH 6/6] perf: single-pass Bech32 checksum, leaner SHA-256, Byron precheck - Bech32: compute the polymod once while decoding (no hrpExpand/concat arrays, lookup table instead of indexOf) and classify Bech32 vs Bech32m from the residue instead of hashing twice. - SHA-256: one buffer for message and padding, state in locals, rotations inlined. - Byron: return early unless the first byte is a CBOR array, so non-Byron Base58 input no longer throws and catches inside the CBOR reader. Benchmark (ops/s): bitcoin legacy 100k -> 250k, tron 90k -> 245k, bech32 190k -> 460k, cosmos 230k -> 520k, solana detection 50k -> 98k. Add an Unreleased changelog entry for #6-#9 and these changes. --- CHANGELOG.md | 14 ++++++ src/utils/bech32.ts | 67 ++++++++++--------------- src/utils/byron.ts | 3 ++ src/utils/sha256.ts | 111 +++++++++++++----------------------------- tests/cardano.test.ts | 14 ++++++ 5 files changed, 90 insertions(+), 119 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b754b47..12b0556 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## Unreleased + +### Changed + +- An invalid `network` option (anything other than `'mainnet'`, `'testnet'`, or `'auto'`) throws a `RangeError` instead of reporting `NETWORK_MISMATCH`. +- Valid Ripple results include `details: { format: 'classic', checksum: true }`. +- Outside strict mode, uniform-case EVM addresses are accepted without hashing. `details.checksum` is `true` only for a verified mixed-case checksum or an address without hex letters. + +### Performance + +- Keccak-256 no longer uses BigInt; SHA-256 and Bech32 avoid per-call allocations, and Bech32 verifies both checksum variants in one pass. +- `detectBlockchain` skips validators whose cheap preconditions fail; results and their order are unchanged. +- Throughput versus 0.4.0 (`npm run benchmark`, Node 24): checksummed EVM about 11x, lowercase EVM over 200x, Bitcoin legacy and TRON about 2.3x, Bech32/Cosmos/Solana about 1.5-1.7x, `detectBlockchain` 2.4-10x. + ## 0.4.0 - JavaScript EVM and Cosmos constructors reject unsupported family identifiers. diff --git a/src/utils/bech32.ts b/src/utils/bech32.ts index 3ab3a6e..47f494b 100644 --- a/src/utils/bech32.ts +++ b/src/utils/bech32.ts @@ -6,38 +6,18 @@ export enum Bech32Encoding { } const GENERATOR = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3]; +const BECH32_CONST = 1; +const BECH32M_CONST = 0x2bc830a3; +const CHARSET_REV = new Int8Array(128).fill(-1); +for (let i = 0; i < BECH32_ALPHABET.length; i++) CHARSET_REV[BECH32_ALPHABET.charCodeAt(i)] = i; -function polymod(values: number[]): number { - let chk = 1; - for (const v of values) { - const top = chk >> 25; - chk = ((chk & 0x1ffffff) << 5) ^ v; - for (let i = 0; i < 5; i++) { - if ((top >> i) & 1) { - chk ^= GENERATOR[i]; - } - } - } +function polymodStep(chk: number, value: number): number { + const top = chk >>> 25; + chk = ((chk & 0x1ffffff) << 5) ^ value; + for (let i = 0; i < 5; i++) if ((top >>> i) & 1) chk ^= GENERATOR[i]; return chk; } -function hrpExpand(hrp: string): number[] { - const ret: number[] = []; - for (let i = 0; i < hrp.length; i++) { - ret.push(hrp.charCodeAt(i) >> 5); - } - ret.push(0); - for (let i = 0; i < hrp.length; i++) { - ret.push(hrp.charCodeAt(i) & 31); - } - return ret; -} - -function verifyChecksum(hrp: string, data: number[], encoding: Bech32Encoding): boolean { - const constValue = encoding === Bech32Encoding.BECH32M ? 0x2bc830a3 : 1; - return polymod(hrpExpand(hrp).concat(data)) === constValue; -} - export interface Decoded { hrp: string; data: number[]; @@ -54,27 +34,30 @@ export function decodeBech32(str: string, limit = 90): Decoded | null { const pos = lower.lastIndexOf('1'); if (pos < 1 || pos + 7 > lower.length) return null; - const hrp = lower.substring(0, pos); - if (/[^\x21-\x7E]/.test(hrp)) return null; + // Checksum over the expanded HRP (high bits, separator, low bits), then the data words. + let chk = 1; + for (let i = 0; i < pos; i++) { + const code = lower.charCodeAt(i); + if (code < 0x21 || code > 0x7e) return null; + chk = polymodStep(chk, code >>> 5); + } + chk = polymodStep(chk, 0); + for (let i = 0; i < pos; i++) chk = polymodStep(chk, lower.charCodeAt(i) & 31); const data: number[] = []; for (let i = pos + 1; i < lower.length; i++) { - const d = BECH32_ALPHABET.indexOf(lower[i]); + const code = lower.charCodeAt(i); + const d = code < 128 ? CHARSET_REV[code] : -1; if (d === -1) return null; + chk = polymodStep(chk, d); data.push(d); } - // Try Bech32 - if (verifyChecksum(hrp, data, Bech32Encoding.BECH32)) { - return { hrp, data: data.slice(0, data.length - 6), encoding: Bech32Encoding.BECH32 }; - } - - // Try Bech32m - if (verifyChecksum(hrp, data, Bech32Encoding.BECH32M)) { - return { hrp, data: data.slice(0, data.length - 6), encoding: Bech32Encoding.BECH32M }; - } - - return null; + // One pass decides both variants: the residue is 1 for Bech32 and 0x2bc830a3 for Bech32m. + const encoding = chk === BECH32_CONST ? Bech32Encoding.BECH32 : chk === BECH32M_CONST ? Bech32Encoding.BECH32M : null; + if (!encoding) return null; + data.length -= 6; + return { hrp: lower.substring(0, pos), data, encoding }; } /** Convert Bech32 words to bytes, rejecting excess or nonzero padding (BIP-173). */ diff --git a/src/utils/byron.ts b/src/utils/byron.ts index 1029e45..0429abd 100644 --- a/src/utils/byron.ts +++ b/src/utils/byron.ts @@ -37,6 +37,9 @@ function crc32(data: Uint8Array): number { } export function byronNetwork(data: Uint8Array): 'mainnet' | 'testnet' | null { + // The envelope is a CBOR array (major type 4). Reject other input before the reader throws: + // most Base58 strings reach here during detection, and exceptions are expensive. + if (data.length === 0 || data[0] >>> 5 !== 4) return null; try { const envelope = new Reader(data); if (envelope.head(4) !== 2 || envelope.head(6) !== 24) return null; diff --git a/src/utils/sha256.ts b/src/utils/sha256.ts index 8bcf60a..9d1bf96 100644 --- a/src/utils/sha256.ts +++ b/src/utils/sha256.ts @@ -8,91 +8,48 @@ const K = new Uint32Array([ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 ]); -const W = new Uint32Array(64); +const W = new Int32Array(64); +/** SHA-256 over bytes. Inputs here are short (Base58Check payloads), so one buffer holds message and padding. */ export function sha256(input: Uint8Array): Uint8Array { - const H = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19]; - - const len = input.length * 8; - const lenByte = input.length; - - // Padding - const padding = new Uint8Array(64 - ((lenByte + 8) % 64) + 8); - padding[0] = 0x80; - - // Length in bits (Big Endian 64 bit) - // Javascript numbers are doubles limited to 53 bits integer precision. - // For small inputs it's fine. - const l = len; - const high = Math.floor(l / 4294967296); - const low = l % 4294967296; - - const pLen = padding.length; - padding[pLen - 4] = (low >>> 24) & 0xff; - padding[pLen - 3] = (low >>> 16) & 0xff; - padding[pLen - 2] = (low >>> 8) & 0xff; - padding[pLen - 1] = low & 0xff; - - padding[pLen - 8] = (high >>> 24) & 0xff; - padding[pLen - 7] = (high >>> 16) & 0xff; - padding[pLen - 6] = (high >>> 8) & 0xff; - padding[pLen - 5] = high & 0xff; - - const msg = new Uint8Array(lenByte + padding.length); + const length = input.length; + const msg = new Uint8Array(((length + 72) >>> 6) << 6); msg.set(input); - msg.set(padding, lenByte); - - for (let i = 0; i < msg.length; i += 64) { - // Prepare message schedule - for (let t = 0; t < 16; t++) { - W[t] = (msg[i + t * 4] << 24) | (msg[i + t * 4 + 1] << 16) | (msg[i + t * 4 + 2] << 8) | (msg[i + t * 4 + 3]); - } + msg[length] = 0x80; + // Big-endian 64-bit bit length; the high word only matters beyond 512 MiB. + const bits = length * 8; + const end = msg.length; + const high = Math.floor(bits / 4294967296); + msg[end - 8] = high >>> 24; msg[end - 7] = high >>> 16; msg[end - 6] = high >>> 8; msg[end - 5] = high; + msg[end - 4] = bits >>> 24; msg[end - 3] = bits >>> 16; msg[end - 2] = bits >>> 8; msg[end - 1] = bits; + + let h0 = 0x6a09e667, h1 = 0xbb67ae85 | 0, h2 = 0x3c6ef372, h3 = 0xa54ff53a | 0; + let h4 = 0x510e527f, h5 = 0x9b05688c | 0, h6 = 0x1f83d9ab, h7 = 0x5be0cd19; + for (let offset = 0; offset < end; offset += 64) { + for (let t = 0, i = offset; t < 16; t++, i += 4) W[t] = (msg[i] << 24) | (msg[i + 1] << 16) | (msg[i + 2] << 8) | msg[i + 3]; for (let t = 16; t < 64; t++) { - const s1 = rro(W[t - 2], 17) ^ rro(W[t - 2], 19) ^ (W[t - 2] >>> 10); - const s0 = rro(W[t - 15], 7) ^ rro(W[t - 15], 18) ^ (W[t - 15] >>> 3); - W[t] = (s1 + W[t - 7] + s0 + W[t - 16]) | 0; + const a = W[t - 15], b = W[t - 2]; + const s0 = ((a >>> 7) | (a << 25)) ^ ((a >>> 18) | (a << 14)) ^ (a >>> 3); + const s1 = ((b >>> 17) | (b << 15)) ^ ((b >>> 19) | (b << 13)) ^ (b >>> 10); + W[t] = (W[t - 16] + s0 + W[t - 7] + s1) | 0; } - - let a = H[0], b = H[1], c = H[2], d = H[3], e = H[4], f = H[5], g = H[6], h = H[7]; - + let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7; for (let t = 0; t < 64; t++) { - const S1 = rro(e, 6) ^ rro(e, 11) ^ rro(e, 25); - const ch = (e & f) ^ ((~e) & g); - const temp1 = (h + S1 + ch + K[t] + W[t]) | 0; - const S0 = rro(a, 2) ^ rro(a, 13) ^ rro(a, 22); - const maj = (a & b) ^ (a & c) ^ (b & c); - const temp2 = (S0 + maj) | 0; - - h = g; - g = f; - f = e; - e = (d + temp1) | 0; - d = c; - c = b; - b = a; - a = (temp1 + temp2) | 0; + const S1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7)); + const t1 = (h + S1 + ((e & f) ^ (~e & g)) + K[t] + W[t]) | 0; + const S0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10)); + const t2 = (S0 + ((a & b) ^ (a & c) ^ (b & c))) | 0; + h = g; g = f; f = e; e = (d + t1) | 0; + d = c; c = b; b = a; a = (t1 + t2) | 0; } - - H[0] = (H[0] + a) | 0; - H[1] = (H[1] + b) | 0; - H[2] = (H[2] + c) | 0; - H[3] = (H[3] + d) | 0; - H[4] = (H[4] + e) | 0; - H[5] = (H[5] + f) | 0; - H[6] = (H[6] + g) | 0; - H[7] = (H[7] + h) | 0; + h0 = (h0 + a) | 0; h1 = (h1 + b) | 0; h2 = (h2 + c) | 0; h3 = (h3 + d) | 0; + h4 = (h4 + e) | 0; h5 = (h5 + f) | 0; h6 = (h6 + g) | 0; h7 = (h7 + h) | 0; } - - const res = new Uint8Array(32); + const out = new Uint8Array(32); + const words = [h0, h1, h2, h3, h4, h5, h6, h7]; for (let i = 0; i < 8; i++) { - res[i * 4] = (H[i] >>> 24) & 0xff; - res[i * 4 + 1] = (H[i] >>> 16) & 0xff; - res[i * 4 + 2] = (H[i] >>> 8) & 0xff; - res[i * 4 + 3] = H[i] & 0xff; + const w = words[i]; + out[i * 4] = w >>> 24; out[i * 4 + 1] = w >>> 16; out[i * 4 + 2] = w >>> 8; out[i * 4 + 3] = w; } - return res; -} - -function rro(val: number, bits: number) { - return (val >>> bits) | (val << (32 - bits)); + return out; } diff --git a/tests/cardano.test.ts b/tests/cardano.test.ts index d700a21..800abe9 100644 --- a/tests/cardano.test.ts +++ b/tests/cardano.test.ts @@ -1,6 +1,7 @@ import { bech32, bech32m } from '@scure/base'; import { validateAddress, CardanoValidator } from '../src'; import { decodeBech32 } from '../src/utils/bech32'; +import { byronNetwork } from '../src/utils/byron'; import vectors from './fixtures/protocol-vectors.json'; // Published Byron example from CIP-19 (testnet). @@ -73,3 +74,16 @@ describe('Cardano Shelley', () => { expect(validateAddress(address, 'cardano').valid).toBe(false); }); }); + +describe('Byron envelope precheck', () => { + test('rejects empty and non-array CBOR without parsing', () => { + for (const data of [new Uint8Array(0), Uint8Array.of(0x00), Uint8Array.of(0x58, 0x1c), Uint8Array.of(0xa1, 0x00)]) { + expect(byronNetwork(data)).toBeNull(); + } + }); + + test('still parses arrays, including non-minimal array headers, before rejecting them', () => { + expect(byronNetwork(Uint8Array.of(0x98, 0x02, 0xd8, 0x18))).toBeNull(); + expect(byronNetwork(Uint8Array.of(0x82))).toBeNull(); + }); +});