commit 6a860cecfec9e03bc8f5ad71eed9622859962dbe Author: Kurdistan Tech Ministry Date: Sun Jan 11 23:22:39 2026 +0300 Initial commit: Fork @polkadot/vanitygen to @pezkuwi/vanitygen - Replace all @polkadot/* dependencies with @pezkuwi/* - Update package.json metadata for Pezkuwichain - Update CLI command from polkadot-js-vanitygen to pezkuwi-vanitygen - Update network options: bizinikiwi, pezkuwi, dicle, zagros - Set default network to pezkuwi (ss58Format: 42) - Update documentation and README - Build and test successful - Version 1.0.0 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8b4d0a9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,31 @@ +# Dependencies +node_modules/ + +# Build output +dist/ +build/ +*.js +*.js.map +*.d.ts +!runcli.mjs + +# Logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Editor +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS +.DS_Store +Thumbs.db + +# Misc +.env +.env.local diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f251564 --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# @pezkuwi/vanitygen + +A CLI vanity address generator for Pezkuwichain + +> Forked from [@polkadot/vanitygen](https://github.com/polkadot-js/tools) and adapted for Pezkuwichain + +## Installation + +```bash +npm install -g @pezkuwi/vanitygen +``` + +or + +```bash +yarn global add @pezkuwi/vanitygen +``` + +## Usage + +```bash +pezkuwi-vanitygen --match cook13 --mnemonic --network pezkuwi --type sr25519 +``` + +### Options + +- `--match ` - The pattern to match at the start of the address +- `--mnemonic` - Generate using a mnemonic (slower but recoverable) +- `--network ` - Network prefix: bizinikiwi, pezkuwi, dicle, zagros (default: pezkuwi) +- `--type ` - Key type: sr25519 (default) or ed25519 + +### Examples + +Generate an address starting with "Pez": +```bash +pezkuwi-vanitygen --match Pez +``` + +Generate with mnemonic (recoverable): +```bash +pezkuwi-vanitygen --match cook --mnemonic +``` + +Generate ed25519 key: +```bash +pezkuwi-vanitygen --match test --type ed25519 +``` + +## Notes + +When using the `--mnemonic` option, the generation will be very slow since it needs to generate mnemonics and then test the resulting outputs. + +As with all other CLI utilities, `--help` will return a list of the available options. + +## License + +Apache-2.0 diff --git a/calculate.d.ts.map b/calculate.d.ts.map new file mode 100644 index 0000000..af4102a --- /dev/null +++ b/calculate.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"calculate.d.ts","sourceRoot":"","sources":["src/calculate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAoCzE,MAAM,CAAC,OAAO,UAAU,SAAS,CAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,QAAa,EAAE,QAAgB,EAAE,EAAE,gBAAgB,GAAG,oBAAoB,CAyBlJ"} \ No newline at end of file diff --git a/generate.d.ts.map b/generate.d.ts.map new file mode 100644 index 0000000..0a39274 --- /dev/null +++ b/generate.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["src/generate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAMnE,MAAM,CAAC,OAAO,UAAU,SAAS,CAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,gBAAgB,GAAG,cAAc,CAoB9F"} \ No newline at end of file diff --git a/generator.d.ts.map b/generator.d.ts.map new file mode 100644 index 0000000..c1fb4c9 --- /dev/null +++ b/generator.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["src/generator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAoB,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAItF,MAAM,CAAC,OAAO,UAAU,SAAS,CAAE,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAgB7E"} \ No newline at end of file diff --git a/index.d.ts.map b/index.d.ts.map new file mode 100644 index 0000000..7328f5f --- /dev/null +++ b/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAGA,OAAO,gBAAgB,CAAC"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..f04b991 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,573 @@ +{ + "name": "@pezkuwi/vanitygen", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@pezkuwi/vanitygen", + "version": "1.0.0", + "license": "Apache-2.0", + "dependencies": { + "@pezkuwi/util": "^14.0.11", + "@pezkuwi/util-crypto": "^14.0.11", + "tslib": "^2.8.1", + "yargs": "^17.7.2" + }, + "bin": { + "pezkuwi-vanitygen": "runcli.mjs" + }, + "devDependencies": { + "@types/node": "^22.10.5", + "@types/yargs": "^17.0.33", + "typescript": "^5.9.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@noble/curves": { + "version": "1.9.7", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.7.tgz", + "integrity": "sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.8.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@pezkuwi/networks": { + "version": "14.0.11", + "resolved": "https://registry.npmjs.org/@pezkuwi/networks/-/networks-14.0.11.tgz", + "integrity": "sha512-vdWfYe1fyRDbqhFDYwn/kVu6bp18Gx0dxYaF2DDhgIH5KWew5Hcib7hmydgIsT+t7LOi5NPKGUF59/1eorV9Pg==", + "license": "Apache-2.0", + "dependencies": { + "@pezkuwi/util": "14.0.11", + "@substrate/ss58-registry": "^1.51.0", + "tslib": "^2.8.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@pezkuwi/util": { + "version": "14.0.11", + "resolved": "https://registry.npmjs.org/@pezkuwi/util/-/util-14.0.11.tgz", + "integrity": "sha512-I/BLTMNzaAMIAIbNBpo2txeo2OZWmPL0jUNyYyY3cH9J+2qLqYs+gDr5mBFO2XVTV+tS7sDlVFdIy9yyfLqCgg==", + "license": "Apache-2.0", + "dependencies": { + "@pezkuwi/x-bigint": "14.0.11", + "@pezkuwi/x-global": "14.0.11", + "@pezkuwi/x-textdecoder": "14.0.11", + "@pezkuwi/x-textencoder": "14.0.11", + "@types/bn.js": "^5.1.6", + "bn.js": "^5.2.1", + "tslib": "^2.8.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@pezkuwi/util-crypto": { + "version": "14.0.11", + "resolved": "https://registry.npmjs.org/@pezkuwi/util-crypto/-/util-crypto-14.0.11.tgz", + "integrity": "sha512-uqq1SixUmSttnS8cDXwk5iWgmGozqAcR7VMoU1CsNguhy7wm6+J6kml1pracLhSDQ9Pze30FZqbNPG48ZbWkYA==", + "license": "Apache-2.0", + "dependencies": { + "@noble/curves": "^1.3.0", + "@noble/hashes": "^1.3.3", + "@pezkuwi/networks": "14.0.11", + "@pezkuwi/util": "14.0.11", + "@pezkuwi/wasm-crypto": "^7.5.4", + "@pezkuwi/wasm-util": "^7.5.4", + "@pezkuwi/x-bigint": "14.0.11", + "@pezkuwi/x-randomvalues": "14.0.11", + "@scure/base": "^1.1.7", + "@scure/sr25519": "^0.2.0", + "tslib": "^2.8.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@pezkuwi/util": "14.0.11" + } + }, + "node_modules/@pezkuwi/wasm-bridge": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/@pezkuwi/wasm-bridge/-/wasm-bridge-7.5.4.tgz", + "integrity": "sha512-UK2SzudaitB3ohXyJQj6K289KReqmiXPXf1Ml4fc87NMSv665d+WYtIW500SR4IlLKp0yfIbvW1VewBz2KIhIw==", + "license": "Apache-2.0", + "dependencies": { + "@pezkuwi/wasm-util": "7.5.3", + "tslib": "^2.7.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@pezkuwi/util": "*", + "@pezkuwi/x-randomvalues": "*" + } + }, + "node_modules/@pezkuwi/wasm-bridge/node_modules/@pezkuwi/wasm-util": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@pezkuwi/wasm-util/-/wasm-util-7.5.3.tgz", + "integrity": "sha512-q0nWKtW8eESANGSb9E9K/Omgh++/a/DAUxtx4CGHAKtDu6hURGYxh3SuEEghueeOuY4MX+Fu5gc0R6V/Z0po+g==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.7.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@pezkuwi/util": "*" + } + }, + "node_modules/@pezkuwi/wasm-crypto": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/@pezkuwi/wasm-crypto/-/wasm-crypto-7.5.4.tgz", + "integrity": "sha512-6VDQ1MJnaqt73ezxuf6NOqYJfsrCJ4qPjZoOFmTjNZt9qKNxDpsw0+3mWsszJvKg0hVsy2vAGoFoVIKf+4pHvg==", + "license": "Apache-2.0", + "dependencies": { + "@pezkuwi/wasm-bridge": "7.5.4", + "@pezkuwi/wasm-crypto-asmjs": "7.5.4", + "@pezkuwi/wasm-crypto-init": "7.5.4", + "@pezkuwi/wasm-crypto-wasm": "7.5.4", + "@pezkuwi/wasm-util": "7.5.4", + "tslib": "^2.7.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@pezkuwi/util": "*", + "@pezkuwi/x-randomvalues": "*" + } + }, + "node_modules/@pezkuwi/wasm-crypto-asmjs": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/@pezkuwi/wasm-crypto-asmjs/-/wasm-crypto-asmjs-7.5.4.tgz", + "integrity": "sha512-zYBTwm9WbDeUuMzn56HHeA13WfWwDEEe0ojH3i0yiuis1Mo6Ie0J3ii7X7gai17Hbnv9ydfgaePvUHUDjt5PQQ==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.7.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@pezkuwi/util": "*" + } + }, + "node_modules/@pezkuwi/wasm-crypto-init": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/@pezkuwi/wasm-crypto-init/-/wasm-crypto-init-7.5.4.tgz", + "integrity": "sha512-Ie4kQtcj/8J9XaMcnjW0rn9yCCFOHAMwckyfOhddwErxW9p7IzZeEEAxhiI34LaR3OV3/yO3gm8W90WN+k6FCQ==", + "license": "Apache-2.0", + "dependencies": { + "@pezkuwi/wasm-bridge": "7.5.4", + "@pezkuwi/wasm-crypto-asmjs": "7.5.4", + "@pezkuwi/wasm-crypto-wasm": "7.5.4", + "@pezkuwi/wasm-util": "7.5.4", + "tslib": "^2.7.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@pezkuwi/util": "*", + "@pezkuwi/x-randomvalues": "*" + } + }, + "node_modules/@pezkuwi/wasm-crypto-wasm": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/@pezkuwi/wasm-crypto-wasm/-/wasm-crypto-wasm-7.5.4.tgz", + "integrity": "sha512-f2Et7jfZ5shYsmDHTuvDjcl+rg3dVGZqXlhx2KnpyGH5jebA8ULaUGxtmO9vUUJjs/rMkJkCNYrZ0YneYtLe4A==", + "license": "Apache-2.0", + "dependencies": { + "@pezkuwi/wasm-util": "7.5.4", + "tslib": "^2.7.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@pezkuwi/util": "*" + } + }, + "node_modules/@pezkuwi/wasm-util": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/@pezkuwi/wasm-util/-/wasm-util-7.5.4.tgz", + "integrity": "sha512-DyWWG8Sn7txg2VltSBqF/0zQCYQ0MNNSkrfHKTOOz6esC1abCDq5LKh8rPqy1IQoeD+lUFubIDmNW3G9pH9lfg==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.7.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@pezkuwi/util": "*" + } + }, + "node_modules/@pezkuwi/x-bigint": { + "version": "14.0.11", + "resolved": "https://registry.npmjs.org/@pezkuwi/x-bigint/-/x-bigint-14.0.11.tgz", + "integrity": "sha512-pDB2pSbUCni0XwXCgz2rAZ9LNuGA+aV2v3l+duYDc4NmEhtUapVJ6mEz9+cXCCoVdDz1BDJ3zjBgcwMjmhbcHA==", + "license": "Apache-2.0", + "dependencies": { + "@pezkuwi/x-global": "14.0.11", + "tslib": "^2.8.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@pezkuwi/x-global": { + "version": "14.0.11", + "resolved": "https://registry.npmjs.org/@pezkuwi/x-global/-/x-global-14.0.11.tgz", + "integrity": "sha512-vSg8j/aUZG3LFW3Awyq50mAWlJRqpoH8JXwOTGb3RRHZnYezMtbunwcw3tgyxP6NhzyGnA4u47vRBls/SeQFYg==", + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.8.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@pezkuwi/x-randomvalues": { + "version": "14.0.11", + "resolved": "https://registry.npmjs.org/@pezkuwi/x-randomvalues/-/x-randomvalues-14.0.11.tgz", + "integrity": "sha512-8HStYeXrNvD6/Zk/RkOz98mIHBv/gGBZ8nLZkjWKsn/PFTPNZbM9hhDwsb98Ky/ZS1ssZWWVg19iH1jHaJ8nYQ==", + "license": "Apache-2.0", + "dependencies": { + "@pezkuwi/x-global": "14.0.11", + "tslib": "^2.8.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@pezkuwi/util": "14.0.11", + "@pezkuwi/wasm-util": "*" + } + }, + "node_modules/@pezkuwi/x-textdecoder": { + "version": "14.0.11", + "resolved": "https://registry.npmjs.org/@pezkuwi/x-textdecoder/-/x-textdecoder-14.0.11.tgz", + "integrity": "sha512-evI/8AYnU1V0mb7MgEoSX4CZJSPw5kjaJB9lQ3jJ93Ei+eaHzR1hH39U+jg1JA4mLXYFVcj9VtdtzKPL6kSv/Q==", + "license": "Apache-2.0", + "dependencies": { + "@pezkuwi/x-global": "14.0.11", + "tslib": "^2.8.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@pezkuwi/x-textencoder": { + "version": "14.0.11", + "resolved": "https://registry.npmjs.org/@pezkuwi/x-textencoder/-/x-textencoder-14.0.11.tgz", + "integrity": "sha512-Sx+dUhoRdaPJOITdpbrI1QEgA6+Xaxe3INUxrr2tD9NdcSMjzQD44r0I4exdtOVJUCuvPF8z9glhqn5OzVQRKw==", + "license": "Apache-2.0", + "dependencies": { + "@pezkuwi/x-global": "14.0.11", + "tslib": "^2.8.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@scure/base": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.2.6.tgz", + "integrity": "sha512-g/nm5FgUa//MCj1gV09zTJTaM6KBAHqLN907YVQqf7zC49+DcO4B1so4ZX07Ef10Twr6nuqYEH9GEggFXA4Fmg==", + "license": "MIT", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/sr25519": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@scure/sr25519/-/sr25519-0.2.0.tgz", + "integrity": "sha512-uUuLP7Z126XdSizKtrCGqYyR3b3hYtJ6Fg/XFUXmc2//k2aXHDLqZwFeXxL97gg4XydPROPVnuaHGF2+xriSKg==", + "license": "MIT", + "dependencies": { + "@noble/curves": "~1.9.2", + "@noble/hashes": "~1.8.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@substrate/ss58-registry": { + "version": "1.51.0", + "resolved": "https://registry.npmjs.org/@substrate/ss58-registry/-/ss58-registry-1.51.0.tgz", + "integrity": "sha512-TWDurLiPxndFgKjVavCniytBIw+t4ViOi7TYp9h/D0NMmkEc9klFTo+827eyEJ0lELpqO207Ey7uGxUa+BS1jQ==", + "license": "Apache-2.0" + }, + "node_modules/@types/bn.js": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.2.0.tgz", + "integrity": "sha512-DLbJ1BPqxvQhIGbeu8VbUC1DiAiahHtAYvA0ZEAa4P31F7IaArc8z3C3BRQdWX4mtLQuABG4yzp76ZrS02Ui1Q==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/node": { + "version": "22.19.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.5.tgz", + "integrity": "sha512-HfF8+mYcHPcPypui3w3mvzuIErlNOh2OAG+BCeBZCEwyiD5ls2SiCwEyT47OELtf7M3nHxBdu0FsmzdKxkN52Q==", + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/yargs": { + "version": "17.0.35", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.35.tgz", + "integrity": "sha512-qUHkeCyQFxMXg79wQfTtfndEC+N9ZZg76HJftDJp+qH2tV7Gj4OJi7l+PiWwJ+pWtW8GwSmqsDj/oymhrTWXjg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/yargs-parser": "*" + } + }, + "node_modules/@types/yargs-parser": { + "version": "21.0.3", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.3.tgz", + "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/bn.js": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.2.tgz", + "integrity": "sha512-v2YAxEmKaBLahNwE1mjp4WON6huMNeuDvagFZW+ASCuA/ku0bXR9hSMw0XpiqMoA3+rmnyck/tPRSFQkoC9Cuw==", + "license": "MIT" + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "license": "MIT" + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "license": "MIT" + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "license": "MIT" + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "license": "MIT", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "license": "ISC", + "engines": { + "node": ">=12" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..8cd9062 --- /dev/null +++ b/package.json @@ -0,0 +1,38 @@ +{ + "author": "Pezkuwichain Team (forked from Jaco Greeff )", + "bugs": "https://github.com/pezkuwichain/pezkuwi-vanitygen/issues", + "description": "A vanity address generator for Pezkuwichain", + "engines": { + "node": ">=18" + }, + "homepage": "https://github.com/pezkuwichain/pezkuwi-vanitygen#readme", + "license": "Apache-2.0", + "name": "@pezkuwi/vanitygen", + "repository": { + "type": "git", + "url": "https://github.com/pezkuwichain/pezkuwi-vanitygen.git" + }, + "sideEffects": false, + "type": "module", + "version": "1.0.0", + "main": "index.js", + "bin": { + "pezkuwi-vanitygen": "./runcli.mjs" + }, + "scripts": { + "build": "tsc --build", + "clean": "rm -rf ./*.js ./*.d.ts ./*.js.map", + "prepublishOnly": "npm run clean && npm run build" + }, + "dependencies": { + "@pezkuwi/util": "^14.0.11", + "@pezkuwi/util-crypto": "^14.0.11", + "tslib": "^2.8.1", + "yargs": "^17.7.2" + }, + "devDependencies": { + "@types/node": "^22.10.5", + "@types/yargs": "^17.0.33", + "typescript": "^5.9.3" + } +} diff --git a/packageDetect.d.ts.map b/packageDetect.d.ts.map new file mode 100644 index 0000000..d85210a --- /dev/null +++ b/packageDetect.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"packageDetect.d.ts","sourceRoot":"","sources":["src/packageDetect.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/packageInfo.d.ts.map b/packageInfo.d.ts.map new file mode 100644 index 0000000..8f45788 --- /dev/null +++ b/packageInfo.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"packageInfo.d.ts","sourceRoot":"","sources":["src/packageInfo.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW;;;;;CAA+E,CAAC"} \ No newline at end of file diff --git a/regex.d.ts.map b/regex.d.ts.map new file mode 100644 index 0000000..29af70c --- /dev/null +++ b/regex.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"regex.d.ts","sourceRoot":"","sources":["src/regex.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,KAAK,QAA4C,CAAC;AAExD,eAAe,KAAK,CAAC"} \ No newline at end of file diff --git a/runcli.d.ts.map b/runcli.d.ts.map new file mode 100644 index 0000000..ef51e4b --- /dev/null +++ b/runcli.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"runcli.d.ts","sourceRoot":"","sources":["src/runcli.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/runcli.mjs b/runcli.mjs new file mode 100755 index 0000000..8699463 --- /dev/null +++ b/runcli.mjs @@ -0,0 +1,5 @@ +#!/usr/bin/env node +// Copyright 2017-2025 @pezkuwi/vanitygen authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import './runcli.js'; diff --git a/sort.d.ts.map b/sort.d.ts.map new file mode 100644 index 0000000..d35eda9 --- /dev/null +++ b/sort.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["src/sort.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAYjD,MAAM,CAAC,OAAO,UAAU,IAAI,CAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,GAAG,MAAM,CAc1E"} \ No newline at end of file diff --git a/src/calculate.ts b/src/calculate.ts new file mode 100644 index 0000000..8a50996 --- /dev/null +++ b/src/calculate.ts @@ -0,0 +1,65 @@ +// Copyright 2017-2025 @pezkuwi/vanitygen authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { GeneratorCalculation, GeneratorOptions } from './types.js'; + +const MAX_OFFSET = 5; + +function calculateAtOne (atOffset: number, test: string[], address: string): GeneratorCalculation { + return { + count: test.reduce((count, c, index): number => { + if (index === count) { + count += (c === '?' || c === address.charAt(index + atOffset)) ? 1 : 0; + } + + return count; + }, 0), + offset: atOffset + }; +} + +function calculateAt (atOffset: number, test: string[][], address: string): GeneratorCalculation { + let bestCount = 0; + let bestOffset = 1; + + for (let i = 0, count = test.length; i < count; i++) { + const { count, offset } = calculateAtOne(atOffset, test[i], address); + + if (count > bestCount) { + bestCount = count; + bestOffset = offset; + } + } + + return { + count: bestCount, + offset: bestOffset + }; +} + +export default function calculate (test: string[][], _address: string, { atOffset = -1, withCase = false }: GeneratorOptions): GeneratorCalculation { + const address = withCase + ? _address + : _address.toLowerCase(); + + if (atOffset > 0) { + return calculateAt(atOffset, test, address); + } + + let bestCount = 0; + let bestOffset = 1; + + for (let i = 0; i < MAX_OFFSET; i++) { + const { count, offset } = calculateAt(i, test, address); + + if (count > bestCount) { + bestCount = count; + bestOffset = offset; + } + } + + return { + count: bestCount, + offset: bestOffset + }; +} diff --git a/src/generate.ts b/src/generate.ts new file mode 100644 index 0000000..50b460f --- /dev/null +++ b/src/generate.ts @@ -0,0 +1,30 @@ +// Copyright 2017-2025 @pezkuwi/vanitygen authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { GeneratorMatch, GeneratorOptions } from './types.js'; + +import { ed25519PairFromSeed, encodeAddress, mnemonicGenerate, mnemonicToMiniSecret, randomAsU8a, sr25519PairFromSeed } from '@pezkuwi/util-crypto'; + +import calculate from './calculate.js'; + +export default function generator (test: string[][], options: GeneratorOptions): GeneratorMatch { + const mnemonic = options.withHex + ? undefined + : mnemonicGenerate(12); + const seed = mnemonic + ? mnemonicToMiniSecret(mnemonic) + : randomAsU8a(); + const pair = options.type === 'sr25519' + ? sr25519PairFromSeed(seed) + : ed25519PairFromSeed(seed); + const address = encodeAddress(pair.publicKey, options.ss58Format); + const { count, offset } = calculate(test, address, options); + + return { + address, + count, + mnemonic, + offset, + seed + }; +} diff --git a/src/generator.ts b/src/generator.ts new file mode 100644 index 0000000..ef8fb5e --- /dev/null +++ b/src/generator.ts @@ -0,0 +1,24 @@ +// Copyright 2017-2025 @pezkuwi/vanitygen authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { GeneratorMatches, GeneratorOptions, GeneratorResult } from './types.js'; + +import generate from './generate.js'; + +export default function generator (options: GeneratorOptions): GeneratorResult { + const { match, runs = 10, withCase = false } = options; + const found: GeneratorMatches = []; + const startAt = Date.now(); + const test = (withCase ? match : match.toLowerCase()) + .split(',') + .map((c): string[] => c.split('')); + + while (found.length !== runs) { + found.push(generate(test, options)); + } + + return { + elapsed: Date.now() - startAt, + found + }; +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..130debe --- /dev/null +++ b/src/index.ts @@ -0,0 +1,4 @@ +// Copyright 2018-2025 @pezkuwi/api-cli authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import './cjs/index.js'; diff --git a/src/packageDetect.ts b/src/packageDetect.ts new file mode 100644 index 0000000..684e080 --- /dev/null +++ b/src/packageDetect.ts @@ -0,0 +1,11 @@ +// Copyright 2017-2025 @pezkuwi/vanitygen authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +// Do not edit, auto-generated by @pezkuwi/dev +// (packageInfo imports will be kept as-is, user-editable) + +import { detectPackage } from '@pezkuwi/util'; + +import { packageInfo } from './packageInfo.js'; + +detectPackage(packageInfo, null, []); diff --git a/src/packageInfo.ts b/src/packageInfo.ts new file mode 100644 index 0000000..bb432dd --- /dev/null +++ b/src/packageInfo.ts @@ -0,0 +1,6 @@ +// Copyright 2017-2025 @pezkuwi/vanitygen authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +// Do not edit, auto-generated by @pezkuwi/dev + +export const packageInfo = { name: '@pezkuwi/vanitygen', path: 'auto', type: 'auto', version: '1.0.0' }; diff --git a/src/regex.ts b/src/regex.ts new file mode 100644 index 0000000..79290b3 --- /dev/null +++ b/src/regex.ts @@ -0,0 +1,7 @@ +// Copyright 2017-2025 @pezkuwi/vanitygen authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +// eslint-disable-next-line prefer-regex-literals +const regex = new RegExp('^[1-9A-HJ-NP-Za-km-z]*$', ''); + +export default regex; diff --git a/src/runcli.mjs b/src/runcli.mjs new file mode 100644 index 0000000..8699463 --- /dev/null +++ b/src/runcli.mjs @@ -0,0 +1,5 @@ +#!/usr/bin/env node +// Copyright 2017-2025 @pezkuwi/vanitygen authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import './runcli.js'; diff --git a/src/runcli.ts b/src/runcli.ts new file mode 100644 index 0000000..f613d8c --- /dev/null +++ b/src/runcli.ts @@ -0,0 +1,152 @@ +#!/usr/bin/env node +// Copyright 2017-2025 @pezkuwi/vanitygen authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { KeypairType } from '@pezkuwi/util-crypto/types'; +import type { GeneratorMatch, GeneratorOptions } from './types.js'; + +import yargs from 'yargs'; +import { hideBin } from 'yargs/helpers'; + +import { u8aToHex } from '@pezkuwi/util'; +import { cryptoWaitReady } from '@pezkuwi/util-crypto'; + +import generator from './generator.js'; +import matchRegex from './regex.js'; + +interface Best extends GeneratorMatch { + withCase?: boolean; +} + +interface ArgV { + match: string; + mnemonic: boolean; + network: string; + type: string; + withCase: boolean; +} + +const { match, mnemonic, network, type, withCase } = yargs(hideBin(process.argv)) + .wrap(120) + .option('match', { + default: 'Test', + type: 'string' + }) + .option('mnemonic', { + default: false, + type: 'boolean' + }) + .option('network', { + choices: ['bizinikiwi', 'pezkuwi', 'dicle', 'zagros'], + default: 'pezkuwi' + }) + .option('type', { + choices: ['ed25519', 'sr25519'], + default: 'sr25519' + }) + .option('withCase', { + default: false, + type: 'boolean' + }) + .argv as ArgV; + +// eslint-disable-next-line prefer-regex-literals +const NUMBER_REGEX = new RegExp('(\\d+?)(?=(\\d{3})+(?!\\d)|$)', 'g'); +const INDICATORS = ['|', '/', '-', '\\']; + +const options: GeneratorOptions = { + match, + network, + runs: 50, + ss58Format: 42, + type: type as KeypairType, + withCase, + withHex: !mnemonic +}; +const startAt = Date.now(); +let best: Best = { + address: '', + count: -1, + offset: 65536 +}; +let total = 0; +let indicator = -1; +const tests = options.match.split(','); + +tests.forEach((test): void => { + if (!matchRegex.test(test)) { + console.error("Invalid character found in match string, allowed is '1-9' (no '0'), 'A-H, J-N & P-Z' (no 'I' or 'O'), 'a-k & m-z' (no 'l') and '?' (wildcard)"); + process.exit(-1); + } +}); + +switch (network) { + case 'dicle': + options.ss58Format = 2; // Dicle (formerly Kusama) + break; + + case 'pezkuwi': + options.ss58Format = 42; // Pezkuwichain main relay + break; + + case 'zagros': + options.ss58Format = 42; // Zagros canary network + break; + + case 'bizinikiwi': + options.ss58Format = 42; // Generic substrate format + break; + + default: + options.ss58Format = 42; + break; +} + +console.log(options); + +function showProgress (): void { + const elapsed = (Date.now() - startAt) / 1000; + + indicator++; + + if (indicator === INDICATORS.length) { + indicator = 0; + } + + process.stdout.write(`\r[${INDICATORS[indicator]}] ${(total.toString().match(NUMBER_REGEX) || []).join(',')} keys in ${(elapsed).toFixed(2)}s (${(total / elapsed).toFixed(0)} keys/s)`); +} + +function showBest (): void { + const { address, count, mnemonic, offset, seed } = best; + + console.log(`\r::: ${address.slice(0, offset)}[${address.slice(offset, count + offset)}]${address.slice(count + offset)} <= ${u8aToHex(seed)} (count=${count}, offset=${offset})${mnemonic ? '\n ' + mnemonic : ''}`); +} + +process.on('unhandledRejection', (error): void => { + console.error(error); + process.exit(1); +}); + +cryptoWaitReady() + .then((): void => { + while (true) { + const nextBest = generator(options).found.reduce((best, match): Best => { + if ((match.count > best.count) || ((match.count === best.count) && (match.offset <= best.offset))) { + return match; + } + + return best; + }, best); + + total += options.runs; + + if (nextBest.address !== best.address) { + best = nextBest; + showBest(); + showProgress(); + } else if ((total % (options.withHex ? 1000 : 100)) === 0) { + showProgress(); + } + } + }) + .catch((error: Error): void => console.error(error)); diff --git a/src/sort.ts b/src/sort.ts new file mode 100644 index 0000000..3cda36f --- /dev/null +++ b/src/sort.ts @@ -0,0 +1,30 @@ +// Copyright 2017-2025 @pezkuwi/vanitygen authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { GeneratorMatch } from './types.js'; + +function numberSort (a: number, b: number): number { + if (a > b) { + return -1; + } else if (a < b) { + return 1; + } + + return 0; +} + +export default function sort (a: GeneratorMatch, b: GeneratorMatch): number { + const countResult = numberSort(a.count, b.count); + + if (countResult !== 0) { + return countResult; + } + + const positionResult = numberSort(b.offset, a.offset); + + if (positionResult !== 0) { + return positionResult; + } + + return a.address.localeCompare(b.address); +} diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..fcfc91b --- /dev/null +++ b/src/types.ts @@ -0,0 +1,33 @@ +// Copyright 2017-2025 @pezkuwi/vanitygen authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { KeypairType } from '@pezkuwi/util-crypto/types'; + +export interface GeneratorCalculation { + count: number; + offset: number; +} + +export interface GeneratorMatch extends GeneratorCalculation { + address: string; + mnemonic?: string; + seed?: Uint8Array; +} + +export type GeneratorMatches = GeneratorMatch[]; + +export interface GeneratorOptions { + atOffset?: number; + match: string; + network?: string; + runs: number; + ss58Format: number; + type: KeypairType; + withCase?: boolean; + withHex?: boolean; +} + +export interface GeneratorResult { + elapsed: number; + found: GeneratorMatches; +} diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..da24d9f --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "baseUrl": "..", + "outDir": "./build", + "rootDir": "./src" + }, + "references": [] +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..92e5947 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ES2022", + "lib": ["ES2022"], + "moduleResolution": "node", + "outDir": "./", + "rootDir": "./src", + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "allowSyntheticDefaultImports": true + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "**/*.spec.ts"] +} diff --git a/types.d.ts.map b/types.d.ts.map new file mode 100644 index 0000000..191233c --- /dev/null +++ b/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["src/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAe,SAAQ,oBAAoB;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,MAAM,gBAAgB,GAAG,cAAc,EAAE,CAAC;AAEhD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,gBAAgB,CAAC;CACzB"} \ No newline at end of file