mirror of
https://github.com/eosswedenorg/antelope-keygen
synced 2026-06-19 04:10:03 +02:00
Compare commits
424 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c4769a030 | |||
| 24136406a7 | |||
| 7e8b1d6e66 | |||
| 8949a80b11 | |||
| 2874862d70 | |||
| d03d27589e | |||
| 772d03a6e3 | |||
| 53644e9ceb | |||
| 1ef3424638 | |||
| ad5d464792 | |||
| baaf7e5b54 | |||
| 1c4e01a726 | |||
| 83f09d494c | |||
| b82ba44544 | |||
| 54ca24bbd9 | |||
| 8cab0cbced | |||
| a421ceb5d8 | |||
| a73b52b987 | |||
| ec07b199ed | |||
| 9a83929029 | |||
| 19f8b67fdd | |||
| 133aa230fb | |||
| 3a2c80e9b5 | |||
| 6554e6c806 | |||
| 2f92e6b2b2 | |||
| 25025c21b4 | |||
| 10ec4355e6 | |||
| 2b4ab78176 | |||
| 2679dc6ef4 | |||
| 4b26e277f8 | |||
| 914205541a | |||
| d5da7d1491 | |||
| 61ce4c751d | |||
| 6589011be5 | |||
| 3ae2c00faa | |||
| 3d5b163e9f | |||
| 9ed6e6ab80 | |||
| 90f5aa17a8 | |||
| 85955baf42 | |||
| 8076eb6342 | |||
| 2cc93efadf | |||
| 8bb1649974 | |||
| aacfdbe4a9 | |||
| 9ad3d47d95 | |||
| 71cb07e6e7 | |||
| 5fd76814c1 | |||
| cf104e1616 | |||
| 8bc93c1bec | |||
| 8d413941ed | |||
| 04b1d60f9b | |||
| e18886e074 | |||
| cbe6902d03 | |||
| d579879d71 | |||
| b39a2a09ae | |||
| e0a7d8fb21 | |||
| 0781b7db80 | |||
| 13a99e15d9 | |||
| b3378eda16 | |||
| 864a55e485 | |||
| d3fd36ef0e | |||
| 1d6fc76eca | |||
| 23a43ff6b3 | |||
| 40831b6941 | |||
| 1ca85a37b8 | |||
| 8e2378cfe8 | |||
| 6273b048bb | |||
| f5d733a4f1 | |||
| e41def2149 | |||
| a92cb0c1d9 | |||
| f40c680ad1 | |||
| 6a7454875c | |||
| 81007003d7 | |||
| 4a3e7d8fa4 | |||
| 1d923d3dd8 | |||
| 0e4a574f7a | |||
| a73689e275 | |||
| 7fb1774359 | |||
| 6bd84b1d8d | |||
| 8c9047d716 | |||
| f7b84c7752 | |||
| 486d2c5030 | |||
| 52e255850a | |||
| 554cfd5884 | |||
| 95849b1e32 | |||
| 010edeb2f5 | |||
| e4dbcbdc0a | |||
| 09e287733c | |||
| 145769970f | |||
| 5bd72cec19 | |||
| 32967fdaac | |||
| 56a5c226bd | |||
| 51883f42ca | |||
| 73ccd4be02 | |||
| cb181bea21 | |||
| 227ce91c98 | |||
| e0a388dac1 | |||
| 88bd1217ba | |||
| f6554a924a | |||
| 0a2ad12700 | |||
| cf6c1a4854 | |||
| 1cb6ddabd6 | |||
| 7c2545cdc2 | |||
| 2a528e0eb0 | |||
| 3cc6a2530e | |||
| a3be286579 | |||
| 4c67cbf905 | |||
| 464a0c1801 | |||
| e26bc8097f | |||
| a6c0cbcc4e | |||
| 38263a421c | |||
| 282028793b | |||
| e20023cf31 | |||
| b7c3fc0506 | |||
| 2ec874607f | |||
| dce6f58607 | |||
| 6f1359444a | |||
| beeba58cee | |||
| e19982acee | |||
| 0b101728b6 | |||
| 8a9d594d37 | |||
| df2b40d1c6 | |||
| 8b8ba4c2c6 | |||
| 63c7212fad | |||
| 54f0fc206f | |||
| 0cb00ae734 | |||
| 9e048c7175 | |||
| 8bc9a87cc9 | |||
| e3d5176cae | |||
| 7cb70bd9a4 | |||
| c173c002f5 | |||
| f1f5e50e9a | |||
| e0d4fbbdb7 | |||
| 37647685ea | |||
| c5e9222abe | |||
| 178e71fbc7 | |||
| e1bda4b846 | |||
| 2084a66dbf | |||
| cad11e5912 | |||
| 2d150a2e8b | |||
| 2d1c0d0785 | |||
| 56c1886880 | |||
| a390d4226f | |||
| 4436f769e6 | |||
| bfd254f484 | |||
| 00b9177f3a | |||
| 8d925536ba | |||
| a350dd5846 | |||
| 404c203488 | |||
| 4a83b06ef2 | |||
| 884f8a6125 | |||
| 54e493de1f | |||
| 7a8867bb3c | |||
| 6181af6212 | |||
| 22222c1d7c | |||
| c1b2bfce0d | |||
| 4741eb684f | |||
| a85c9b5090 | |||
| 9dacf00c7f | |||
| e5cb4a72f6 | |||
| 9e9e96b954 | |||
| 94686cc4f6 | |||
| fc49dd243d | |||
| 460e8149fd | |||
| d3e8cc2814 | |||
| c98ed34e6e | |||
| 099d6b3008 | |||
| 2f16accbba | |||
| 54d46004c1 | |||
| 0503aa0f04 | |||
| 4a3e5a5f62 | |||
| f6dc9cd0b1 | |||
| 8f45d3707a | |||
| 3bd9e9856b | |||
| e9dadc07ac | |||
| 769e56af2f | |||
| 50a2805c3f | |||
| 925ef7e8ad | |||
| c14a453f01 | |||
| 3ca4631bbe | |||
| 1f8fbfc8ca | |||
| 3b1ada9cb7 | |||
| 35706c9ba3 | |||
| 45005c9950 | |||
| 6a53999c14 | |||
| bfc40bd3e7 | |||
| c206ec764f | |||
| 48eb716165 | |||
| bc614da0e8 | |||
| eed3c1cfef | |||
| bbd2959a0d | |||
| 0d44bbc8f6 | |||
| 40ddff41db | |||
| 3c21e27f45 | |||
| 8cb3fad9b1 | |||
| a2ec5eaaec | |||
| 69017c7a21 | |||
| 0205e25afb | |||
| 4cc6f39da3 | |||
| e80d8c5e34 | |||
| 52474387ca | |||
| fb85be4f1e | |||
| 70dee5611b | |||
| d9976c7f80 | |||
| ba0efa2dd7 | |||
| 526b87670b | |||
| 9a5f0cff1c | |||
| dd9dd484e3 | |||
| 654a53698f | |||
| f181bddc4f | |||
| 043900845f | |||
| 9c86841612 | |||
| ef93588211 | |||
| 710a41a6f4 | |||
| 920d422ff8 | |||
| a46a13db4d | |||
| faff761eeb | |||
| dd1fe841ad | |||
| 522c9ccfd5 | |||
| 44a1ea16bd | |||
| 384ad2537b | |||
| aa2fd02884 | |||
| 9cba57d1ab | |||
| 7266699db9 | |||
| 9f28dfcc29 | |||
| cf082919cc | |||
| ba95dbbf93 | |||
| 47767e3443 | |||
| 1924feacb0 | |||
| a9a45363df | |||
| fc00d97d40 | |||
| 086d9e1241 | |||
| 6c26ce8ac6 | |||
| ddc1af8957 | |||
| ac00821a38 | |||
| bc90c2e9ef | |||
| 2851490b3e | |||
| d9634f334b | |||
| a417390bb7 | |||
| 8035e3233c | |||
| 6bf611f7d0 | |||
| f5ab96e04f | |||
| ac4e2f9e9d | |||
| 51081aaf3c | |||
| 1075481b2e | |||
| c3640c034f | |||
| 006fb94786 | |||
| f601824e02 | |||
| df7a8a3c8c | |||
| 9a0bd26f83 | |||
| 72a74fcb5a | |||
| 2aaebdf5e2 | |||
| 04ac59aeac | |||
| 7b58c691b5 | |||
| 13b2ff871f | |||
| 18ccb1f8d2 | |||
| 13e3cde4b7 | |||
| 66f6c5a9de | |||
| b52f61d319 | |||
| 7c2629427d | |||
| 840c6ae69a | |||
| dbf4e56e52 | |||
| f0d3f355cc | |||
| 8b5ac3b18b | |||
| 53fcc9df53 | |||
| 26b96add30 | |||
| f630a8344c | |||
| f676f2e7ca | |||
| f7858cb5bd | |||
| bde7afbc4e | |||
| 48f89105c6 | |||
| aa7b49437a | |||
| 3f1e657649 | |||
| de6b62a5bd | |||
| 9e9b3b7309 | |||
| d642bfe89f | |||
| c59190b7ea | |||
| 7a95dd035e | |||
| 062ce45798 | |||
| 787c5e4bf5 | |||
| e099ba1ed3 | |||
| fd91419642 | |||
| 3505af5c1f | |||
| a9f153212b | |||
| 64f9026f96 | |||
| dcde774eac | |||
| 4a64da310b | |||
| 040d3457ef | |||
| a8432ea972 | |||
| 67c12d7cb3 | |||
| 4df78587c0 | |||
| 3dd0a41c37 | |||
| 35fc0f08cb | |||
| 3bf42e5234 | |||
| daa860d574 | |||
| 6eaf32847c | |||
| f907beba35 | |||
| 6edcd2d66a | |||
| ca617cfa3b | |||
| 243acc8014 | |||
| ba296fba63 | |||
| 3b55751022 | |||
| 508d5639c5 | |||
| 06a2f7be33 | |||
| c5a5ba40f6 | |||
| bcabafbb92 | |||
| d6a4ae6db8 | |||
| 6195b42452 | |||
| b88e613b54 | |||
| f84f474290 | |||
| 805bf3e1e5 | |||
| 51309c4d8a | |||
| 1e725889c1 | |||
| f1f9eb5a66 | |||
| e385e46a94 | |||
| 50e55270a0 | |||
| 694b057d81 | |||
| eeff86feee | |||
| 7ee53b7497 | |||
| 7bae67ddbc | |||
| 833e5f1ae5 | |||
| 0464986ae8 | |||
| b03ad0b22d | |||
| 62ba5b1259 | |||
| 62626c14c0 | |||
| ade4708b50 | |||
| 757ed2956a | |||
| 0536b89486 | |||
| 912ae83684 | |||
| f9aab4033e | |||
| 01fc8911a3 | |||
| 34c24eb710 | |||
| 2511e7b767 | |||
| 4e876b3cc2 | |||
| fcbe784fc8 | |||
| 18178da53a | |||
| c8cd7f10e4 | |||
| 4ddcedb5d6 | |||
| 985cab3f64 | |||
| 8e7b132ca1 | |||
| ce5dda06fe | |||
| 84f01dd707 | |||
| fc5614eff2 | |||
| 7a4cc43ec9 | |||
| bc0369f301 | |||
| 04641354ff | |||
| 0e9d23086f | |||
| 20a47d11b5 | |||
| e0397ceee3 | |||
| 38d1658748 | |||
| 677a48f34a | |||
| 4742096417 | |||
| fd0e893660 | |||
| fca45626fa | |||
| b24ea1fc83 | |||
| 67df405309 | |||
| d636cf7756 | |||
| f9930ec4fc | |||
| cb5df9bbba | |||
| c7802b2e56 | |||
| 8630f5c255 | |||
| 8007a39c35 | |||
| 0bda9e3f2a | |||
| 07a85e732f | |||
| cc4d91579b | |||
| 59b358d256 | |||
| dbb6b64950 | |||
| 3e7da26216 | |||
| 3b916086d0 | |||
| 637ccd529f | |||
| 890e9841e8 | |||
| 56c78cbcc2 | |||
| 288c7e96a2 | |||
| e310bb7ac0 | |||
| 2d1696a0e4 | |||
| 2b20f8aaf4 | |||
| db75317d31 | |||
| 98a3d8b1d1 | |||
| 826ad10ce9 | |||
| 693c7aa069 | |||
| 1142b8d5e4 | |||
| 2d1568a07b | |||
| 368f93a26c | |||
| 152015d959 | |||
| f3bf4bdab1 | |||
| c416bbdad2 | |||
| 368d2ad726 | |||
| 297ae2b98f | |||
| 161b7e80e1 | |||
| 97b834d11e | |||
| 075144c72b | |||
| 8c8d88c631 | |||
| 92f2c4ffcc | |||
| f6ba8a73a2 | |||
| 2db52b9406 | |||
| 8c8e586b2c | |||
| 725ba47e34 | |||
| 5b8d26a4e3 | |||
| 5b4a45fa59 | |||
| 35bb2302dd | |||
| 418949f26f | |||
| fd2b4a8368 | |||
| e95470d57f | |||
| f6e4603cbe | |||
| 58406e0c24 | |||
| baba04991f | |||
| 237fc4e4af | |||
| 5bc3335d54 | |||
| 4f4444a62a | |||
| e5c096c709 | |||
| 87647ba1cd | |||
| 410c890275 | |||
| 6ab7a9affa | |||
| 58c83b2795 | |||
| 26ddf38ef7 | |||
| 1546d3c81c | |||
| 9139969cd6 | |||
| 6dcc897fcf | |||
| a4dec2e39b | |||
| bae3721211 | |||
| 1c3d503369 | |||
| 7e37f1ef8b | |||
| 936378c69f | |||
| 77d63a5c36 | |||
| f4e2b1e162 |
76 changed files with 13909 additions and 702 deletions
90
.github/workflows/ci.yml
vendored
90
.github/workflows/ci.yml
vendored
|
|
@ -6,43 +6,73 @@ on:
|
|||
- '*'
|
||||
- '*/*'
|
||||
- '!master'
|
||||
pull_request:
|
||||
branches: [ develop ]
|
||||
|
||||
jobs:
|
||||
unix:
|
||||
name: compile - Ubuntu
|
||||
runs-on: ubuntu-latest
|
||||
compile:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-20.04, ubuntu-22.04, macos-latest, windows-latest ]
|
||||
build: [ cli, cli-mt, cli-ansi, cli-ansi-mt, gui, gui-mt ]
|
||||
include:
|
||||
- build: cli
|
||||
cmake-opts: -DCOMPONENT_CLI=ON -DCOMPONENT_GUI=OFF -DFORCE_ANSI=OFF -DUSE_THREADS=OFF
|
||||
- build: cli-mt
|
||||
cmake-opts: -DCOMPONENT_CLI=ON -DCOMPONENT_GUI=OFF -DFORCE_ANSI=OFF -DUSE_THREADS=ON
|
||||
- build: cli-ansi
|
||||
cmake-opts: -DCOMPONENT_CLI=ON -DCOMPONENT_GUI=OFF -DFORCE_ANSI=ON -DUSE_THREADS=OFF
|
||||
- build: cli-ansi-mt
|
||||
cmake-opts: -DCOMPONENT_CLI=ON -DCOMPONENT_GUI=OFF -DFORCE_ANSI=ON -DUSE_THREADS=ON
|
||||
- build: gui
|
||||
cmake-opts: -DCOMPONENT_CLI=OFF -DCOMPONENT_GUI=ON -DUSE_THREADS=OFF
|
||||
- build: gui-mt
|
||||
cmake-opts: -DCOMPONENT_CLI=OFF -DCOMPONENT_GUI=ON -DUSE_THREADS=ON
|
||||
|
||||
name: ${{matrix.os}} (${{matrix.build}})
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Configure
|
||||
run: mkdir build && cd build && cmake ..
|
||||
- name: Build
|
||||
run: cmake --build build
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
mac:
|
||||
name: compile - MacOS
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Dependancies
|
||||
- name: OpenSSL OSX
|
||||
if: runner.os == 'macOS'
|
||||
shell: bash
|
||||
run: brew install openssl
|
||||
|
||||
- name: Qt - Ubuntu
|
||||
if: startsWith(matrix.build, 'gui') && runner.os == 'Linux'
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get update
|
||||
if [ "${{matrix.os}}" == "ubuntu-22.04" ]; then
|
||||
sudo apt-get install qtbase5-dev=5.15.3+dfsg-2ubuntu0.2
|
||||
else :
|
||||
sudo apt-get install qt5-default=5.12.8+dfsg-0ubuntu2.1
|
||||
fi
|
||||
|
||||
- name: Qt - Windows/Mac
|
||||
if: startsWith(matrix.build, 'gui') && runner.os != 'Linux'
|
||||
uses: jurplel/install-qt-action@v3
|
||||
with:
|
||||
version: '5.15.2'
|
||||
|
||||
- name: Configure
|
||||
run: mkdir build && cd build && cmake -D OPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1 ..
|
||||
shell: bash
|
||||
run: |
|
||||
OPTS="${{matrix.cmake-opts}}"
|
||||
if [ "$RUNNER_OS" == "macOS" ]; then
|
||||
OPTS="-D OPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1 ${OPTS}"
|
||||
fi
|
||||
cmake ${OPTS} -B build
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
run: cmake --build build
|
||||
|
||||
win:
|
||||
name: compile - windows
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Dependancies
|
||||
run: |
|
||||
mkdir build; cd build
|
||||
Invoke-WebRequest -Uri https://mirror.firedaemon.com/OpenSSL/openssl-1.1.1e-dev.zip -OutFile openssl.zip
|
||||
Expand-Archive openssl.zip
|
||||
- name: Configure
|
||||
run: cd build; cmake -D OPENSSL_ROOT_DIR="$pwd\openssl\openssl-1.1\x64" ..
|
||||
- name: Build
|
||||
run: cmake --build build
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: ${{matrix.os}}_${{matrix.build}}-build
|
||||
path: build
|
||||
|
|
|
|||
161
.github/workflows/package.yml
vendored
Normal file
161
.github/workflows/package.yml
vendored
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
name: Package
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [ created ]
|
||||
|
||||
jobs:
|
||||
# Debian package for ubuntu.
|
||||
ubuntu:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ ubuntu-20.04, ubuntu-22.04 ]
|
||||
component: [ cli, gui ]
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
qt: qt5-default=5.12.8+dfsg-0ubuntu2.1
|
||||
- os: ubuntu-22.04
|
||||
qt: qtbase5-dev=5.15.3+dfsg-2ubuntu0.2
|
||||
- component: cli
|
||||
build-opts: --cli --no-gui -t Release --pkg-type deb
|
||||
- component: gui
|
||||
build-opts: --no-cli --gui -t Release --pkg-type deb
|
||||
name: DEB ${{matrix.os}} (${{matrix.component}})
|
||||
runs-on: ${{matrix.os}}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Qt
|
||||
if: startsWith(matrix.component, 'gui')
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install ${{matrix.qt}}
|
||||
|
||||
- name: Package
|
||||
id: package
|
||||
run: |
|
||||
./build.sh ${{matrix.build-opts}}
|
||||
FILE=$(ls build/*.deb | head -1)
|
||||
echo "filename=$FILE" >> "$GITHUB_OUTPUT"
|
||||
echo "name=$(basename $FILE)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Upload
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_name: ${{ steps.package.outputs.name }}
|
||||
asset_path: ${{ steps.package.outputs.filename }}
|
||||
asset_content_type: application/x-deb
|
||||
|
||||
# RPM package for redhat based systems.
|
||||
rpm:
|
||||
strategy:
|
||||
matrix:
|
||||
container:
|
||||
- name: "fedora:36"
|
||||
deps:
|
||||
gcc-12.2.1-4.fc36.x86_64
|
||||
gcc-c++-12.2.1-4.fc36.x86_64
|
||||
cmake-3.26.3-1.fc36.x86_64
|
||||
openssl1.1-devel-1.1.1q-1.fc36.x86_64
|
||||
qt: qt5-qtbase-devel-5.15.3-1.fc36.x86_64
|
||||
|
||||
- name: "fedora:37"
|
||||
deps:
|
||||
gcc-12.3.1-1.fc37.x86_64
|
||||
gcc-c++-12.3.1-1.fc37.x86_64
|
||||
cmake-3.27.1-1.fc37.x86_64
|
||||
openssl-devel-3.0.9-1.fc37.x86_64
|
||||
qt: qt5-qtbase-devel-5.15.9-3.fc37.x86_64
|
||||
|
||||
- name: "fedora:38"
|
||||
deps:
|
||||
gcc-13.2.1-1.fc38.x86_64
|
||||
gcc-c++-13.2.1-1.fc38.x86_64
|
||||
cmake-3.26.2-1.fc38.x86_64
|
||||
openssl-devel-1:3.0.9-2.fc38.x86_64
|
||||
qt: qt5-qtbase-devel-5.15.10-5.fc38.x86_64
|
||||
component: [ cli, gui ]
|
||||
include:
|
||||
- component: cli
|
||||
build-opts: --cli --no-gui -t Release --pkg-type rpm
|
||||
- component: gui
|
||||
build-opts: --no-cli --gui -t Release --pkg-type rpm
|
||||
name: RPM ${{matrix.container.name}} (${{matrix.component}})
|
||||
runs-on: ubuntu-latest
|
||||
container: ${{ matrix.container.name }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Dependancies
|
||||
run: |
|
||||
sudo dnf install -y util-linux rpmdevtools git ${{ matrix.container.deps }}
|
||||
|
||||
- name: Qt
|
||||
if: startsWith(matrix.component, 'gui')
|
||||
shell: bash
|
||||
run: |
|
||||
sudo dnf install -y ${{ matrix.container.qt }}
|
||||
|
||||
- name: Package
|
||||
id: package
|
||||
run: |
|
||||
./build.sh ${{matrix.build-opts}}
|
||||
FILE=$(ls build/*.rpm | head -1)
|
||||
echo "filename=$FILE" >> "$GITHUB_OUTPUT"
|
||||
echo "name=$(basename $FILE)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Upload
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_name: ${{ steps.package.outputs.name }}
|
||||
asset_path: ${{ steps.package.outputs.filename }}
|
||||
asset_content_type: application/octet-stream
|
||||
|
||||
# Windows installer
|
||||
windows:
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [ Win32, x64 ]
|
||||
include:
|
||||
- arch: Win32
|
||||
qt-arch: win32_msvc2015
|
||||
- arch: x64
|
||||
qt-arch: win64_msvc2015_64
|
||||
name: Windows (${{matrix.arch}})
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Qt
|
||||
uses: jurplel/install-qt-action@v3
|
||||
with:
|
||||
arch: ${{ matrix.qt-arch }}
|
||||
version: '5.11.0'
|
||||
|
||||
- name: Configure
|
||||
run: cmake -A ${{matrix.arch}} -DCOMPONENT_GUI=ON -DCOMPONENT_CLI=ON -D CMAKE_BUILD_TYPE=Release -D CPACK_GENERATOR=NSIS -S . -B build
|
||||
|
||||
- name: Package
|
||||
id: package
|
||||
run: |
|
||||
cmake --build build --config Release --target package
|
||||
$FILE=(ls build/*.exe)
|
||||
echo "filename=$FILE" >> "$GITHUB_OUTPUT"
|
||||
echo "name=$(([io.fileinfo]"$FILE").basename)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Upload
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_name: ${{ steps.package.outputs.name }}
|
||||
asset_path: ${{ steps.package.outputs.filename }}
|
||||
asset_content_type: application/vnd.microsoft.portable-executable
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1 +1,3 @@
|
|||
build/
|
||||
.vscode/
|
||||
.cache/
|
||||
|
|
|
|||
193
CMakeLists.txt
193
CMakeLists.txt
|
|
@ -1,98 +1,141 @@
|
|||
cmake_minimum_required(VERSION 3.4)
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
# Project name and version
|
||||
project(eosio-keygen VERSION 0.1.2)
|
||||
# --------------------------------
|
||||
# Project Info
|
||||
# --------------------------------
|
||||
|
||||
# Options
|
||||
option(USE_THREADS "Compile with support for threads (if available)." ON)
|
||||
project(antelope-keygen
|
||||
VERSION 1.1.0
|
||||
DESCRIPTION "Keygenerator for Antelope based blockchain"
|
||||
HOMEPAGE_URL "https://github.com/eosswedenorg/antelope-keygen" )
|
||||
|
||||
# Use installpath from GNUInstallDirs as default.
|
||||
set( PROJECT_MAINTAINER "Henrik Hautakoski <henrik@eossweden.org>")
|
||||
set( PROJECT_LICENSE_FILE ${CMAKE_CURRENT_LIST_DIR}/LICENSE )
|
||||
|
||||
# --------------------------------
|
||||
# Options
|
||||
# --------------------------------
|
||||
|
||||
option(COMPONENT_CLI "Build CLI Component" ON)
|
||||
option(COMPONENT_GUI "Build GUI Component (Qt5)" OFF)
|
||||
|
||||
if (NOT COMPONENT_CLI AND NOT COMPONENT_GUI)
|
||||
message(FATAL_ERROR "Atleast one of BUILD_COMPONENT_GUI,BUILD_COMPONENT_CLI must be set to ON")
|
||||
endif()
|
||||
|
||||
# --------------------------------
|
||||
# CMake settings
|
||||
# --------------------------------
|
||||
|
||||
# Append modules dir
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
# Default to debug build if none is set.
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
set( CMAKE_BUILD_TYPE Debug )
|
||||
endif()
|
||||
|
||||
# Install path
|
||||
include(GNUInstallDirs)
|
||||
|
||||
set( CMAKE_INSTALL_SHAREDIR ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME} )
|
||||
|
||||
if (WIN32)
|
||||
# "Flat" install on windows.
|
||||
set( CMAKE_INSTALL_BINDIR "bin" )
|
||||
set( CMAKE_INSTALL_DATADIR "." )
|
||||
set( CMAKE_INSTALL_SHAREDIR "." )
|
||||
set( CMAKE_INSTALL_MANDIR "." )
|
||||
endif (WIN32)
|
||||
|
||||
# Path to a directory outside of CMAKE_BUILD_DIR
|
||||
# Should be used to cache large downloaded data that won't be deleted on clean builds.
|
||||
set( DOWNLOAD_CACHE_DIR ${CMAKE_CURRENT_LIST_DIR}/.cache )
|
||||
|
||||
set( components )
|
||||
if (COMPONENT_CLI)
|
||||
list(APPEND components cli )
|
||||
endif()
|
||||
|
||||
if (COMPONENT_GUI)
|
||||
list(APPEND components gui )
|
||||
endif()
|
||||
|
||||
# --------------------------------
|
||||
# Program
|
||||
# Compiler settings
|
||||
# --------------------------------
|
||||
|
||||
set (PROGRAM_EXE ${CMAKE_PROJECT_NAME})
|
||||
|
||||
set (PROGRAM_SOURCE
|
||||
src/string.cpp
|
||||
src/ec.cpp
|
||||
src/base58.cpp
|
||||
src/checksum.cpp
|
||||
src/WIF.cpp
|
||||
src/key_search.cpp
|
||||
src/main.cpp
|
||||
)
|
||||
|
||||
# Configure the compiler options
|
||||
set( CMAKE_CXX_STANDARD 11 )
|
||||
set( CMAKE_CXX_STANDARD_REQUIRED ON )
|
||||
set( CMAKE_CXX_EXTENSIONS OFF )
|
||||
|
||||
# Libraries
|
||||
find_package(OpenSSL 1.1 REQUIRED)
|
||||
# c++ flags
|
||||
add_compile_options(
|
||||
"$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wall;-Wconversion;-Wno-sign-conversion;-Wextra>"
|
||||
"$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/W3;-D_CRT_SECURE_NO_WARNINGS=1>"
|
||||
|
||||
if (USE_THREADS)
|
||||
find_package(Threads)
|
||||
if (Threads_FOUND)
|
||||
# Add preprocessor flag
|
||||
add_definitions( "-DHAVE_THREADS=1" )
|
||||
endif (Threads_FOUND)
|
||||
endif (USE_THREADS)
|
||||
# Debug
|
||||
"$<$<CONFIG:Debug>:$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-O0;-g>>"
|
||||
"$<$<CONFIG:Debug>:$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/Od;/Zi>>"
|
||||
|
||||
# Include OpenSSL headers
|
||||
include_directories( ${OPENSSL_INCLUDE_DIR} )
|
||||
# Release
|
||||
"$<$<CONFIG:Release>:$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-O3>>"
|
||||
"$<$<CONFIG:Release>:$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/O2>>"
|
||||
|
||||
add_executable( ${PROGRAM_EXE} ${PROGRAM_SOURCE} )
|
||||
|
||||
target_link_libraries( ${PROGRAM_EXE}
|
||||
PUBLIC
|
||||
${OPENSSL_LIBRARIES}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
# MinSizeRel
|
||||
"$<$<CONFIG:MinSizeRel>:$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Os>>"
|
||||
"$<$<CONFIG:MinSizeRel>:$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/O1>>"
|
||||
)
|
||||
|
||||
install(TARGETS ${PROGRAM_EXE} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
add_link_options(
|
||||
# Release
|
||||
"$<$<CONFIG:Release>:$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-s>>"
|
||||
)
|
||||
|
||||
# Win32 specific.
|
||||
include(CheckPIESupported)
|
||||
check_pie_supported()
|
||||
#cmake_policy(SET CMP0083 NEW)
|
||||
|
||||
set( CMAKE_POSITION_INDEPENDENT_CODE TRUE )
|
||||
|
||||
# Project config file
|
||||
configure_file(config.hpp.in "${PROJECT_BINARY_DIR}/config.hpp" @ONLY)
|
||||
include_directories(${PROJECT_BINARY_DIR})
|
||||
|
||||
# Bundle antelope-extras on windows.
|
||||
if (WIN32)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set (OPENSSL_LIBCRYPTO_NAME libcrypto-1_1-x64)
|
||||
else()
|
||||
set (OPENSSL_LIBCRYPTO_NAME libcrypto-1_1)
|
||||
include(extras)
|
||||
list(APPEND components extras )
|
||||
endif()
|
||||
|
||||
# --------------------------------
|
||||
# Package
|
||||
# --------------------------------
|
||||
|
||||
include(CPackConfig)
|
||||
|
||||
set( CPACK_COMPONENTS_ALL ${components} )
|
||||
|
||||
if (CPACK_GENERATOR MATCHES "^[Nn][Ss][Ii][Ss]$")
|
||||
set( CPACK_RESOURCE_FILE_LICENSE ${PROJECT_LICENSE_FILE} )
|
||||
endif()
|
||||
|
||||
set (CPACK_PROPERTIES_FILE ${PROJECT_BINARY_DIR}/CPackComponentsInclude.cmake)
|
||||
configure_file(cmake/CPackProperties.cmake.in ${CPACK_PROPERTIES_FILE} @ONLY)
|
||||
|
||||
# --------------------------------
|
||||
# Components
|
||||
# --------------------------------
|
||||
|
||||
add_subdirectory( common )
|
||||
|
||||
foreach(comp ${components})
|
||||
if ( EXISTS ${CMAKE_CURRENT_LIST_DIR}/${comp} )
|
||||
add_subdirectory( ${comp} )
|
||||
endif()
|
||||
set( OPENSSL_LIBCRYPTO_DLL ${OPENSSL_ROOT_DIR}/bin/${OPENSSL_LIBCRYPTO_NAME}.dll )
|
||||
|
||||
# Need to copy libcrypto dll to binary folder.
|
||||
add_custom_command(TARGET ${PROGRAM_EXE} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${OPENSSL_LIBCRYPTO_DLL}
|
||||
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}
|
||||
)
|
||||
|
||||
# "Flat" install on windows.
|
||||
set( CMAKE_INSTALL_BINDIR "." )
|
||||
set( CMAKE_INSTALL_DATADIR "." )
|
||||
|
||||
# We also need to copy libcrypto dll during install
|
||||
install(FILES ${OPENSSL_LIBCRYPTO_DLL} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif (WIN32)
|
||||
endforeach()
|
||||
|
||||
# --------------------------------
|
||||
# Additional install files
|
||||
# CPack
|
||||
# --------------------------------
|
||||
|
||||
install(FILES README.md LICENSE LICENSE.bitcoin
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME})
|
||||
|
||||
# --------------------------------
|
||||
# Debian package script
|
||||
# --------------------------------
|
||||
|
||||
if (UNIX) # Only include in bash environments.
|
||||
# Hack to set the right permissions :)
|
||||
configure_file(scripts/generate_deb.sh.in ${PROJECT_BINARY_DIR}/tmp/generate_deb.sh @ONLY)
|
||||
file(COPY ${PROJECT_BINARY_DIR}/tmp/generate_deb.sh DESTINATION ${PROJECT_BINARY_DIR}
|
||||
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||
)
|
||||
endif (UNIX)
|
||||
include (CPack)
|
||||
|
|
|
|||
2
LICENSE
2
LICENSE
|
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019-2020 EOS Sw/eden
|
||||
Copyright (c) 2019-2023 EOS Sw/eden
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2009-2019 The Bitcoin Core developers
|
||||
Copyright (c) 2009-2019 Bitcoin Developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
156
README.md
156
README.md
|
|
@ -1,33 +1,96 @@
|
|||
|
||||
# EOSIO Keygen
|
||||
[](https://github.com/eosswedenorg/antelope-keygen/actions)
|
||||
[](https://github.com/eosswedenorg/antelope-keygen/releases/latest)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
|
||||
This program generates public and private keypair for [EOS](https://eos.io/)
|
||||
# Antelope Keygen
|
||||
|
||||
This program generates public and private keypair for [Antelope IO](https://antelope.io)
|
||||
|
||||
## Compile
|
||||
|
||||
You will need `openssl` development files (version 1.1 or later) to compile and `cmake` to compile this project.
|
||||
You will need `libantelope` and `cmake 3.15` or later to compile this project.
|
||||
|
||||
`Qt 5.9.0` or later is required for the graphical program.
|
||||
|
||||
### Linux/MacOS
|
||||
|
||||
**NOTE:** Only Ubuntu 20.04 and 22.04 and Fedoora 36 is officially supported.
|
||||
|
||||
The project should compile fine on most versions/distros but it is only tested
|
||||
and distributed for those distros/versions by [Sw/eden](http://www.eossweden.org).
|
||||
|
||||
#### Dependencies
|
||||
|
||||
#### Linux
|
||||
|
||||
**Ubuntu:**
|
||||
|
||||
First you need to have a compiler. this can be installed with apt.
|
||||
|
||||
```sh
|
||||
$ apt-get install libssl-dev cmake
|
||||
$ apt-get install gcc g++
|
||||
```
|
||||
**For other linux distributions:**
|
||||
|
||||
Consult the manual for how to get these installed.
|
||||
**CMake**
|
||||
|
||||
**MacOS:**
|
||||
If your package manager don't provide a sufficiently new version of cmake, you can install it with these commands:
|
||||
|
||||
Ubuntu 16.04/18.04 - [kitware](https://apt.kitware.com) ppa:
|
||||
|
||||
```sh
|
||||
$ brew install openssl cmake
|
||||
$ wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -
|
||||
$ sudo apt-add-repository "deb https://apt.kitware.com/ubuntu/ `lsb_release -cs` main"
|
||||
$ sudo apt-get install cmake
|
||||
```
|
||||
|
||||
shell script:
|
||||
|
||||
```sh
|
||||
$ wget -O cmake.sh https://github.com/Kitware/CMake/releases/download/v3.15.5/cmake-3.15.5-Linux-x86_64.sh && sudo sh ./cmake.sh --prefix=/usr/local --skip-license
|
||||
```
|
||||
|
||||
Other methods is documanted at https://cmake.org/download
|
||||
|
||||
**Qt (only for gui program)**
|
||||
|
||||
You will need to install `qt >= 5.9.0`
|
||||
|
||||
On **ubuntu** you can do this via `apt`
|
||||
|
||||
```
|
||||
$ apt-get install qt5-default
|
||||
```
|
||||
|
||||
For other distributions, download the official [qt-installer](https://www.qt.io/download-qt-installer).
|
||||
It is recommended to install the latest stable version.
|
||||
|
||||
#### MacOS
|
||||
|
||||
**NOTE:** Support for MacOS is still experimental and may or may not work as expected.
|
||||
|
||||
You must have a compiler installed. This project is known to build with `Xcode 11.0` but other versions should work.
|
||||
|
||||
You need to have cmake installed also, this can be done with this `brew` command:
|
||||
```sh
|
||||
$ brew install cmake
|
||||
```
|
||||
|
||||
If you need a newer version of cmake, you can download the official `.dmg` file: [cmake-3.15.7-Darwin-x86_64.dmg](https://github.com/Kitware/CMake/releases/download/v3.15.7/cmake-3.15.7-Darwin-x86_64.dmg). or see https://cmake.org/download for other versions.
|
||||
|
||||
`libantelope` needs to be compiled and installed from source. [Go here](https://github.com/eosswedenorg/libantelope)
|
||||
|
||||
**Qt (only for gui program)**
|
||||
|
||||
This can be installed with brew.
|
||||
|
||||
```sh
|
||||
$ brew install qt
|
||||
```
|
||||
|
||||
#### Build
|
||||
|
||||
After you just need to run `./build.sh` to trigger the whole build.
|
||||
Run `./build.sh` to trigger cmake.
|
||||
|
||||
If you dont want to use the script. you can build with cmake using the following commands:
|
||||
|
||||
|
|
@ -43,13 +106,14 @@ $ cmake .. && make
|
|||
|
||||
#### Dependencies
|
||||
|
||||
Download and install `cmake` from [cmake.org](https://cmake.org) and download
|
||||
[openssl](https://mirror.firedaemon.com/OpenSSL/openssl-1.1.1e-dev.zip)
|
||||
|
||||
unpack `openssl-1.1.1e-dev.zip` somewhere on the filesystem.
|
||||
Download and install `cmake` version `3.15` or newer from [cmake.org](https://cmake.org)
|
||||
|
||||
You will also need a compiler. [Build Tools for Visual Studio 2019](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16) (Selecting C++ during installation) is recommended.
|
||||
|
||||
**Qt (only for gui program)**
|
||||
|
||||
Download the official [qt-installer](https://www.qt.io/download-qt-installer) and follow the steps. It is recommended to install the latest stable version.
|
||||
|
||||
#### Build.
|
||||
|
||||
you need to set `OPENSSL_ROOT_DIR` to the directory where you unpacked
|
||||
|
|
@ -60,12 +124,57 @@ you need to set `OPENSSL_ROOT_DIR` to the directory where you unpacked
|
|||
For example:
|
||||
|
||||
```
|
||||
C:\repo> mkdir build
|
||||
C:\repo> cd build
|
||||
C:\repo\build> cmake -D OPENSSL_ROOT_DIR="C:/path/to/openssl-1.1/x86" ..
|
||||
C:\repo\build> cmake --build . --config Release
|
||||
C:\repo> cmake -D OPENSSL_ROOT_DIR="C:/path/to/openssl-1.1/x86" -B build
|
||||
C:\repo> cmake --build build --config Release
|
||||
```
|
||||
|
||||
**Qt**
|
||||
|
||||
If you are compiling the gui program. you will need to point `cmake` to the location `qt` where installed. this can be done by the `CMAKE_PREFIX_PATH` variable:
|
||||
|
||||
```
|
||||
C:\repo> cmake -D CMAKE_PREFIX_PATH="C:/path/to/qt/msvc2017_64"
|
||||
```
|
||||
|
||||
## Compile options
|
||||
|
||||
These compile options are available:
|
||||
|
||||
| Cmake | build.sh | Description |
|
||||
|--------------------------- | ----------------- | ----------------------------------------- |
|
||||
| -DCOMPONENT_CLI=`OFF` | --no-cli | Do not build cli program |
|
||||
| -DCOMPONENT_GUI=`ON` | --gui | Build gui program (Qt5) |
|
||||
| -DUSE_THREADS=`OFF` | --disable-threads | Disable thread support |
|
||||
| -DCMAKE_BUILD_TYPE=`value` | -t `value` | Type of build |
|
||||
| -DFORCE_ANSI=`ON` | --force-ansi | Force ANSI console colors even on windows |
|
||||
|
||||
For more details about options run `./build.sh -l` or `mkdir build && cmake build -LA`
|
||||
|
||||
### libantelope
|
||||
|
||||
To speed up the build process, you can install `libantelope`
|
||||
|
||||
#### Ubuntu
|
||||
|
||||
You can use [Sw/eden's APT Repository](https://eosswedenorg.github.io/apt) like this:
|
||||
|
||||
```sh
|
||||
$ sudo apt-get install software-properties-common
|
||||
$ curl https://apt.eossweden.org/key 2> /dev/null | sudo apt-key add -
|
||||
$ sudo apt-add-repository -y 'deb [arch=amd64] https://apt.eossweden.org/main `lsb_release -cs` stable'
|
||||
$ sudo apt-get install libantelope-dev
|
||||
```
|
||||
or manually via `.deb` file from [github](https://github.com/eosswedenorg/libantelope/releases)
|
||||
|
||||
```sh
|
||||
$ wget <url>
|
||||
$ sudo apt install ./libantelope-dev-<version>.deb
|
||||
```
|
||||
|
||||
#### Other
|
||||
|
||||
Consult [libantelope's github](https://github.com/eosswedenorg/libantelope)
|
||||
|
||||
## Install
|
||||
|
||||
After the project has been compiled. run `sudo ./install.sh` or the following code if you dont want to use that:
|
||||
|
|
@ -86,13 +195,12 @@ Run `sudo ./uninstall.sh` or remove the files listed in `build/install_manifest.
|
|||
|
||||
## Security notice
|
||||
|
||||
Keys are generated by `OpenSSL`'s `EC_KEY_generate_key` function. The program will
|
||||
never expose your keys to anything but the computers memory and output of the
|
||||
program. You are free to inspect the source code and compile yourself to verify.
|
||||
Keys are generated using [libantelope](https://github.com/eosswedenorg/libantelope)
|
||||
while the library does not claim to guarantee cryptographically secure keys. it
|
||||
relies on widly used open source cryptographic libraries (OpenSSL, libsecp256k1).
|
||||
|
||||
However, use this at your own risk. we cannot guarantee that the keys are
|
||||
cryptographically secure as this depends on OpenSSL's implementation (alto it is
|
||||
widely used and should be safe)
|
||||
Use at your own risk. The author and [Sw/eden](https://eossweden.org/) does not take responsability
|
||||
for any damage caused by keys generated by the program.
|
||||
|
||||
Please read the `LICENSE` file.
|
||||
|
||||
|
|
@ -107,4 +215,4 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
## Author
|
||||
|
||||
Henrik Hautakoski - [henrik@eossweden.org](mailto:henrik@eossweden.org)
|
||||
Henrik Hautakoski - [Sw/eden](https://eossweden.org/) - [henrik@eossweden.org](mailto:henrik@eossweden.org)
|
||||
|
|
|
|||
75
build.sh
75
build.sh
|
|
@ -1,7 +1,72 @@
|
|||
#!/bin/bash
|
||||
|
||||
mkdir build 2> /dev/null
|
||||
pushd build > /dev/null
|
||||
cmake .. $@
|
||||
make -B
|
||||
popd > /dev/null
|
||||
function usage() {
|
||||
echo "Usage: ${0##*/} [ -h|--help ] [ --cli|--no-cli ] [ --gui|--no-gui] [ -t|--type Debug|Release|RelWithDebInfo|MinSizeRel ] [ --libeosio=<path> ] [ --pkg-type nsis|deb|zip|tgz ] [ --disable-threads ] [ --force-ansi ]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
options=$(getopt -n "${0##*/}" -o "lht:" -l "help,cli,no-cli,gui,no-gui,type:,libeosio:,pkg-type:,disable-threads,force-ansi" -- "$@")
|
||||
|
||||
[ $? -eq 0 ] || usage
|
||||
|
||||
eval set -- "$options"
|
||||
|
||||
TARGET="all"
|
||||
ONLY_CONFIG=0
|
||||
ARGS=""
|
||||
BUILD_ARGS="--clean-first"
|
||||
while true; do
|
||||
|
||||
case $1 in
|
||||
-t|--type)
|
||||
shift
|
||||
[[ ! "$1" =~ ^(Debug|Release|RelWithDebInfo|MinSizeRel)$ ]] && {
|
||||
echo "Incorrect type '$1' provided"
|
||||
usage
|
||||
}
|
||||
ARGS="${ARGS} -DCMAKE_BUILD_TYPE=${1}"
|
||||
BUILD_ARGS="${BUILD_ARGS} --config ${1}"
|
||||
;;
|
||||
--pkg-type)
|
||||
shift
|
||||
[[ ! "$1" =~ ^(nsis|deb|rpm|zip|tgz)$ ]] && {
|
||||
echo "Incorrect package type '$1' provided"
|
||||
usage
|
||||
}
|
||||
TARGET="package"
|
||||
ARGS="${ARGS} -DCPACK_GENERATOR=${1^^}"
|
||||
;;
|
||||
--libeosio)
|
||||
shift
|
||||
ARGS="${ARGS} -DLIBEOSIO_SOURCE_DIR=${1}"
|
||||
;;
|
||||
--cli)
|
||||
ARGS="${ARGS} -DCOMPONENT_CLI=ON" ;;
|
||||
--no-cli)
|
||||
ARGS="${ARGS} -DCOMPONENT_CLI=OFF" ;;
|
||||
--gui)
|
||||
ARGS="${ARGS} -DCOMPONENT_GUI=ON" ;;
|
||||
--no-gui)
|
||||
ARGS="${ARGS} -DCOMPONENT_GUI=OFF" ;;
|
||||
--disable-threads)
|
||||
ARGS="${ARGS} -DUSE_THREADS=OFF" ;;
|
||||
--force-ansi)
|
||||
ARGS="${ARGS} -DFORCE_ANSI=ON" ;;
|
||||
-l)
|
||||
ARGS="${ARGS} -LH"
|
||||
ONLY_CONFIG=1 ;;
|
||||
-h|--help) usage ;;
|
||||
--) shift
|
||||
break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Remove cache first
|
||||
rm build/CMakeCache.txt 2> /dev/null
|
||||
|
||||
cmake -B build $ARGS .
|
||||
if [ ${ONLY_CONFIG} -eq 0 ]; then
|
||||
cmake --build build ${BUILD_ARGS} --target ${TARGET}
|
||||
fi
|
||||
|
|
|
|||
84
cli/CMakeLists.txt
Normal file
84
cli/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
# --------------------------------
|
||||
# Project Info
|
||||
# --------------------------------
|
||||
|
||||
project(antelope-keygen
|
||||
VERSION ${CMAKE_PROJECT_VERSION}
|
||||
LANGUAGES CXX)
|
||||
|
||||
# Options
|
||||
option(FORCE_ANSI "Force ANSI console colors even on windows" OFF)
|
||||
|
||||
# --------------------------------
|
||||
# Program
|
||||
# --------------------------------
|
||||
|
||||
set (PROGRAM_EXE ${PROJECT_NAME})
|
||||
|
||||
set (PROGRAM_SOURCE
|
||||
src/isatty.cpp
|
||||
src/cli_key_search_result.cpp
|
||||
src/console.cpp
|
||||
src/benchmark.cpp
|
||||
src/main.cpp
|
||||
)
|
||||
|
||||
if (WIN32 AND NOT FORCE_ANSI)
|
||||
set (PROGRAM_SOURCE ${PROGRAM_SOURCE} src/console_win32.cpp)
|
||||
else()
|
||||
# *nix should have ansi support.
|
||||
set (PROGRAM_SOURCE ${PROGRAM_SOURCE} src/console_ansi.cpp)
|
||||
endif()
|
||||
|
||||
add_executable( ${PROGRAM_EXE} ${PROGRAM_SOURCE} )
|
||||
|
||||
# Include CLI11
|
||||
include ( ${CMAKE_SOURCE_DIR}/lib/CLI11/CMakeLists.txt )
|
||||
|
||||
target_include_directories( ${PROGRAM_EXE} PRIVATE ${LIBCLI11_INCLUDE} )
|
||||
target_link_libraries( ${PROGRAM_EXE} PUBLIC common )
|
||||
|
||||
# --------------------------------
|
||||
# Install
|
||||
# --------------------------------
|
||||
|
||||
install(TARGETS ${PROGRAM_EXE}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT cli)
|
||||
|
||||
install(FILES ${PROJECT_LICENSE_FILE}
|
||||
DESTINATION ${CMAKE_INSTALL_SHAREDIR}
|
||||
COMPONENT cli
|
||||
RENAME LICENSE.cli)
|
||||
|
||||
install (FILES ${LIBCLI11_LICENSE}
|
||||
DESTINATION ${CMAKE_INSTALL_SHAREDIR}
|
||||
COMPONENT cli
|
||||
RENAME LICENSE.libcli11)
|
||||
|
||||
|
||||
# Documentation
|
||||
|
||||
configure_file( docs/README.md.in ${PROJECT_BINARY_DIR}/README.cli.md @ONLY )
|
||||
install(FILES ${PROJECT_BINARY_DIR}/README.cli.md
|
||||
DESTINATION ${CMAKE_INSTALL_SHAREDIR}
|
||||
COMPONENT cli)
|
||||
|
||||
if (UNIX)
|
||||
configure_file( docs/antelope-keygen.1.in ${PROJECT_BINARY_DIR}/man1/antelope-keygen.1 )
|
||||
configure_file( docs/antelope-keygen-search.1.in ${PROJECT_BINARY_DIR}/man1/antelope-keygen-search.1 )
|
||||
configure_file( docs/antelope-keygen-benchmark.1.in ${PROJECT_BINARY_DIR}/man1/antelope-keygen-benchmark.1 )
|
||||
|
||||
install(DIRECTORY ${PROJECT_BINARY_DIR}/man1
|
||||
DESTINATION ${CMAKE_INSTALL_MANDIR}
|
||||
COMPONENT cli)
|
||||
endif (UNIX)
|
||||
|
||||
# --------------------------------
|
||||
# Package
|
||||
# --------------------------------
|
||||
|
||||
configure_file(cmake/CPackComponentConfig.cmake.in
|
||||
${PROJECT_BINARY_DIR}/CPackProperties.cmake)
|
||||
16
cli/cmake/CPackComponentConfig.cmake.in
Normal file
16
cli/cmake/CPackComponentConfig.cmake.in
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
# --------------------------------
|
||||
# CPack Component Config
|
||||
# --------------------------------
|
||||
|
||||
set( CPACK_PACKAGE_CLI_NAME "${PROJECT_NAME}" )
|
||||
set( CPACK_PACKAGE_CLI_CONTACT "${PROJECT_MAINTAINER}" )
|
||||
|
||||
set( CPACK_COMPONENT_CLI_DESCRIPTION "Command line application" )
|
||||
|
||||
# Debian specific
|
||||
set( CPACK_DEBIAN_CLI_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}-${CPACK_SYSTEM_NAME}-${CPACK_SYSTEM_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
|
||||
set( CPACK_DEBIAN_CLI_PACKAGE_NAME "${PROJECT_NAME}" )
|
||||
set( CPACK_DEBIAN_CLI_PACKAGE_PRIORITY "optional" )
|
||||
set( CPACK_DEBIAN_CLI_PACKAGE_SECTION "misc" )
|
||||
set( CPACK_DEBIAN_CLI_PACKAGE_DEPENDS "libssl1.1 (>= 1.1.0) | libssl3 (>= 3.0.0), libstdc++6 (>= 6)")
|
||||
106
cli/docs/README.md.in
Normal file
106
cli/docs/README.md.in
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
|
||||
# @PROJECT_NAME@ (cli)
|
||||
|
||||
Generate public and private keypair for [Antelope IO](https://antelope.io)
|
||||
|
||||
Source code is available at [github.com](https://github.com/eosswedenorg/antelope-keygen)
|
||||
|
||||
## Synopsis
|
||||
|
||||
```shell
|
||||
@PROJECT_NAME@ [-h|--help]
|
||||
|
||||
@PROJECT_NAME@ [-v]
|
||||
|
||||
@PROJECT_NAME@ search [-m] [--l33t] [--threads <num>] [--dict <file1> ...] [--lang <value> ...] word_list [count]
|
||||
|
||||
@PROJECT_NAME@ benchmark [num_keys]
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Output one Antelope key pair if no arguments are given.
|
||||
Options and subcommands are as follows:
|
||||
|
||||
### General flags
|
||||
|
||||
| syntax | Description |
|
||||
| --------------- | ---------------- |
|
||||
| -h, --help | Shows help text. |
|
||||
| -v | Shows version |
|
||||
|
||||
|
||||
### search command
|
||||
|
||||
`@PROJECT_NAME@ search [-m] [--l33t] [--threads <num>] [--dict <file1> ...] [--lang <value> ...] word_list [count]`
|
||||
|
||||
performs a search, finding `count` public keys containing one or more words from `word_list` (separated with ',').
|
||||
|
||||
Instead of a list it is possible to specify a file with words (separated with newline '\n') using `file:/path/to/file`
|
||||
|
||||
#### Search specific options
|
||||
|
||||
#### -m
|
||||
|
||||
Monochrome, disables all color output.
|
||||
|
||||
#### --leet
|
||||
|
||||
Takes each word in `word_list` and find all l33tspeak combinations of that word and uses the new list for the search.
|
||||
|
||||
#### --threads num
|
||||
|
||||
Use `num` of parallel threads for searching. Default is what the operating system recommends.
|
||||
|
||||
#### --dict file
|
||||
Use words found in `file` (separated by newline) to highlight words in the keys
|
||||
found (note that the words in this file are not used for search. only for highlight output).
|
||||
|
||||
There can be more then one `--dict` flag. In that case contents of all files are merged into one dictionary.
|
||||
|
||||
#### --lang value
|
||||
|
||||
Same as `--dict` but will use `value` to find a file in `@CMAKE_INSTALL_FULL_DATADIR@/@CMAKE_PROJECT_NAME@/dict`.
|
||||
There can be more then one `--lang` flag. In that case contents of all files are merged into one dictionary.
|
||||
|
||||
#### count
|
||||
|
||||
Number of keys to search for (default is 10)
|
||||
|
||||
|
||||
### benchmark command
|
||||
|
||||
`@PROJECT_NAME@ benchmark [num_keys]`
|
||||
|
||||
performs a benchmark test, generating `num_keys` keys and measuring the time.
|
||||
|
||||
#### Benchmark specific options:
|
||||
|
||||
#### num_keys
|
||||
|
||||
Number of keys to search for (default is 10)
|
||||
|
||||
|
||||
## Security notice
|
||||
|
||||
Keys are generated using [libantelope](https://github.com/eosswedenorg/libantelope)
|
||||
while the library does not claim to guarantee cryptographically secure keys. it
|
||||
relies on widly used open source cryptographic libraries (OpenSSL, libsecp256k1).
|
||||
|
||||
Use at your own risk. The author and [Sw/eden](https://eossweden.org/) does not take responsability
|
||||
for any damage caused by keys generated by the program.
|
||||
|
||||
Please read the `LICENSE.cli` file.
|
||||
|
||||
```
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
Henrik Hautakoski - [Sw/eden](https://eossweden.org/) - [henrik@eossweden.org](mailto:henrik@eossweden.org)
|
||||
67
cli/docs/antelope-keygen-benchmark.1.in
Normal file
67
cli/docs/antelope-keygen-benchmark.1.in
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
.TH @PROJECT_NAME@-benchmark 1 "April, 2023" "@PROJECT_NAME@-benchmark @PROJECT_VERSION@"
|
||||
|
||||
.SH NAME
|
||||
@PROJECT_NAME@ benchmark - Benchmark the performance of the @PROJECT_NAME@ key generator.
|
||||
|
||||
.SH SYNOPSIS
|
||||
|
||||
.SY @PROJECT_NAME@
|
||||
benchmark
|
||||
.OP \-h|--help
|
||||
.YS
|
||||
|
||||
.SY @PROJECT_NAME@
|
||||
benchmark
|
||||
.OP num_keys
|
||||
.YS
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
performs a benchmark test, generating \fInum_keys\fR (default 1000) keys and measuring the time.
|
||||
|
||||
.SH SECURITY NOTICE
|
||||
|
||||
.PP
|
||||
Keys are generated using
|
||||
.UR https://github.com/eosswedenorg/libantelope
|
||||
libantelope
|
||||
.UE .
|
||||
while the library does not claim to guarantee cryptographically secure keys. it
|
||||
relies on widly used open source cryptographic libraries (OpenSSL, libsecp256k1).
|
||||
|
||||
.PP
|
||||
Use at your own risk. The author and
|
||||
.UR https://eossweden.org
|
||||
Sw/eden
|
||||
.UE
|
||||
does not take responsability for any damage caused by keys generated by the program.
|
||||
|
||||
.P
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
.br
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
.br
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
.br
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
.br
|
||||
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
.br
|
||||
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
.SH BUGS
|
||||
|
||||
Report bugs to
|
||||
.UR https://github.com/eosswedenorg/eosio-keygen/issues
|
||||
Github
|
||||
.UE . Thank you.
|
||||
|
||||
.SH AUTHOR
|
||||
|
||||
.MT henrik@eossweden.org
|
||||
Henrik Hautakoski
|
||||
.ME
|
||||
|
||||
.UR https://eossweden.org
|
||||
EOS Sw/eden
|
||||
.UE
|
||||
112
cli/docs/antelope-keygen-search.1.in
Normal file
112
cli/docs/antelope-keygen-search.1.in
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
.TH @PROJECT_NAME@-search 1 "April, 2023" "@PROJECT_NAME@-search @PROJECT_VERSION@"
|
||||
|
||||
.SH NAME
|
||||
@PROJECT_NAME@ search - Search after
|
||||
.UR https://antelope.io
|
||||
Antelope IO
|
||||
.UE
|
||||
vanity keys.
|
||||
|
||||
.SH SYNOPSIS
|
||||
|
||||
.SY @PROJECT_NAME@
|
||||
search
|
||||
.OP \-h|--help
|
||||
.YS
|
||||
|
||||
.SY @PROJECT_NAME@
|
||||
search
|
||||
.OP -m
|
||||
.OP \--l33t
|
||||
.OP \--threads <num>
|
||||
.OP \--dict <file1> ...
|
||||
.OP \--lang <value> ...
|
||||
.B word_list
|
||||
.OP count
|
||||
.YS
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
.PP
|
||||
performs a search, finding \fIcount\fR public keys containing one or more words from
|
||||
\fIword_list\fR (separated with ',').
|
||||
.PP
|
||||
Instead of a list it is possible to specify a file with words (separated with newline \fB'\\n'\fR) using
|
||||
\fIfile:<filename\fR
|
||||
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Show help text.
|
||||
.TP
|
||||
\fB\-m\fR
|
||||
Monochrome, disables all color output.
|
||||
.TP
|
||||
.B --l33t
|
||||
Takes each word in <\fIword_list\fR> and find all l33tspeak combinations of that word and uses the new list for the search.
|
||||
.TP
|
||||
\fB\-\-threads\fR \fInum\fR
|
||||
Use <\fInum\fR> of parallel threads for searching. Default is what the operating system recommends.
|
||||
.TP
|
||||
\fB\-\-dict\fR \fIfile\fR
|
||||
Use words found in \fIfile\fR (separated by newline) to highlight words in the keys found.
|
||||
.br
|
||||
There can be more then one \fB\-\-dict\fR flag.
|
||||
In that case contents of all files are merged into one dictionary.
|
||||
.br
|
||||
\fBnote:\fR the words in this file are not used for search. only for highlight output.
|
||||
.TP
|
||||
\fB\-\-lang\fR \fIvalue\fR
|
||||
Same as \fB\-\-dict\fR but will use \fIvalue\fR to find a file in
|
||||
\fB@CMAKE_INSTALL_FULL_DATADIR@/@CMAKE_PROJECT_NAME@/dict\fR.
|
||||
.br
|
||||
There can be more then one \fB\-\-lang\fR flag. In that case contents of all files are merged into one dictionary.
|
||||
.TP
|
||||
\fBcount\fR
|
||||
Number of keys to search for (default is 10)
|
||||
|
||||
.SH SECURITY NOTICE
|
||||
|
||||
.PP
|
||||
Keys are generated using
|
||||
.UR https://github.com/eosswedenorg/libantelope
|
||||
libantelope
|
||||
.UE .
|
||||
while the library does not claim to guarantee cryptographically secure keys. it
|
||||
relies on widly used open source cryptographic libraries (OpenSSL, libsecp256k1).
|
||||
|
||||
.PP
|
||||
Use at your own risk. The author and
|
||||
.UR https://eossweden.org
|
||||
Sw/eden
|
||||
.UE
|
||||
does not take responsability for any damage caused by keys generated by the program.
|
||||
|
||||
.P
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
.br
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
.br
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
.br
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
.br
|
||||
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
.br
|
||||
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
.SH BUGS
|
||||
|
||||
Report bugs to
|
||||
.UR https://github.com/eosswedenorg/eosio-keygen/issues
|
||||
Github
|
||||
.UE . Thank you.
|
||||
|
||||
.SH AUTHOR
|
||||
|
||||
.MT henrik@eossweden.org
|
||||
Henrik Hautakoski
|
||||
.ME
|
||||
|
||||
.UR https://eossweden.org
|
||||
EOS Sw/eden
|
||||
.UE
|
||||
106
cli/docs/antelope-keygen.1.in
Normal file
106
cli/docs/antelope-keygen.1.in
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
.TH @PROJECT_NAME@ 1 "April, 2023" "@PROJECT_NAME@ @PROJECT_VERSION@"
|
||||
|
||||
.SH NAME
|
||||
@PROJECT_NAME@ - Generate public and private keypair for
|
||||
.UR https://antelope.io
|
||||
Antelope IO
|
||||
.UE .
|
||||
|
||||
.SH SYNOPSIS
|
||||
|
||||
.SY @PROJECT_NAME@
|
||||
.OP \-h|--help
|
||||
.YS
|
||||
|
||||
.SY @PROJECT_NAME@
|
||||
.OP \-v
|
||||
.YS
|
||||
|
||||
.SY @PROJECT_NAME@
|
||||
.OP \--format <value>
|
||||
.YS
|
||||
|
||||
.SH SUBCOMMANDS
|
||||
|
||||
.PP
|
||||
\fB@PROJECT_NAME@ search\fR
|
||||
.RS 4
|
||||
Search after
|
||||
.UR https://antelope.io
|
||||
Antelope IO
|
||||
.UE
|
||||
vanity keys.
|
||||
.br
|
||||
see \fB@PROJECT_NAME@-search\fR(1)
|
||||
.RE
|
||||
|
||||
.PP
|
||||
\fB@PROJECT_NAME@ benchmark\fR
|
||||
.RS 4
|
||||
Benchmark the performance of the @PROJECT_NAME@ key generator.
|
||||
.br
|
||||
see \fB@PROJECT_NAME@-benchmark\fR(1)
|
||||
.RE
|
||||
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
Output one Antelope key pair if no arguments are given
|
||||
.PP
|
||||
Options and subcommands are as follows:
|
||||
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Shows this help text.
|
||||
.TP
|
||||
\fB\-v\fR
|
||||
Shows version.
|
||||
.TP
|
||||
\fB\-\-format\fR \fR\fI\,value\/\fR
|
||||
What keyformat to use, valid values are: \fIK1\fR, \fIlegacy\fR, \fIfio\fR
|
||||
|
||||
.SH SECURITY NOTICE
|
||||
|
||||
.PP
|
||||
Keys are generated using
|
||||
.UR https://github.com/eosswedenorg/libantelope
|
||||
libantelope
|
||||
.UE .
|
||||
while the library does not claim to guarantee cryptographically secure keys. it
|
||||
relies on widly used open source cryptographic libraries (OpenSSL, libsecp256k1).
|
||||
|
||||
.PP
|
||||
Use at your own risk. The author and
|
||||
.UR https://eossweden.org
|
||||
Sw/eden
|
||||
.UE
|
||||
does not take responsability for any damage caused by keys generated by the program.
|
||||
|
||||
.P
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
.br
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
.br
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
.br
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
.br
|
||||
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
.br
|
||||
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
.SH BUGS
|
||||
|
||||
Report bugs to
|
||||
.UR https://github.com/eosswedenorg/eosio-keygen/issues
|
||||
Github
|
||||
.UE . Thank you.
|
||||
|
||||
.SH AUTHOR
|
||||
|
||||
.MT henrik@eossweden.org
|
||||
Henrik Hautakoski
|
||||
.ME
|
||||
|
||||
.UR https://eossweden.org
|
||||
EOS Sw/eden
|
||||
.UE
|
||||
50
cli/src/benchmark.cpp
Normal file
50
cli/src/benchmark.cpp
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <chrono>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include "benchmark.hpp"
|
||||
|
||||
namespace antelopekeygen {
|
||||
|
||||
std::chrono::duration<float> _run_benchmark(size_t num_keys) {
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
for(size_t i = 0; i < num_keys; i++) {
|
||||
struct libantelope::ec_keypair k;
|
||||
libantelope::ec_generate_key(&k);
|
||||
}
|
||||
return std::chrono::steady_clock::now() - start;
|
||||
}
|
||||
|
||||
void benchmark(size_t num_keys, struct benchmark_result* res) {
|
||||
|
||||
if (num_keys < 1) {
|
||||
res->sec = res->kps = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
res->sec = _run_benchmark(num_keys).count();
|
||||
res->kps = static_cast<float>(num_keys) / res->sec;
|
||||
}
|
||||
|
||||
} // namespace antelopekeygen
|
||||
40
cli/src/benchmark.hpp
Normal file
40
cli/src/benchmark.hpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef EOSIOKEYGEN_BENCHMARK_H
|
||||
#define EOSIOKEYGEN_BENCHMARK_H
|
||||
|
||||
#include <ctime>
|
||||
|
||||
namespace antelopekeygen {
|
||||
|
||||
struct benchmark_result {
|
||||
float sec; // elapsed seconds.
|
||||
float kps; // keys per second.
|
||||
};
|
||||
|
||||
void benchmark(size_t num_keys, struct benchmark_result* res);
|
||||
|
||||
} // namespace antelopekeygen
|
||||
|
||||
#endif /* EOSIOKEYGEN_BENCHMARK_H */
|
||||
77
cli/src/cli_key_search_result.cpp
Normal file
77
cli/src/cli_key_search_result.cpp
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <libantelope/WIF.hpp>
|
||||
#include <eoskeygen/core/dictionary.hpp>
|
||||
#include "console.hpp"
|
||||
#include "cli_key_search_result.hpp"
|
||||
|
||||
namespace antelopekeygen {
|
||||
|
||||
static size_t highlight(console::Color color, const std::string& str, size_t pos, size_t len) {
|
||||
|
||||
std::cout << console::fg(color, console::bold)
|
||||
<< str.substr(pos, len)
|
||||
<< console::reset;
|
||||
return len;
|
||||
}
|
||||
|
||||
CliKeySearchResult::CliKeySearchResult(const Dictionary& dict, const libantelope::wif_codec_t& codec) :
|
||||
m_dict (dict),
|
||||
m_codec (codec)
|
||||
{
|
||||
}
|
||||
|
||||
void CliKeySearchResult::onResult(const struct libantelope::ec_keypair* key, const struct KeySearch::result& result) {
|
||||
|
||||
std::string pub = libantelope::wif_pub_encode(key->pub, m_codec.pub);
|
||||
Dictionary::search_result_t dict_res = m_dict.search(pub);
|
||||
int pub_prefix_len = (int) m_codec.pub.length();
|
||||
|
||||
std::cout << "----" << std::endl;
|
||||
std::cout << "Found: " << pub.substr(result.pos, result.len) << std::endl;
|
||||
|
||||
std::cout << "Public: " << m_codec.pub;
|
||||
for(size_t i = pub_prefix_len; i < pub.length(); ) {
|
||||
|
||||
if (i == result.pos) {
|
||||
i += highlight(console::red, pub, result.pos, result.len);
|
||||
continue;
|
||||
}
|
||||
|
||||
auto p = dict_res.find(i);
|
||||
if (p != dict_res.end()) {
|
||||
i += highlight(console::blue, pub, p->first, p->second);
|
||||
continue;
|
||||
}
|
||||
|
||||
std::cout << pub[i++];
|
||||
}
|
||||
|
||||
std::cout << std::endl
|
||||
<< "Private: " << libantelope::wif_priv_encode(key->secret, m_codec.pvt) << std::endl;
|
||||
}
|
||||
|
||||
} // namespace antelopekeygen
|
||||
54
cli/src/cli_key_search_result.hpp
Normal file
54
cli/src/cli_key_search_result.hpp
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef EOSIOKEYGEN_KEY_SEARCH_HELPERS_H
|
||||
#define EOSIOKEYGEN_KEY_SEARCH_HELPERS_H
|
||||
|
||||
#include <string>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <libantelope/WIF.hpp>
|
||||
#include <eoskeygen/core/string.hpp>
|
||||
#include <eoskeygen/key_search.hpp>
|
||||
#include <eoskeygen/key_search_result.hpp>
|
||||
|
||||
namespace antelopekeygen {
|
||||
|
||||
class Dictionary;
|
||||
|
||||
class CliKeySearchResult : public IKeySearchResult
|
||||
{
|
||||
public:
|
||||
CliKeySearchResult(const Dictionary& dict, const libantelope::wif_codec_t& codec);
|
||||
|
||||
virtual void onResult(const struct libantelope::ec_keypair* key, const struct KeySearch::result& result);
|
||||
|
||||
protected :
|
||||
|
||||
const Dictionary& m_dict;
|
||||
|
||||
libantelope::wif_codec_t m_codec;
|
||||
};
|
||||
|
||||
} // namespace antelopekeygen
|
||||
|
||||
#endif /* EOSIOKEYGEN_KEY_SEARCH_HELPERS_H */
|
||||
48
cli/src/console.cpp
Normal file
48
cli/src/console.cpp
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <iostream>
|
||||
#include "isatty.hpp"
|
||||
#include "console.hpp"
|
||||
|
||||
namespace antelopekeygen { namespace console {
|
||||
|
||||
bool disable_color = false;
|
||||
|
||||
FILE* _getFileFromStream(const std::ostream& os) {
|
||||
|
||||
if (&os == &std::cout) {
|
||||
return stdout;
|
||||
} else if (&os == &std::cerr) {
|
||||
return stderr;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool isColorsSupported(const std::ostream& os) {
|
||||
|
||||
FILE* fd = _getFileFromStream(os);
|
||||
return disable_color == false && isatty(fd);
|
||||
}
|
||||
|
||||
} } // namespace antelopekeygen::console
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2020 EOS Sw/eden
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -21,39 +21,71 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
#include "base58.h"
|
||||
#include "checksum.h"
|
||||
#include "WIF.h"
|
||||
#ifndef EOSIOKEYGEN_CONSOLE_H
|
||||
#define EOSIOKEYGEN_CONSOLE_H
|
||||
|
||||
std::string wif_priv_encode(ec_privkey_t priv) {
|
||||
#include <ostream>
|
||||
|
||||
checksum_t check;
|
||||
unsigned char buf[37] = { 0x80 };
|
||||
namespace antelopekeygen {
|
||||
|
||||
memcpy(buf + 1, priv.data(), priv.size());
|
||||
namespace console {
|
||||
|
||||
// Checksum
|
||||
check = checksum_sha256d(buf, 33);
|
||||
memcpy(buf + 33, check.data(), check.size());
|
||||
extern bool disable_color;
|
||||
|
||||
return base58_encode(buf, buf + sizeof(buf));
|
||||
}
|
||||
// enum for all supported colors.
|
||||
enum Color {
|
||||
default_fg,
|
||||
black,
|
||||
white,
|
||||
red,
|
||||
green,
|
||||
blue,
|
||||
yellow,
|
||||
magenta,
|
||||
cyan,
|
||||
|
||||
std::string wif_pub_encode(ec_pubkey_t pub) {
|
||||
// Light colors.
|
||||
light_grey,
|
||||
light_red,
|
||||
light_green,
|
||||
light_blue,
|
||||
light_yellow,
|
||||
light_magenta,
|
||||
light_cyan,
|
||||
|
||||
checksum_t check = checksum_ripemd160(pub.data(), pub.size());
|
||||
unsigned char buf[37];
|
||||
// Dark colors
|
||||
dark_grey
|
||||
};
|
||||
|
||||
memcpy(buf, pub.data(), pub.size());
|
||||
memcpy(buf + 33, check.data(), check.size());
|
||||
enum Attribute {
|
||||
normal,
|
||||
bold,
|
||||
italic
|
||||
};
|
||||
|
||||
return "EOS" + base58_encode(buf, buf + sizeof(buf));
|
||||
}
|
||||
bool isColorsSupported(const std::ostream& os);
|
||||
|
||||
void wif_print_key(const struct ec_keypair *key) {
|
||||
// Resets all colors/attributes
|
||||
std::ostream& reset(std::ostream& os);
|
||||
|
||||
std::cout << "Private: " << wif_priv_encode(key->secret) << std::endl;
|
||||
std::cout << "Public: " << wif_pub_encode(key->pub) << std::endl;
|
||||
}
|
||||
// Foreground color
|
||||
// Defined as a class with overloaded "<<" operator so you can write:
|
||||
// std::cout << fg(red) << "Text";
|
||||
class fg
|
||||
{
|
||||
public:
|
||||
fg(Color color, Attribute attribute = normal)
|
||||
: _color(color), _attr(attribute) {}
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& os, const fg& obj);
|
||||
|
||||
protected :
|
||||
Color _color;
|
||||
Attribute _attr;
|
||||
};
|
||||
|
||||
} // namespace console
|
||||
|
||||
} // namespace antelopekeygen
|
||||
|
||||
#endif /* EOSIOKEYGEN_CONSOLE_H */
|
||||
83
cli/src/console_ansi.cpp
Normal file
83
cli/src/console_ansi.cpp
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <iostream>
|
||||
#include "console.hpp"
|
||||
|
||||
namespace antelopekeygen {
|
||||
|
||||
namespace console {
|
||||
|
||||
std::ostream& reset(std::ostream& os) {
|
||||
|
||||
if (!isColorsSupported(os)) {
|
||||
return os;
|
||||
}
|
||||
return os << "\033[0m";
|
||||
}
|
||||
|
||||
// Foreground
|
||||
std::ostream& operator<<(std::ostream& os, const fg& obj) {
|
||||
|
||||
int attr;
|
||||
int code;
|
||||
|
||||
if (!isColorsSupported(os)) {
|
||||
return os;
|
||||
}
|
||||
|
||||
switch(obj._color) {
|
||||
case black : code = 30; break;
|
||||
case red : code = 31; break;
|
||||
case green : code = 32; break;
|
||||
case yellow : code = 33; break;
|
||||
case blue : code = 34; break;
|
||||
case magenta : code = 35; break;
|
||||
case cyan : code = 36; break;
|
||||
case light_grey : code = 37; break;
|
||||
case dark_grey : code = 90; break;
|
||||
case light_red : code = 91; break;
|
||||
case light_green : code = 92; break;
|
||||
case light_yellow : code = 93; break;
|
||||
case light_blue : code = 94; break;
|
||||
case light_magenta : code = 95; break;
|
||||
case light_cyan : code = 96; break;
|
||||
case white : code = 97; break;
|
||||
case default_fg : default :
|
||||
code = 39;
|
||||
}
|
||||
|
||||
switch(obj._attr) {
|
||||
|
||||
case bold : attr = 1; break;
|
||||
case italic : attr = 2; break;
|
||||
case normal : default :
|
||||
attr = 0;
|
||||
}
|
||||
|
||||
return os << "\033[" << attr << ";" << code << "m";
|
||||
}
|
||||
|
||||
} // namespace console
|
||||
|
||||
} // namespace antelopekeygen
|
||||
108
cli/src/console_win32.cpp
Normal file
108
cli/src/console_win32.cpp
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <iostream>
|
||||
#include "console.hpp"
|
||||
|
||||
namespace antelopekeygen {
|
||||
|
||||
// WinAPI colors
|
||||
#define FG_BLACK 0
|
||||
#define FG_BLUE FOREGROUND_BLUE
|
||||
#define FG_GREEN FOREGROUND_GREEN
|
||||
#define FG_RED FOREGROUND_RED
|
||||
#define FG_CYAN (FOREGROUND_GREEN | FOREGROUND_BLUE)
|
||||
#define FG_YELLOW (FOREGROUND_RED | FOREGROUND_GREEN)
|
||||
#define FG_MAGENTA (FOREGROUND_RED | FOREGROUND_BLUE)
|
||||
#define FG_DARKGREY FOREGROUND_INTENSITY
|
||||
#define FG_GREY (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE)
|
||||
#define FG_LIGHTBLUE (FOREGROUND_INTENSITY | FOREGROUND_BLUE)
|
||||
#define FG_LIGHTGREEN (FOREGROUND_INTENSITY | FOREGROUND_GREEN)
|
||||
#define FG_LIGHTCYAN (FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE)
|
||||
#define FG_LIGHTRED (FOREGROUND_INTENSITY | FOREGROUND_RED)
|
||||
#define FG_LIGHTMAGENTA (FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE)
|
||||
#define FG_LIGHTYELLOW (FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN)
|
||||
#define FG_WHITE (FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE)
|
||||
#define FG_DEFAULT FG_GREY
|
||||
|
||||
namespace console {
|
||||
|
||||
HANDLE _getNativeHandle(const std::ostream& os) {
|
||||
|
||||
if (&os == &std::cout) {
|
||||
return ::GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
} else if (&os == &std::cerr) {
|
||||
return ::GetStdHandle(STD_ERROR_HANDLE);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::ostream& reset(std::ostream& os) {
|
||||
|
||||
if (isColorsSupported(os)) {
|
||||
::SetConsoleTextAttribute(_getNativeHandle(os), FG_DEFAULT);
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
// Foreground
|
||||
std::ostream& operator<<(std::ostream& os, const fg& obj) {
|
||||
|
||||
int code;
|
||||
|
||||
if (isColorsSupported(os)) {
|
||||
|
||||
switch(obj._color) {
|
||||
case black : code = FG_BLACK; break;
|
||||
case red : code = FG_RED; break;
|
||||
case green : code = FG_GREEN; break;
|
||||
case blue : code = FG_BLUE; break;
|
||||
case yellow : code = FG_YELLOW; break;
|
||||
case magenta : code = FG_MAGENTA; break;
|
||||
case cyan : code = FG_CYAN; break;
|
||||
case light_grey : code = FG_GREY; break;
|
||||
case light_red : code = FG_LIGHTRED; break;
|
||||
case light_green : code = FG_LIGHTGREEN; break;
|
||||
case light_yellow : code = FG_LIGHTYELLOW; break;
|
||||
case light_blue : code = FG_LIGHTBLUE; break;
|
||||
case light_magenta : code = FG_LIGHTMAGENTA; break;
|
||||
case light_cyan : code = FG_LIGHTCYAN; break;
|
||||
case dark_grey : code = FG_DARKGREY; break;
|
||||
case white : code = FG_WHITE; break;
|
||||
case default_fg : default :
|
||||
code = FG_DEFAULT;
|
||||
}
|
||||
|
||||
::SetConsoleTextAttribute(_getNativeHandle(os), code);
|
||||
}
|
||||
|
||||
// WinAPI does not support text attributes in the console.
|
||||
// so we ignore those.
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace console
|
||||
|
||||
} // namespace antelopekeygen
|
||||
45
cli/src/isatty.cpp
Normal file
45
cli/src/isatty.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#if _WIN32
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#define _isatty isatty
|
||||
#define _fileno fileno
|
||||
#endif
|
||||
#include "isatty.hpp"
|
||||
|
||||
namespace antelopekeygen {
|
||||
|
||||
bool isatty(int fd) {
|
||||
return ::_isatty(fd);
|
||||
}
|
||||
|
||||
bool isatty(FILE* fd) {
|
||||
// fileno() segfaults if fd is null.
|
||||
return fd ? isatty(_fileno(fd)) : false;
|
||||
}
|
||||
|
||||
} // namespace antelopekeygen
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2020 EOS Sw/eden
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -21,16 +21,17 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef WIF_H
|
||||
#define WIF_H
|
||||
#ifndef EOSIOKEYGEN_CORE_ISATTY_H
|
||||
#define EOSIOKEYGEN_CORE_ISATTY_H
|
||||
|
||||
#include <string>
|
||||
#include "ec.h"
|
||||
#include <stdio.h>
|
||||
|
||||
std::string wif_priv_encode(ec_privkey_t priv);
|
||||
namespace antelopekeygen {
|
||||
|
||||
std::string wif_pub_encode(ec_pubkey_t pub);
|
||||
bool isatty(int fd);
|
||||
|
||||
void wif_print_key(const struct ec_keypair *key);
|
||||
bool isatty(FILE* fd);
|
||||
|
||||
#endif /* WIF_H */
|
||||
} // namespace antelopekeygen
|
||||
|
||||
#endif /* EOSIOKEYGEN_CORE_ISATTY_H */
|
||||
247
cli/src/main.cpp
Normal file
247
cli/src/main.cpp
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <CLI11/CLI11.hpp>
|
||||
#include <libantelope/base58.hpp>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <libantelope/WIF.hpp>
|
||||
#include <eoskeygen/config.hpp>
|
||||
#include <eoskeygen/core/file.hpp>
|
||||
#include <eoskeygen/core/string.hpp>
|
||||
#include <eoskeygen/core/dictionary.hpp>
|
||||
#include <eoskeygen/core/leet.hpp>
|
||||
#include <eoskeygen/key_search.hpp>
|
||||
#include "cli_key_search_result.hpp"
|
||||
#include "console.hpp"
|
||||
#include "benchmark.hpp"
|
||||
#include "config.hpp"
|
||||
|
||||
// Command line options.
|
||||
bool option_l33t = false;
|
||||
libantelope::wif_codec_t key_codec;
|
||||
|
||||
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||
size_t option_num_threads;
|
||||
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||
|
||||
class CustomFormatter : public CLI::Formatter {
|
||||
public:
|
||||
|
||||
std::string make_usage(const CLI::App *app, std::string name) const
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
out << std::endl << CLI::Formatter::make_usage(app, name)
|
||||
<< std::endl
|
||||
<< "Outputs one EOSIO key pair if no subcommand is given"
|
||||
<< std::endl;
|
||||
|
||||
return out.str();
|
||||
}
|
||||
};
|
||||
|
||||
int cmd_search(const antelopekeygen::strlist_t& words, const antelopekeygen::Dictionary& dict, int count) {
|
||||
|
||||
antelopekeygen::KeySearch ks;
|
||||
antelopekeygen::CliKeySearchResult rs(dict, key_codec);
|
||||
|
||||
ks.setPrefix(key_codec.pub);
|
||||
ks.setCallback(&rs);
|
||||
|
||||
for(auto it = words.begin(); it != words.end(); it++) {
|
||||
size_t p = libantelope::is_base58(*it);
|
||||
if (p != std::string::npos) {
|
||||
std::cerr << "The word '"
|
||||
<< *it << "' contains an invalid non-base58 character '"
|
||||
<< (*it)[p] << "'" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (option_l33t) {
|
||||
for(std::size_t i = 0; i < words.size(); i++) {
|
||||
ks.addList(antelopekeygen::l33twords(words[i]));
|
||||
}
|
||||
} else {
|
||||
ks.addList(words);
|
||||
}
|
||||
|
||||
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||
ks.setThreadCount(option_num_threads);
|
||||
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||
|
||||
std::cout << "Searching for " << count
|
||||
<< " keys containing: " << antelopekeygen::strlist::join(ks.getList(), ",")
|
||||
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||
<< ", Using: " << ks.getThreadCount() << " threads"
|
||||
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||
<< std::endl;
|
||||
|
||||
ks.find(count);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cmd_benchmark(size_t num_keys) {
|
||||
|
||||
struct antelopekeygen::benchmark_result res;
|
||||
|
||||
std::cout << "Benchmark: Generating "
|
||||
<< num_keys << " keys" << std::endl;
|
||||
|
||||
antelopekeygen::benchmark(num_keys, &res);
|
||||
|
||||
std::cout << "Result: Took " << res.sec << " seconds, "
|
||||
<< res.kps << " keys per second." << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
CLI::App cmd("Keygenerator for Antelope based blockchains", PROGRAM_NAME);
|
||||
std::vector<std::string> dict_list;
|
||||
std::vector<std::string> lang_list;
|
||||
std::string search_words;
|
||||
std::string key_format;
|
||||
int search_count;
|
||||
size_t bench_count;
|
||||
int rc = 0;
|
||||
|
||||
libantelope::ec_init();
|
||||
|
||||
CLI::Option* version = cmd.add_flag("-v,--version", "Show version");
|
||||
cmd.add_option("--format", key_format, "valid values: K1, fio, legacy")->default_val("K1");
|
||||
|
||||
// Search
|
||||
CLI::App* search_cmd = cmd.add_subcommand("search",
|
||||
"performs a search, finding <count> public keys containing "
|
||||
"one or more words from <word_list> (separated with \",\")");
|
||||
CLI::Option* monocrome = search_cmd->add_flag("-m", "Monochrome, disables all color output.");
|
||||
|
||||
search_cmd->add_flag("--l33t", option_l33t, "Takes each word in <word_list> and find all l33tspeak"
|
||||
" combinations of that word and uses the new list for the search.");
|
||||
|
||||
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||
search_cmd->add_option("--threads", option_num_threads,
|
||||
"Use <num> of parallel threads for searching.\n"
|
||||
"Default is what the operating system recomends.")
|
||||
->default_val(antelopekeygen::KeySearch::max_threads());
|
||||
|
||||
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||
|
||||
search_cmd->add_option("--dict", dict_list, "");
|
||||
search_cmd->add_option("--lang", lang_list, "");
|
||||
search_cmd->add_option("word_list", search_words,
|
||||
"one or more words (separated with \",\")\n\n"
|
||||
"Instead of a list it is possible to specify a file with words\n"
|
||||
"(separated with newline '\\n') using file:<filename>")->required();
|
||||
search_cmd->add_option("count", search_count, "Number of keys to search for before the program terminates.")->default_val(10);
|
||||
|
||||
// Benchmark
|
||||
CLI::App* bench_cmd = cmd.add_subcommand("benchmark", "performs a benchmark test, "
|
||||
"generating <num> keys and measuring the time.");
|
||||
bench_cmd->add_option("count", bench_count, "")->default_val(1000);
|
||||
|
||||
// Parse command line.
|
||||
cmd.formatter(std::make_shared<CustomFormatter>());
|
||||
|
||||
CLI11_PARSE(cmd, argc, argv);
|
||||
|
||||
if (*version) {
|
||||
std::cout << PROGRAM_NAME << ": v" << PROGRAM_VERSION << std::endl;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (key_format == "fio") {
|
||||
key_codec = libantelope::wif_create_legacy_codec("FIO");
|
||||
} else if (key_format == "legacy") {
|
||||
key_codec = libantelope::WIF_CODEC_LEG;
|
||||
} else if (key_format == "K1") {
|
||||
key_codec = libantelope::WIF_CODEC_K1;
|
||||
} else {
|
||||
std::cerr << "invalid key format: " << key_format << std::endl;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (search_cmd->parsed()) {
|
||||
antelopekeygen::strlist_t words;
|
||||
antelopekeygen::Dictionary dict;
|
||||
|
||||
if (*monocrome) {
|
||||
antelopekeygen::console::disable_color = true;
|
||||
}
|
||||
|
||||
for (auto item : dict_list) {
|
||||
antelopekeygen::Dictionary d;
|
||||
|
||||
if (d.loadFromFile(item)) {
|
||||
dict.add(d);
|
||||
} else {
|
||||
std::cerr << "Could not load dictionary from file: " << item << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto item : lang_list) {
|
||||
antelopekeygen::Dictionary d;
|
||||
std::string filename(CONFIG_SHARE_FULL_PATH "/dicts/" + item);
|
||||
|
||||
if (d.loadFromFile(filename)) {
|
||||
dict.add(d);
|
||||
} else {
|
||||
std::cerr << "Could not load dictionary from language file: " << filename << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (search_words.rfind("file:", 0) == 0) {
|
||||
std::string filename = search_words.substr(5);
|
||||
if (!antelopekeygen::readLines(filename, words)) {
|
||||
std::cerr << "Could not read file: " << filename << std::endl;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (words.size() < 1) {
|
||||
std::cerr << filename << " did not contain any words" << std::endl;
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
words = antelopekeygen::strlist::splitw(search_words);
|
||||
}
|
||||
|
||||
rc = cmd_search(words, dict, search_count);
|
||||
goto end;
|
||||
|
||||
} else if (bench_cmd->parsed()) {
|
||||
cmd_benchmark(bench_count);
|
||||
}
|
||||
// No subcommand given, just generate and print a keypair.
|
||||
else {
|
||||
struct libantelope::ec_keypair pair;
|
||||
libantelope::ec_generate_key(&pair);
|
||||
libantelope::wif_print_key(&pair, key_codec);
|
||||
goto end;
|
||||
}
|
||||
|
||||
end: libantelope::ec_shutdown();
|
||||
return rc;
|
||||
}
|
||||
125
cmake/CPackConfig.cmake
Normal file
125
cmake/CPackConfig.cmake
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
# Custom script to setup cpack properly.
|
||||
|
||||
# --------------------------------
|
||||
# System variables
|
||||
# --------------------------------
|
||||
|
||||
# check CMAKE_SIZEOF_VOID_P to know if we are 32 or 64 bit.
|
||||
set( CPACK_SYSTEM_ARCH "x86" )
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set( CPACK_SYSTEM_ARCH "${CPACK_SYSTEM_ARCH}_64" )
|
||||
endif()
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
|
||||
# Set CPACK_SYSTEM_NAME, CPACK_SYSTEM_VERSION
|
||||
# and CPACK_DEBIAN_PACKAGE_ARCHITECTURE correctly for debian based systems.
|
||||
execute_process(COMMAND lsb_release -is OUTPUT_VARIABLE SYS OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if (SYS)
|
||||
string(TOLOWER "${SYS}" CPACK_SYSTEM_NAME )
|
||||
|
||||
# Set CPACK_SYSTEM_VERSION
|
||||
execute_process(COMMAND lsb_release -rs OUTPUT_VARIABLE SYS_VER OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if (SYS_VER)
|
||||
set( CPACK_SYSTEM_VERSION ${SYS_VER} )
|
||||
endif(SYS_VER)
|
||||
|
||||
# Try setting CPACK_DEBIAN_PACKAGE_ARCHITECTURE based on dpkg
|
||||
if (NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
|
||||
execute_process(
|
||||
COMMAND dpkg --print-architecture
|
||||
OUTPUT_VARIABLE ARCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
if (ARCH)
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${ARCH})
|
||||
endif()
|
||||
endif()
|
||||
endif(SYS)
|
||||
|
||||
|
||||
# set CPACK_DEBIAN_PACKAGE_ARCHITECTURE to somthing sane by default.
|
||||
if (NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
|
||||
|
||||
# debian uses different names for 32/64 bit.
|
||||
if (CPACK_SYSTEM_ARCH STREQUAL "x86")
|
||||
set( ARCH "i386" )
|
||||
else()
|
||||
set( ARCH "amd64" )
|
||||
endif()
|
||||
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${ARCH})
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
# CPACK_SYSTEM_NAME defaults are weird. so we set good default here.
|
||||
if (NOT CPACK_SYSTEM_NAME)
|
||||
set (CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
|
||||
endif()
|
||||
|
||||
# CPACK_SYSTEM_VERSION does not exist in original CPack. so we set a default here.
|
||||
if (NOT CPACK_SYSTEM_VERSION)
|
||||
set (CPACK_SYSTEM_VERSION ${CMAKE_SYSTEM_VERSION})
|
||||
endif()
|
||||
|
||||
|
||||
# --------------------------------
|
||||
# Package variables
|
||||
# --------------------------------
|
||||
|
||||
|
||||
# Forward some variables not handled by CPack.
|
||||
if (NOT CPACK_PACKAGE_CONTACT AND PROJECT_MAINTAINER)
|
||||
set( CPACK_PACKAGE_CONTACT ${PROJECT_MAINTAINER} )
|
||||
endif()
|
||||
|
||||
# Set "correct" filename that also include system version.
|
||||
if (CPACK_SYSTEM_VERSION)
|
||||
set( CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}_${CPACK_SYSTEM_NAME}-${CPACK_SYSTEM_VERSION}_${CPACK_SYSTEM_ARCH}" )
|
||||
else()
|
||||
set( CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}_${CPACK_SYSTEM_NAME}_${CPACK_SYSTEM_ARCH}" )
|
||||
endif()
|
||||
|
||||
|
||||
# .deb specific
|
||||
|
||||
# Set release version default 1.
|
||||
set( CPACK_DEBIAN_PACKAGE_RELEASE "1" CACHE STRING "Debian package release version" )
|
||||
|
||||
# For some reason CPackDeb does not honor CPACK_PACKAGE_HOMEPAGE_URL (that is set correctly)
|
||||
# if CPACK_DEBIAN_PACKAGE_HOMEPAGE (that the docs says it should.)
|
||||
# So we have to do it here.
|
||||
set( CPACK_DEBIAN_PACKAGE_HOMEPAGE "${PROJECT_HOMEPAGE_URL}" )
|
||||
|
||||
# Always build components for deb packages
|
||||
set( CPACK_DEB_COMPONENT_INSTALL ON )
|
||||
|
||||
|
||||
# RPM
|
||||
|
||||
# Always build components for rpm packages
|
||||
set( CPACK_RPM_COMPONENT_INSTALL ON )
|
||||
|
||||
# Same as with DEB package.
|
||||
set( CPACK_RPM_PACKAGE_HOMEPAGE "${PROJECT_HOMEPAGE_URL}" )
|
||||
|
||||
set( CPACK_RPM_PACKAGE_RELEASE_DIST ON )
|
||||
set( CPACK_RPM_PACKAGE_RELEASE "1" CACHE STRING "RPM package release version" )
|
||||
set( CPACK_RPM_PACKAGE_LICENSE "MIT" )
|
||||
set( CPACK_RPM_FILE_NAME "RPM-DEFAULT" )
|
||||
|
||||
# --------------------------------
|
||||
# Generator default
|
||||
# --------------------------------
|
||||
|
||||
|
||||
# Default to gzip tar on unix. zip otherwise.
|
||||
if (NOT CPACK_GENERATOR)
|
||||
if (UNIX)
|
||||
set( CPACK_GENERATOR "TGZ" )
|
||||
else()
|
||||
set( CPACK_GENERATOR "ZIP" )
|
||||
endif()
|
||||
endif()
|
||||
7
cmake/CPackProperties.cmake.in
Normal file
7
cmake/CPackProperties.cmake.in
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
# Include component specific config
|
||||
foreach( component @CPACK_COMPONENTS_ALL@ )
|
||||
if (EXISTS "@CMAKE_CURRENT_BINARY_DIR@/${component}/CPackProperties.cmake")
|
||||
include("@CMAKE_CURRENT_BINARY_DIR@/${component}/CPackProperties.cmake")
|
||||
endif()
|
||||
endforeach()
|
||||
43
cmake/extras.cmake
Normal file
43
cmake/extras.cmake
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
set( EXTRAS_DIRECTORY ${DOWNLOAD_CACHE_DIR}/eosio-keygen-extras-0.1.0 )
|
||||
set( FILENAME ${DOWNLOAD_CACHE_DIR}/eosio-keygen-extras-0.1.0.zip )
|
||||
|
||||
# --------------------------------
|
||||
# Download/Unpack
|
||||
# --------------------------------
|
||||
|
||||
if (NOT EXISTS ${FILENAME})
|
||||
|
||||
set( URL "https://github.com/eosswedenorg/eosio-keygen-extras/releases/download/v0.1.0/eosio-keygen-extras-0.1.0.zip" )
|
||||
set( CHECKSUM "7be3188a52a39876e37986e6a7d78e0d6c89e68e8391cf48821c800563aaa036" )
|
||||
|
||||
message( STATUS "Downloading ${URL}" )
|
||||
|
||||
file(DOWNLOAD ${URL} ${FILENAME}
|
||||
TIMEOUT 60
|
||||
EXPECTED_HASH SHA256=${CHECKSUM}
|
||||
TLS_VERIFY ON)
|
||||
endif()
|
||||
|
||||
if (NOT EXISTS ${EXTRAS_DIRECTORY})
|
||||
|
||||
message( STATUS "Unpacking ${FILENAME}" )
|
||||
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xf ${FILENAME}
|
||||
WORKING_DIRECTORY ${DOWNLOAD_CACHE_DIR})
|
||||
endif()
|
||||
|
||||
|
||||
# --------------------------------
|
||||
# Install
|
||||
# --------------------------------
|
||||
|
||||
install(DIRECTORY ${EXTRAS_DIRECTORY}/dict
|
||||
DESTINATION ${CMAKE_INSTALL_SHAREDIR}
|
||||
COMPONENT extras )
|
||||
|
||||
# --------------------------------
|
||||
# CPack
|
||||
# --------------------------------
|
||||
|
||||
set( CPACK_COMPONENT_EXTRAS_DESCRIPTION "Dictionary files" )
|
||||
1
common/.gitignore
vendored
Normal file
1
common/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
include/eoskeygen/config.h*
|
||||
49
common/CMakeLists.txt
Normal file
49
common/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# ------------------------------------------------------------
|
||||
# Common CMake file
|
||||
#
|
||||
# Compiles the code that should be shared between the cli
|
||||
# and gui programs into a static library.
|
||||
# ------------------------------------------------------------
|
||||
|
||||
# Options
|
||||
option(USE_THREADS "Compile with support for threads (if available)." ON)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
|
||||
# --------------------------------
|
||||
# Library
|
||||
# --------------------------------
|
||||
set( COMMON_NAME common )
|
||||
|
||||
set( COMMON_SOURCE
|
||||
src/core/file.cpp
|
||||
src/core/dictionary.cpp
|
||||
src/core/string.cpp
|
||||
src/core/strlist.cpp
|
||||
src/core/leet.cpp
|
||||
src/key_search.cpp
|
||||
)
|
||||
|
||||
# Threads support
|
||||
if (USE_THREADS)
|
||||
find_package(Threads)
|
||||
if (Threads_FOUND)
|
||||
set( ANTELOPEKEYGEN_HAVE_THREADS TRUE )
|
||||
set( COMMON_SOURCE ${COMMON_SOURCE} src/key_search_mt.cpp )
|
||||
endif (Threads_FOUND)
|
||||
endif (USE_THREADS)
|
||||
|
||||
# Project config file
|
||||
configure_file(config.hpp.in "${CMAKE_CURRENT_LIST_DIR}/include/eoskeygen/config.hpp" @ONLY)
|
||||
|
||||
add_library( ${COMMON_NAME} STATIC ${COMMON_SOURCE} )
|
||||
|
||||
target_include_directories( ${COMMON_NAME} PUBLIC include )
|
||||
|
||||
# Link with libantelope and threads library.
|
||||
include( libantelope )
|
||||
target_link_libraries( ${COMMON_NAME}
|
||||
PUBLIC
|
||||
libantelope
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
)
|
||||
53
common/cmake/libantelope.cmake
Normal file
53
common/cmake/libantelope.cmake
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# --------------------------------
|
||||
# Variables
|
||||
# --------------------------------
|
||||
set( LIBANTELOPE_GIT_URL "https://github.com/eosswedenorg/libantelope.git" )
|
||||
set( LIBANTELOPE_WANTED_VERSION v0.2.2 )
|
||||
|
||||
# --------------------------------
|
||||
# Macros
|
||||
# --------------------------------
|
||||
macro(fromGit tag)
|
||||
|
||||
message ("Using libantelope from: ${LIBANTELOPE_GIT_URL}@${tag}")
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(libantelope
|
||||
GIT_REPOSITORY ${LIBANTELOPE_GIT_URL}
|
||||
GIT_TAG ${tag}
|
||||
SOURCE_DIR ${DOWNLOAD_CACHE_DIR}/libeosio/src
|
||||
STAMP_DIR ${DOWNLOAD_CACHE_DIR}/libeosio/stamp
|
||||
)
|
||||
|
||||
FetchContent_GetProperties(libantelope)
|
||||
if (NOT libantelope_POPULATED)
|
||||
FetchContent_Populate(libantelope)
|
||||
add_subdirectory(${libantelope_SOURCE_DIR} ${libantelope_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(buildLocal src)
|
||||
message ("Using local libantelope at: ${src}")
|
||||
add_subdirectory(${src} ${src}/build EXCLUDE_FROM_ALL)
|
||||
endmacro()
|
||||
|
||||
# If we have a local libantelope
|
||||
if (LIBANTELOPE_SOURCE_DIR)
|
||||
buildLocal( ${LIBANTELOPE_SOURCE_DIR} )
|
||||
else()
|
||||
|
||||
# Check if version is in fact a version.
|
||||
if (LIBANTELOPE_WANTED_VERSION MATCHES "^[0-9]+(.[0-9]+)?(.[0-9]+)(-[a-zA-Z0-9]+)?$")
|
||||
# Try finding the package on the system.
|
||||
find_package(libantelope ${LIBANTELOPE_WANTED_VERSION} QUIET)
|
||||
if (libantelope_FOUND)
|
||||
message ("Using libeosio in: ${libantelope_DIR}")
|
||||
# Not found, download from git.
|
||||
else()
|
||||
fromGit( v${LIBANTELOPE_WANTED_VERSION} )
|
||||
endif()
|
||||
# Assume version contains a git branch.
|
||||
else()
|
||||
fromGit( ${LIBANTELOPE_WANTED_VERSION} )
|
||||
endif()
|
||||
endif()
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2020 EOS Sw/eden
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -21,10 +21,10 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
#ifndef ANTELOPEKEYGEN_COMMON_CONFIG_H
|
||||
#define ANTELOPEKEYGEN_COMMON_CONFIG_H
|
||||
|
||||
#define EC_PRIVKEY_SIZE 32
|
||||
#define EC_PUBKEY_SIZE 33 /* Compressed: 32 bytes + 1 prefix */
|
||||
// Defined if we have thread support.
|
||||
#cmakedefine ANTELOPEKEYGEN_HAVE_THREADS
|
||||
|
||||
#endif /* TYPES_H */
|
||||
#endif /* ANTELOPEKEYGEN_COMMON_CONFIG_H */
|
||||
75
common/include/eoskeygen/core/dictionary.hpp
Normal file
75
common/include/eoskeygen/core/dictionary.hpp
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef ANTELOPEKEYGEN_COMMON_CORE_DICTIONARY_H
|
||||
#define ANTELOPEKEYGEN_COMMON_CORE_DICTIONARY_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
namespace antelopekeygen {
|
||||
|
||||
class Dictionary
|
||||
{
|
||||
public :
|
||||
// Map that contains position and length for substrings.
|
||||
//
|
||||
// key = position in the search string.
|
||||
// value = length of the word from this position.
|
||||
typedef std::map< size_t, size_t > search_result_t;
|
||||
|
||||
public :
|
||||
|
||||
// Load words from file.
|
||||
bool loadFromFile(const std::string& filename);
|
||||
|
||||
// Add a word to the dictionary.
|
||||
void add(const std::string& word);
|
||||
|
||||
// Add words from another dictionary.
|
||||
void add(const Dictionary& dictionary);
|
||||
|
||||
// Clear all words from the dictionary.
|
||||
void clear();
|
||||
|
||||
// Returns the list of words in the dictionary.
|
||||
const std::set<std::string>& getWords() const;
|
||||
|
||||
// Returns true if word exists in the dictionary.
|
||||
bool contains(const std::string& word) const;
|
||||
|
||||
// Searches the subject for words defined in the dictionary.
|
||||
// Returns a search_result_t with the words found in subject.
|
||||
// See search_result_t for more details.
|
||||
search_result_t search(const std::string& subject) const;
|
||||
|
||||
protected :
|
||||
|
||||
// Words in the dictionary.
|
||||
std::set<std::string> m_words;
|
||||
};
|
||||
|
||||
} // namespace antelopekeygen
|
||||
|
||||
#endif /* ANTELOPEKEYGEN_COMMON_CORE_DICTIONARY_H */
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2020 EOS Sw/eden
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -21,15 +21,15 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef CHECKSUM_H
|
||||
#define CHECKSUM_H
|
||||
#ifndef ANTELOPEKEYGEN_COMMON_CORE_FILE_H
|
||||
#define ANTELOPEKEYGEN_COMMON_CORE_FILE_H
|
||||
|
||||
#include <array>
|
||||
#include <eoskeygen/core/strlist.hpp>
|
||||
|
||||
typedef std::array<unsigned char, 4> checksum_t;
|
||||
namespace antelopekeygen {
|
||||
|
||||
checksum_t checksum_sha256d(const unsigned char *data, unsigned int len);
|
||||
bool readLines(const std::string& filename, strlist_t& lines);
|
||||
|
||||
checksum_t checksum_ripemd160(const unsigned char *data, unsigned int len);
|
||||
} // namespace
|
||||
|
||||
#endif /* CHECKSUM_H */
|
||||
#endif /* ANTELOPEKEYGEN_COMMON_CORE_FILE_H */
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2020 EOS Sw/eden
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -21,14 +21,16 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef BASE58_H
|
||||
#define BASE58_H
|
||||
#ifndef ANTELOPEKEYGEN_COMMON_CORE_LEET_H
|
||||
#define ANTELOPEKEYGEN_COMMON_CORE_LEET_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <eoskeygen/core/strlist.hpp>
|
||||
|
||||
std::string base58_encode(const std::string& str);
|
||||
std::string base58_encode(const std::vector<unsigned char>& vch);
|
||||
std::string base58_encode(const unsigned char* pbegin, const unsigned char* pend);
|
||||
namespace antelopekeygen {
|
||||
|
||||
#endif /* BASE58_H */
|
||||
strlist_t l33twords(std::string str);
|
||||
|
||||
} // namespace antelopekeygen
|
||||
|
||||
#endif /* ANTELOPEKEYGEN_COMMON_CORE_LEET_H */
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2020 EOS Sw/eden
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -21,17 +21,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef STRING_H
|
||||
#define STRING_H
|
||||
#ifndef ANTELOPEKEYGEN_COMMON_CORE_STRING_H
|
||||
#define ANTELOPEKEYGEN_COMMON_CORE_STRING_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
typedef std::vector<std::string> strlist_t;
|
||||
|
||||
strlist_t strsplitwords(const std::string& str, const std::string& delim = ",");
|
||||
|
||||
strlist_t strsplit(const std::string& str, const std::string& delim);
|
||||
namespace antelopekeygen {
|
||||
|
||||
std::string& strtolower(std::string& str);
|
||||
|
||||
|
|
@ -39,4 +35,6 @@ std::string& rtrim(std::string& str);
|
|||
std::string& ltrim(std::string& str);
|
||||
std::string& trim(std::string& str);
|
||||
|
||||
#endif /* STRING_H */
|
||||
} // namespace antelopekeygen
|
||||
|
||||
#endif /* ANTELOPEKEYGEN_COMMON_CORE_STRING_H */
|
||||
50
common/include/eoskeygen/core/strlist.hpp
Normal file
50
common/include/eoskeygen/core/strlist.hpp
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef ANTELOPEKEYGEN_COMMON_CORE_STRLIST_H
|
||||
#define ANTELOPEKEYGEN_COMMON_CORE_STRLIST_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace antelopekeygen {
|
||||
|
||||
typedef std::vector<std::string> strlist_t;
|
||||
|
||||
typedef std::string& (*strlist_stripfunc_t)(std::string& str);
|
||||
|
||||
namespace strlist {
|
||||
|
||||
strlist_t splitw(const std::string& str, const std::string& delim = ",");
|
||||
|
||||
strlist_t split(const std::string& str, const std::string& delim);
|
||||
|
||||
std::string join(const strlist_t& list, const std::string& delim);
|
||||
|
||||
strlist_t& strip(strlist_t& list, strlist_stripfunc_t fn);
|
||||
|
||||
} // namespace strlist
|
||||
|
||||
} // namespace antelopekeygen
|
||||
|
||||
#endif /* ANTELOPEKEYGEN_COMMON_CORE_STRLIST_H */
|
||||
125
common/include/eoskeygen/key_search.hpp
Normal file
125
common/include/eoskeygen/key_search.hpp
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef ANTELOPEKEYGEN_COMMON_KEY_SEARCH_H
|
||||
#define ANTELOPEKEYGEN_COMMON_KEY_SEARCH_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <eoskeygen/config.hpp>
|
||||
#include <eoskeygen/core/dictionary.hpp>
|
||||
#include <eoskeygen/core/strlist.hpp>
|
||||
|
||||
namespace antelopekeygen {
|
||||
|
||||
class IKeySearchResult;
|
||||
|
||||
class KeySearch
|
||||
{
|
||||
public :
|
||||
|
||||
struct result {
|
||||
size_t pos; // position where the word was found.
|
||||
size_t len; // the length of the word.
|
||||
};
|
||||
|
||||
public :
|
||||
KeySearch();
|
||||
|
||||
void setPrefix(const std::string& prefix);
|
||||
|
||||
// Add a word to search for.
|
||||
void addWord(const std::string& str);
|
||||
|
||||
// Add a list of words to search for.
|
||||
void addList(const strlist_t& list);
|
||||
|
||||
// get the list of words to search for.
|
||||
const strlist_t& getList();
|
||||
|
||||
// Clears the search list.
|
||||
void clear();
|
||||
|
||||
// Set callback for search result.
|
||||
void setCallback(IKeySearchResult* callback);
|
||||
|
||||
#ifdef ANTELOPEKEYGEN_HAVE_THREADS
|
||||
// Returns the maximum number of threads
|
||||
// reported by the operating system.
|
||||
static size_t max_threads();
|
||||
|
||||
// Set the number of threads to use while searching.
|
||||
void setThreadCount(size_t num);
|
||||
|
||||
size_t getThreadCount() const;
|
||||
#endif /* ANTELOPEKEYGEN_HAVE_THREADS */
|
||||
|
||||
// Aborts find() operation if started.
|
||||
// This is useful for multithreaded code (like GUI application)
|
||||
// If find() is started as a seperate thread. This method could be called
|
||||
// from the gui thread if the user presses "cancel" button.
|
||||
void abort();
|
||||
|
||||
// Perform a search.
|
||||
void find(size_t num_results);
|
||||
|
||||
protected :
|
||||
|
||||
// Check if any word in <word_list> appears in <key>'s public key.
|
||||
// returns true if a word was found (stored in <result>), false otherwise.
|
||||
bool _contains_word(const struct libantelope::ec_keypair* key, struct result& result);
|
||||
|
||||
#ifdef ANTELOPEKEYGEN_HAVE_THREADS
|
||||
void _thr_proc();
|
||||
|
||||
void _search_mt();
|
||||
#endif /* ANTELOPEKEYGEN_HAVE_THREADS */
|
||||
|
||||
void _search_linear();
|
||||
|
||||
protected :
|
||||
|
||||
// Public key prefix.
|
||||
std::string m_prefix;
|
||||
|
||||
// List of words to search for.
|
||||
strlist_t m_words;
|
||||
|
||||
// Max keys to search for.
|
||||
std::size_t m_max;
|
||||
|
||||
// Current number of keys found.
|
||||
std::size_t m_count;
|
||||
|
||||
#ifdef ANTELOPEKEYGEN_HAVE_THREADS
|
||||
// Number of threads to use.
|
||||
size_t m_threads;
|
||||
#endif /* ANTELOPEKEYGEN_HAVE_THREADS */
|
||||
|
||||
IKeySearchResult* m_callback;
|
||||
};
|
||||
|
||||
} // namespace antelopekeygen
|
||||
|
||||
#endif /* ANTELOPEKEYGEN_COMMON_KEY_SEARCH_H */
|
||||
40
common/include/eoskeygen/key_search_result.hpp
Normal file
40
common/include/eoskeygen/key_search_result.hpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef ANTELOPEKEYGEN_COMMON_KEY_SEARCH_RESULT_H
|
||||
#define ANTELOPEKEYGEN_COMMON_KEY_SEARCH_RESULT_H
|
||||
|
||||
#include <eoskeygen/key_search.hpp>
|
||||
|
||||
namespace antelopekeygen {
|
||||
|
||||
class IKeySearchResult
|
||||
{
|
||||
public :
|
||||
|
||||
virtual void onResult(const struct libantelope::ec_keypair* key, const struct KeySearch::result& result) = 0;
|
||||
};
|
||||
|
||||
} // namespace antelopekeygen
|
||||
|
||||
#endif /* ANTELOPEKEYGEN_COMMON_KEY_SEARCH_RESULT_H */
|
||||
129
common/src/core/dictionary.cpp
Normal file
129
common/src/core/dictionary.cpp
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <vector>
|
||||
#include <cstdio>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <eoskeygen/core/string.hpp>
|
||||
#include <eoskeygen/core/dictionary.hpp>
|
||||
#include <eoskeygen/core/file.hpp>
|
||||
|
||||
namespace antelopekeygen {
|
||||
|
||||
struct StringContains {
|
||||
StringContains(const std::string& str, std::vector<size_t>& pos) : m_str(str), m_pos(pos) {}
|
||||
bool operator()(const std::string& w) {
|
||||
for(size_t p = m_str.find(w); p != std::string::npos; p = m_str.find(w, p+1)) {
|
||||
m_pos.push_back(p);
|
||||
}
|
||||
return !m_pos.empty();
|
||||
}
|
||||
std::string m_str;
|
||||
std::vector<size_t>& m_pos;
|
||||
};
|
||||
|
||||
bool Dictionary::loadFromFile(const std::string& filename)
|
||||
{
|
||||
strlist_t lines;
|
||||
|
||||
// Clear before adding.
|
||||
clear();
|
||||
|
||||
if (readLines(filename, lines)) {
|
||||
|
||||
// Read each line and add to the dictionary.
|
||||
for(auto it = lines.begin(); it != lines.end(); it++) {
|
||||
add(*it);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Dictionary::add(const std::string& word)
|
||||
{
|
||||
// Do not insert a empty string.
|
||||
if (word.length()) {
|
||||
m_words.insert(word);
|
||||
}
|
||||
}
|
||||
|
||||
void Dictionary::add(const Dictionary& dictionary)
|
||||
{
|
||||
std::set_union(
|
||||
m_words.begin(), m_words.end(),
|
||||
dictionary.m_words.begin(), dictionary.m_words.end(),
|
||||
std::inserter(m_words, m_words.begin())
|
||||
);
|
||||
}
|
||||
|
||||
const std::set<std::string>& Dictionary::getWords() const
|
||||
{
|
||||
return m_words;
|
||||
}
|
||||
|
||||
void Dictionary::clear()
|
||||
{
|
||||
m_words.clear();
|
||||
}
|
||||
|
||||
bool Dictionary::contains(const std::string& word) const
|
||||
{
|
||||
return m_words.find(word) != m_words.cend();
|
||||
}
|
||||
|
||||
Dictionary::search_result_t Dictionary::search(const std::string& subject) const
|
||||
{
|
||||
search_result_t res;
|
||||
|
||||
std::vector<size_t> pos;
|
||||
StringContains pred(subject, pos);
|
||||
|
||||
// Find all words.
|
||||
for(auto it = std::find_if(m_words.begin(), m_words.end(), pred);
|
||||
it != m_words.end();
|
||||
it = std::find_if(++it, m_words.end(), pred)) {
|
||||
|
||||
// Go through all found positions.
|
||||
for (auto it2 = pos.begin(); it2 != pos.end(); it2++) {
|
||||
|
||||
// Insert
|
||||
auto rit = res.find(*it2);
|
||||
if (rit == res.end()) {
|
||||
res.emplace(*it2, it->length());
|
||||
}
|
||||
// Update length if it's longer then the previous we found.
|
||||
else if (rit->second < it->length()) {
|
||||
rit->second = it->length();
|
||||
}
|
||||
}
|
||||
|
||||
// Clear positions
|
||||
pos.clear();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
} // namespace antelopekeygen
|
||||
49
common/src/core/file.cpp
Normal file
49
common/src/core/file.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <cstdio>
|
||||
#include <eoskeygen/core/string.hpp>
|
||||
#include <eoskeygen/core/file.hpp>
|
||||
|
||||
namespace antelopekeygen {
|
||||
|
||||
bool readLines(const std::string& filename, strlist_t& lines) {
|
||||
|
||||
FILE *fd;
|
||||
char buf[1024];
|
||||
|
||||
fd = fopen(filename.c_str(), "r");
|
||||
if (!fd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while(fgets(buf, sizeof(buf), fd) != NULL) {
|
||||
std::string line(buf);
|
||||
lines.push_back(trim(line));
|
||||
}
|
||||
|
||||
fclose(fd);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace antelopekeygen
|
||||
82
common/src/core/leet.cpp
Normal file
82
common/src/core/leet.cpp
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <algorithm>
|
||||
#include <eoskeygen/core/leet.hpp>
|
||||
|
||||
namespace antelopekeygen {
|
||||
|
||||
static bool is_l33t(char ch, char& r) {
|
||||
|
||||
// '1', '2', '3', '4', '5', '6', '7', '8', '9'
|
||||
static char alphabet[9] = { 'l', 'z', 'e', 'a', 's', 'G', 't', 'B', 'g' };
|
||||
|
||||
for(std::size_t i = 0; i < sizeof(alphabet) / sizeof(char); i++) {
|
||||
|
||||
if (ch == alphabet[i]) {
|
||||
r = static_cast<char>('1' + i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void _l33t(strlist_t& list, const std::string& a, std::size_t pos) {
|
||||
|
||||
// Find the next character to be replaced.
|
||||
for(std::size_t i = pos; i < a.length(); i++) {
|
||||
|
||||
char ch;
|
||||
if (is_l33t(a[i], ch)) {
|
||||
// create a new string and replace the character.
|
||||
std::string b = a;
|
||||
b[i] = ch;
|
||||
|
||||
// Store the new string as the result.
|
||||
list.push_back(b);
|
||||
|
||||
// Perform the same algorithm for both strings
|
||||
// at the next position.
|
||||
_l33t(list, a, i + 1);
|
||||
_l33t(list, b, i + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
strlist_t l33twords(std::string str) {
|
||||
|
||||
strlist_t list;
|
||||
|
||||
// "l" is abit special and are not included in base58 so we set it to 1.
|
||||
// All other characters in "l33t" are valid.
|
||||
std::transform(str.begin(), str.end(), str.begin(), [](char c){ return c == 'l' ? '1' : c; });
|
||||
|
||||
// Store the original string as the first in list.
|
||||
list.push_back(str);
|
||||
|
||||
_l33t(list, str, 0);
|
||||
return list;
|
||||
}
|
||||
|
||||
} // namespace antelopekeygen
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2020 EOS Sw/eden
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -21,30 +21,12 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cctype>
|
||||
#include "string.h"
|
||||
#include <algorithm>
|
||||
#include <eoskeygen/core/string.hpp>
|
||||
|
||||
strlist_t strsplitwords(const std::string& str, const std::string& delim) {
|
||||
|
||||
strlist_t words = strsplit(str, delim);
|
||||
std::for_each(words.begin(), words.end(), trim);
|
||||
return words;
|
||||
}
|
||||
|
||||
strlist_t strsplit(const std::string& str, const std::string& delim) {
|
||||
|
||||
strlist_t r;
|
||||
size_t s = 0, e = 0, dlen = delim.length();
|
||||
|
||||
while((e = str.find(delim, s)) != std::string::npos) {
|
||||
r.push_back(str.substr(s, e - s));
|
||||
s = e + dlen;
|
||||
}
|
||||
|
||||
r.push_back(str.substr(s));
|
||||
return r;
|
||||
}
|
||||
namespace antelopekeygen {
|
||||
|
||||
std::string& strtolower(std::string& str) {
|
||||
std::transform(str.begin(), str.end(), str.begin(), [](unsigned char c){ return std::tolower(c); });
|
||||
|
|
@ -66,3 +48,5 @@ std::string& rtrim(std::string& str) {
|
|||
std::string& trim(std::string& str) {
|
||||
return ltrim(rtrim(str));
|
||||
}
|
||||
|
||||
} // namespace antelopekeygen
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2020 EOS Sw/eden
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -21,51 +21,55 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <openssl/ec.h>
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/hmac.h>
|
||||
#include "ec.h"
|
||||
#include <algorithm>
|
||||
#include <eoskeygen/core/string.hpp>
|
||||
#include <eoskeygen/core/strlist.hpp>
|
||||
|
||||
static int ec_generate_pair(unsigned char *priv, unsigned char *pub) {
|
||||
namespace antelopekeygen {
|
||||
|
||||
int ret = -1;
|
||||
EC_KEY *k;
|
||||
BN_CTX *ctx;
|
||||
strlist_t strlist::splitw(const std::string& str, const std::string& delim) {
|
||||
|
||||
// Create BIGNUM context.
|
||||
ctx = BN_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Construct curve.
|
||||
k = EC_KEY_new_by_curve_name(NID_secp256k1);
|
||||
if (k == NULL) {
|
||||
goto fail1;
|
||||
}
|
||||
|
||||
// Generate new key pair.
|
||||
if (EC_KEY_generate_key(k) != 1) {
|
||||
goto fail2;
|
||||
}
|
||||
|
||||
// Copy private key to binary format.
|
||||
EC_KEY_priv2oct(k, priv, EC_PRIVKEY_SIZE);
|
||||
|
||||
// Copy public key key
|
||||
EC_POINT_point2oct(EC_KEY_get0_group(k),
|
||||
EC_KEY_get0_public_key(k), POINT_CONVERSION_COMPRESSED,
|
||||
pub, EC_PUBKEY_SIZE, ctx);
|
||||
|
||||
ret = 0;
|
||||
fail2:
|
||||
EC_KEY_free(k);
|
||||
fail1:
|
||||
BN_CTX_free(ctx);
|
||||
return ret;
|
||||
strlist_t words = strlist::split(str, delim);
|
||||
std::for_each(words.begin(), words.end(), trim);
|
||||
return words;
|
||||
}
|
||||
|
||||
int ec_generate_key(struct ec_keypair *pair) {
|
||||
strlist_t strlist::split(const std::string& str, const std::string& delim) {
|
||||
|
||||
return ec_generate_pair(pair->secret.data(), pair->pub.data());
|
||||
strlist_t r;
|
||||
size_t s = 0, e = 0, dlen = delim.length();
|
||||
|
||||
while((e = str.find(delim, s)) != std::string::npos) {
|
||||
r.push_back(str.substr(s, e - s));
|
||||
s = e + dlen;
|
||||
}
|
||||
|
||||
r.push_back(str.substr(s));
|
||||
return r;
|
||||
}
|
||||
|
||||
std::string strlist::join(const strlist_t& list, const std::string& delim) {
|
||||
|
||||
std::string out;
|
||||
|
||||
for(const std::string& item : list) {
|
||||
if (item.length() < 1) {
|
||||
continue;
|
||||
}
|
||||
out += item + delim;
|
||||
}
|
||||
|
||||
if (out.length() > 0) {
|
||||
out.erase(out.end() - delim.length());
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
strlist_t& strlist::strip(strlist_t& list, strlist_stripfunc_t fn) {
|
||||
|
||||
std::transform(list.begin(), list.end(), list.begin(), fn);
|
||||
return list;
|
||||
}
|
||||
|
||||
} // namespace antelopekeygen
|
||||
131
common/src/key_search.cpp
Normal file
131
common/src/key_search.cpp
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <libantelope/WIF.hpp>
|
||||
#include <eoskeygen/config.hpp>
|
||||
#include <eoskeygen/core/string.hpp>
|
||||
#include <eoskeygen/key_search_result.hpp>
|
||||
#include <eoskeygen/key_search.hpp>
|
||||
|
||||
namespace antelopekeygen {
|
||||
|
||||
KeySearch::KeySearch() :
|
||||
m_prefix ("EOS"),
|
||||
m_max (0),
|
||||
m_count (0),
|
||||
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||
m_threads (0),
|
||||
#endif
|
||||
m_callback (NULL)
|
||||
{
|
||||
}
|
||||
|
||||
void KeySearch::setPrefix(const std::string& prefix)
|
||||
{
|
||||
m_prefix = prefix;
|
||||
}
|
||||
|
||||
void KeySearch::addWord(const std::string& str)
|
||||
{
|
||||
std::string tmp = str;
|
||||
strtolower(tmp);
|
||||
m_words.push_back(tmp);
|
||||
}
|
||||
|
||||
void KeySearch::addList(const strlist_t& list)
|
||||
{
|
||||
for(const std::string& item : list) {
|
||||
addWord(item);
|
||||
}
|
||||
}
|
||||
|
||||
const strlist_t& KeySearch::getList()
|
||||
{
|
||||
return m_words;
|
||||
}
|
||||
|
||||
void KeySearch::clear()
|
||||
{
|
||||
m_words.clear();
|
||||
}
|
||||
|
||||
void KeySearch::setCallback(IKeySearchResult* callback)
|
||||
{
|
||||
m_callback = callback;
|
||||
}
|
||||
|
||||
void KeySearch::_search_linear()
|
||||
{
|
||||
struct libantelope::ec_keypair pair;
|
||||
|
||||
while (m_count < m_max) {
|
||||
struct result res;
|
||||
libantelope::ec_generate_key(&pair);
|
||||
if (_contains_word(&pair, res)) {
|
||||
m_callback->onResult(&pair, res);
|
||||
m_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KeySearch::abort()
|
||||
{
|
||||
// exit find() operation by setting m_max to zero.
|
||||
m_max = 0;
|
||||
}
|
||||
|
||||
void KeySearch::find(size_t num_results)
|
||||
{
|
||||
m_count = 0;
|
||||
m_max = num_results;
|
||||
|
||||
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||
// Only do multithread if number of threads makes sense.
|
||||
if (m_threads >= 2) {
|
||||
_search_mt();
|
||||
return;
|
||||
}
|
||||
#endif /* HAVE_THREADS */
|
||||
|
||||
_search_linear();
|
||||
}
|
||||
|
||||
bool KeySearch::_contains_word(const struct libantelope::ec_keypair* key, struct result& result) {
|
||||
|
||||
size_t prefix_len = m_prefix.length();
|
||||
std::string pubstr = libantelope::wif_pub_encode(key->pub, m_prefix).substr(prefix_len);
|
||||
strtolower(pubstr);
|
||||
|
||||
for(auto const& w: m_words) {
|
||||
size_t p = pubstr.find(w);
|
||||
if (p != std::string::npos) {
|
||||
result.pos = p + prefix_len;
|
||||
result.len = w.length();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace antelopekeygen
|
||||
101
common/src/key_search_mt.cpp
Normal file
101
common/src/key_search_mt.cpp
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <cstddef>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <eoskeygen/key_search_result.hpp>
|
||||
#include <eoskeygen/key_search.hpp>
|
||||
|
||||
namespace antelopekeygen {
|
||||
|
||||
// Mutex guard for m_count.
|
||||
std::mutex g_count_mtx;
|
||||
|
||||
// Thread process.
|
||||
void KeySearch::_thr_proc()
|
||||
{
|
||||
struct libantelope::ec_keypair pair;
|
||||
|
||||
while (m_count < m_max) {
|
||||
struct result res;
|
||||
|
||||
libantelope::ec_generate_key(&pair);
|
||||
if (_contains_word(&pair, res)) {
|
||||
|
||||
// Guard output with mutex, so we don't get
|
||||
// interrupted mid write and can write to m_count and res safely.
|
||||
const std::lock_guard<std::mutex> lock(g_count_mtx);
|
||||
|
||||
// It is possible m_count was updated by another thread
|
||||
// after we checked it in the while loop.
|
||||
// So while we have the lock, we need to check it again.
|
||||
if (m_count >= m_max) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update count and call result function.
|
||||
m_count++;
|
||||
m_callback->onResult(&pair, res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KeySearch::setThreadCount(size_t num)
|
||||
{
|
||||
m_threads = num;
|
||||
}
|
||||
|
||||
size_t KeySearch::max_threads()
|
||||
{
|
||||
return std::thread::hardware_concurrency();
|
||||
}
|
||||
|
||||
size_t KeySearch::getThreadCount() const
|
||||
{
|
||||
return m_threads;
|
||||
}
|
||||
|
||||
void KeySearch::_search_mt()
|
||||
{
|
||||
std::vector<std::thread> t;
|
||||
|
||||
t.resize(m_threads - 1);
|
||||
|
||||
// Launch them.
|
||||
for(std::size_t i = 0; i < t.size(); i++) {
|
||||
t[i] = std::thread(&KeySearch::_thr_proc, this);
|
||||
}
|
||||
|
||||
// Use main thread for 1 search
|
||||
_thr_proc();
|
||||
|
||||
// Wait for all threads to compelete.
|
||||
for(std::size_t i = 0; i < t.size(); i++) {
|
||||
t[i].join();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace antelopekeygen
|
||||
37
config.hpp.in
Normal file
37
config.hpp.in
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef EOSIOKEYGEN_CONFIG_H
|
||||
#define EOSIOKEYGEN_CONFIG_H
|
||||
|
||||
#define PROGRAM_NAME "@PROJECT_NAME@"
|
||||
#define PROGRAM_VERSION "@PROJECT_VERSION@"
|
||||
|
||||
// Paths
|
||||
#define CONFIG_SHARE_PATH "@CMAKE_INSTALL_DATADIR@/@CMAKE_PROJECT_NAME@"
|
||||
#define CONFIG_SHARE_FULL_PATH "@CMAKE_INSTALL_FULL_DATADIR@/@CMAKE_PROJECT_NAME@"
|
||||
|
||||
#define CONFIG_DICT_PATH "@CMAKE_INSTALL_DATADIR@/@CMAKE_PROJECT_NAME@/dict"
|
||||
#define CONFIG_DICT_FULL_PATH "@CMAKE_INSTALL_FULL_DATADIR@/@CMAKE_PROJECT_NAME@/dict"
|
||||
|
||||
#endif /* EOSIOKEYGEN_CONFIG_H */
|
||||
85
gui/CMakeLists.txt
Normal file
85
gui/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
project(antelope-keygen-gui
|
||||
VERSION ${CMAKE_PROJECT_VERSION}
|
||||
DESCRIPTION "Keygenerator for Antelope blockchain (gui)"
|
||||
LANGUAGES CXX)
|
||||
|
||||
# Append modules dir
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
include(QtUtils)
|
||||
|
||||
# Qt5 needs MOC,RCC and UIC
|
||||
set( CMAKE_AUTOMOC ON )
|
||||
set( CMAKE_AUTORCC ON )
|
||||
set( CMAKE_AUTOUIC ON )
|
||||
|
||||
# Autogenerate about config file
|
||||
|
||||
file( READ ${PROJECT_LICENSE_FILE} GUI_ABOUT_LICENSE )
|
||||
|
||||
string(REGEX REPLACE "^([^\n]+)" "<h2>\\1</h2>" GUI_ABOUT_LICENSE ${GUI_ABOUT_LICENSE})
|
||||
string(REGEX REPLACE "\n\n([^\n]+)" "<p>\\1</p>" GUI_ABOUT_LICENSE ${GUI_ABOUT_LICENSE})
|
||||
string(REGEX REPLACE "\n" "" GUI_ABOUT_LICENSE ${GUI_ABOUT_LICENSE})
|
||||
string(REGEX REPLACE "\<(.+)\>" "- <a href=\"mailto:\\1\">\\1</a>" GUI_ABOUT_AUTHOR ${PROJECT_MAINTAINER})
|
||||
|
||||
configure_file(gui_text.h.in "${CMAKE_CURRENT_BINARY_DIR}/gui_text.h" @ONLY ESCAPE_QUOTES)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# --------------------------------
|
||||
# Program
|
||||
# --------------------------------
|
||||
|
||||
set( PROGRAM_EXE ${PROJECT_NAME} )
|
||||
|
||||
set( PROGRAM_SRC
|
||||
src/main.cpp
|
||||
src/MainWindow.cpp
|
||||
src/GenerateWindow.cpp
|
||||
src/SearchWindow.cpp
|
||||
src/MultiSelect.cpp
|
||||
src/Settings.cpp
|
||||
src/helpers.cpp
|
||||
)
|
||||
|
||||
add_executable( ${PROGRAM_EXE} WIN32 ${PROGRAM_SRC} )
|
||||
|
||||
# Libraries
|
||||
target_link_libraries( ${PROGRAM_EXE} common )
|
||||
|
||||
# QT
|
||||
qt5_app(TARGET ${PROGRAM_EXE}
|
||||
SKIP_TRANSLATIONS
|
||||
MODULES Core Gui Widgets Concurrent
|
||||
INSTALL_COMPONENT gui
|
||||
)
|
||||
|
||||
# --------------------------------
|
||||
# Install
|
||||
# --------------------------------
|
||||
|
||||
install(TARGETS ${PROGRAM_EXE}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT gui)
|
||||
|
||||
install(FILES ${PROJECT_LICENSE_FILE}
|
||||
DESTINATION ${CMAKE_INSTALL_SHAREDIR}
|
||||
COMPONENT gui
|
||||
RENAME LICENSE.gui)
|
||||
|
||||
install(FILES README.md
|
||||
DESTINATION ${CMAKE_INSTALL_SHAREDIR}
|
||||
COMPONENT gui
|
||||
RENAME README.gui.md)
|
||||
|
||||
install(FILES LICENSE.qt5
|
||||
DESTINATION ${CMAKE_INSTALL_SHAREDIR}
|
||||
COMPONENT gui)
|
||||
|
||||
# --------------------------------
|
||||
# Package
|
||||
# --------------------------------
|
||||
|
||||
configure_file(cmake/CPackComponentConfig.cmake.in
|
||||
${PROJECT_BINARY_DIR}/CPackProperties.cmake)
|
||||
165
gui/LICENSE.qt5
Normal file
165
gui/LICENSE.qt5
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
32
gui/README.md
Normal file
32
gui/README.md
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
# antelope-keygen (gui)
|
||||
|
||||
This is the graphical version of the [antelope-keygen](https://github.com/eosswedenorg/antelope-keygen) project.
|
||||
|
||||
This program generates public and private keypair for [Antelope IO](https://antelope.io)
|
||||
|
||||
Among the basic functionality the program can also search for keys containing specific words also know as _vanity keys_.
|
||||
|
||||
## Security notice
|
||||
|
||||
Keys are generated using [libantelope](https://github.com/eosswedenorg/libantelope)
|
||||
while the library does not claim to guarantee cryptographically secure keys. it
|
||||
relies on widly used open source cryptographic libraries (OpenSSL, libsecp256k1).
|
||||
|
||||
Use at your own risk. The author and [Sw/eden](https://eossweden.org/) does not take responsability
|
||||
for any damage caused by keys generated by the program.
|
||||
|
||||
Please read the `LICENSE` file.
|
||||
|
||||
```
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
Henrik Hautakoski - [Sw/eden](https://eossweden.org/) - [henrik@eossweden.org](mailto:henrik@eossweden.org)
|
||||
17
gui/cmake/CPackComponentConfig.cmake.in
Normal file
17
gui/cmake/CPackComponentConfig.cmake.in
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
# --------------------------------
|
||||
# CPack Component Config
|
||||
# --------------------------------
|
||||
|
||||
set( CPACK_PACKAGE_GUI_NAME "${PROJECT_NAME}" )
|
||||
set( CPACK_PACKAGE_GUI_CONTACT "${PROJECT_MAINTAINER}" )
|
||||
|
||||
# Additional description
|
||||
set( CPACK_COMPONENT_GUI_DESCRIPTION "Graphical interface (Qt framework)" )
|
||||
|
||||
# Debian specific
|
||||
set( CPACK_DEBIAN_GUI_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}-${CPACK_SYSTEM_NAME}-${CPACK_SYSTEM_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
|
||||
set( CPACK_DEBIAN_GUI_PACKAGE_NAME "${PROJECT_NAME}" )
|
||||
set( CPACK_DEBIAN_GUI_PACKAGE_PRIORITY "optional" )
|
||||
set( CPACK_DEBIAN_GUI_PACKAGE_SECTION "misc" )
|
||||
set( CPACK_DEBIAN_GUI_PACKAGE_DEPENDS "libqt5core5a (>= 5.9.5), libqt5concurrent5 (>= 5.9.5), libqt5gui5 (>= 5.9.5), libqt5widgets5 (>= 5.9.5), libssl1.1")
|
||||
110
gui/cmake/QtUtils.cmake
Normal file
110
gui/cmake/QtUtils.cmake
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
|
||||
set(_QT_INSTALL_CONFIG_TEMPLATE ${CMAKE_CURRENT_LIST_DIR}/cmake_install_qt.cmake.in)
|
||||
set(_QT_INSTALL_CONFIG ${CMAKE_CURRENT_BINARY_DIR}/cmake_install_qt.cmake)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Code Taken and modified from:
|
||||
# https://github.com/equalsraf/neovim-qt/blob/master/cmake/WinDeployQt.cmake
|
||||
#
|
||||
# Wrapper to call windeployqt on Windows
|
||||
# ------------------------------------------------------------------------------
|
||||
function(qt5_win_deploy)
|
||||
cmake_parse_arguments(_deploy
|
||||
"COMPILER_RUNTIME;FORCE;SKIP_TRANSLATIONS"
|
||||
"TARGET;INSTALL_COMPONENT"
|
||||
"MODULES;EXCLUDE_MODULES"
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
if(NOT _deploy_TARGET)
|
||||
message(FATAL_ERROR "A TARGET must be specified")
|
||||
endif()
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
list(APPEND _ARGS --debug)
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||
list(APPEND _ARGS --release-with-debug-info)
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
list(APPEND _ARGS --release)
|
||||
endif()
|
||||
if(_deploy_COMPILER_RUNTIME)
|
||||
list(APPEND _ARGS --compiler-runtime)
|
||||
endif()
|
||||
if(_deploy_FORCE)
|
||||
list(APPEND _ARGS --force)
|
||||
endif()
|
||||
if(_deploy_SKIP_TRANSLATIONS)
|
||||
list(APPEND _ARGS --no-translations)
|
||||
endif()
|
||||
|
||||
foreach(mod ${_deploy_MODULES})
|
||||
string(TOLOWER ${mod} mod)
|
||||
string(REPLACE "qt5::" "" mod ${mod})
|
||||
list(APPEND _ARGS "--${mod}")
|
||||
endforeach()
|
||||
foreach(mod ${_deploy_EXCLUDE_MODULES})
|
||||
string(TOLOWER ${mod} mod)
|
||||
string(REPLACE "qt5::" "" mod ${mod})
|
||||
list(APPEND _ARGS "--no-${mod}")
|
||||
endforeach()
|
||||
|
||||
find_program(_deploy_PROGRAM windeployqt PATHS $ENV{QTDIR}/bin)
|
||||
if(_deploy_PROGRAM)
|
||||
message(STATUS "Found ${_deploy_PROGRAM}")
|
||||
else()
|
||||
message(FATAL_ERROR "Unable to find windeployqt")
|
||||
endif()
|
||||
|
||||
if(COMPILER_RUNTIME AND NOT $ENV{VVVV})
|
||||
message(STATUS "not set, the VC++ redistributable installer will NOT be bundled")
|
||||
endif()
|
||||
|
||||
set( _QT_INSTALL_CONFIG_DEPFILE "${CMAKE_CURRENT_BINARY_DIR}/qt_deps_\${CMAKE_INSTALL_CONFIG_NAME}.cmake" )
|
||||
set( _QT_DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/qt_deps_${CMAKE_BUILD_TYPE}.cmake )
|
||||
|
||||
add_custom_target(${_deploy_TARGET}_windeployqt ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "$<TARGET_FILE_DIR:${_deploy_TARGET}>" > ${_QT_DEPFILE}
|
||||
COMMAND ${_deploy_PROGRAM} --list relative ${_ARGS} $<TARGET_FILE:${_deploy_TARGET}> >> ${_QT_DEPFILE}
|
||||
DEPENDS ${_deploy_TARGET}
|
||||
COMMENT "Preparing Qt runtime dependencies")
|
||||
|
||||
configure_file(${_QT_INSTALL_CONFIG_TEMPLATE} ${_QT_INSTALL_CONFIG} @ONLY)
|
||||
|
||||
if (_deploy_INSTALL_COMPONENT)
|
||||
set(_install_args COMPONENT ${_deploy_INSTALL_COMPONENT})
|
||||
endif()
|
||||
|
||||
install(SCRIPT ${_QT_INSTALL_CONFIG} ${_install_args})
|
||||
endfunction()
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Macro for compile, link and deploy qt apps.
|
||||
# ------------------------------------------------------------------------------
|
||||
macro(qt5_app)
|
||||
cmake_parse_arguments(_args
|
||||
"COMPILER_RUNTIME;FORCE;SKIP_TRANSLATIONS"
|
||||
"TARGET;INSTALL_COMPONENT"
|
||||
"MODULES"
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
if(NOT _args_TARGET)
|
||||
message(FATAL_ERROR "A TARGET must be specified")
|
||||
endif()
|
||||
|
||||
if(NOT _args_MODULES)
|
||||
message(FATAL_ERROR "Must define atleast one QT component")
|
||||
endif()
|
||||
|
||||
find_package( Qt5 COMPONENTS ${_args_MODULES} REQUIRED)
|
||||
|
||||
# Link targets
|
||||
list( TRANSFORM _args_MODULES PREPEND "Qt5::" OUTPUT_VARIABLE _qtargets)
|
||||
target_link_libraries( ${_args_TARGET} ${_qtargets} )
|
||||
|
||||
|
||||
if (WIN32)
|
||||
# Windows needs alot of extra stuff to copy all dll's.
|
||||
qt5_win_deploy(${ARGN})
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
23
gui/cmake/cmake_install_qt.cmake.in
Normal file
23
gui/cmake/cmake_install_qt.cmake.in
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
# Custom script that installs Qt runtime files.
|
||||
|
||||
if (EXISTS @_QT_INSTALL_CONFIG_DEPFILE@)
|
||||
file(STRINGS @_QT_INSTALL_CONFIG_DEPFILE@ _lines)
|
||||
|
||||
# First line is the output path.
|
||||
list(GET _lines 0 BASE_PATH)
|
||||
|
||||
# Rest of the lines are the files relative to the path.
|
||||
list(SUBLIST _lines 1 -1 FILES)
|
||||
|
||||
foreach(file ${FILES})
|
||||
get_filename_component(rel_path ${file} DIRECTORY BASE_DIR ${BASE_PATH})
|
||||
|
||||
set(install_path ${CMAKE_INSTALL_PREFIX}/@CMAKE_INSTALL_BINDIR@)
|
||||
if (rel_path)
|
||||
set(install_path "${install_path}/${rel_path}")
|
||||
endif()
|
||||
|
||||
file(INSTALL ${BASE_PATH}/${file} DESTINATION ${install_path})
|
||||
endforeach()
|
||||
endif()
|
||||
54
gui/gui_text.h.in
Normal file
54
gui/gui_text.h.in
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef EOSIOKEYGEN_GUI_TEXT_H
|
||||
#define EOSIOKEYGEN_GUI_TEXT_H
|
||||
|
||||
#include <config.hpp>
|
||||
|
||||
#define EOSIOKEYGEN_GUI_TEXT_ABOUT_TITLE "@PROJECT_NAME@ - About"
|
||||
|
||||
#define EOSIOKEYGEN_GUI_TEXT_ABOUT_BODY \
|
||||
"<h1>@PROJECT_NAME@ - v@PROJECT_VERSION@</h1>" \
|
||||
"<p>@PROJECT_DESCRIPTION@</p>" \
|
||||
"<p><a href=\"@PROJECT_HOMEPAGE_URL@\">@PROJECT_HOMEPAGE_URL@</a></p>" \
|
||||
"@GUI_ABOUT_LICENSE@" \
|
||||
"<h2>Author</h2>" \
|
||||
"<p>@GUI_ABOUT_AUTHOR@</p>"
|
||||
|
||||
#define EOSIOKEYGEN_GUI_TEXT_DICT_LANG_TOOLTIP \
|
||||
"<p>Highlight words from given language dictionary in the found keys (note that the words " \
|
||||
"<strong>are not</strong> used for search. only for highlight output).</p>" \
|
||||
"<p>There can be more then one language. In that case contents " \
|
||||
"of all languges are merged into one dictionary.</p>" \
|
||||
"<p>The langauges are stored in files at <i>" CONFIG_SHARE_FULL_PATH "/dict</i></p>"
|
||||
|
||||
|
||||
#define EOSIOKEYGEN_GUI_TEXT_DICT_FILE_TOOLTIP \
|
||||
"<p>Use words found in file (separated by newline) to highlight " \
|
||||
"words in the keys found (note that the words in this " \
|
||||
"file are not used for search. only for highlight output).</p>" \
|
||||
"<p>There can be more then one file. In that case contents " \
|
||||
"of all files are merged into one dictionary.</p>"
|
||||
|
||||
#endif /* EOSIOKEYGEN_GUI_TEXT_H */
|
||||
128
gui/src/GenerateWindow.cpp
Normal file
128
gui/src/GenerateWindow.cpp
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <QIcon>
|
||||
#include <QLabel>
|
||||
#include <QGridLayout>
|
||||
#include <QClipboard>
|
||||
#include <QGuiApplication>
|
||||
#include <QFont>
|
||||
#include <QFontDatabase>
|
||||
#include <libantelope/ec.hpp>
|
||||
#include <libantelope/WIF.hpp>
|
||||
#include "Settings.hpp"
|
||||
#include "GenerateWindow.hpp"
|
||||
|
||||
void _initKeyWidget(QLineEdit& w, const QFont& font) {
|
||||
w.setFixedWidth(460);
|
||||
w.setFont(font);
|
||||
w.setReadOnly(true);
|
||||
}
|
||||
|
||||
void _initKeyCopyButton(QPushButton& btn, const QIcon& icon) {
|
||||
btn.setFixedWidth(32);
|
||||
btn.setIcon(icon);
|
||||
}
|
||||
|
||||
GenerateWindow::GenerateWindow(QWidget *parent) :
|
||||
QWidget (parent),
|
||||
m_btn_gen ("Generate"),
|
||||
m_btn_copy_both ("Copy keys")
|
||||
{
|
||||
QFont mono = QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||
|
||||
QIcon copy_icon = QIcon::fromTheme("edit-copy");
|
||||
QGridLayout* layout;
|
||||
|
||||
_initKeyWidget(m_pub, mono);
|
||||
_initKeyWidget(m_priv, mono);
|
||||
|
||||
_initKeyCopyButton(m_btn_copy_pub, copy_icon);
|
||||
_initKeyCopyButton(m_btn_copy_priv, copy_icon);
|
||||
|
||||
// Layout
|
||||
layout = new QGridLayout();
|
||||
layout->setAlignment(Qt::AlignCenter);
|
||||
|
||||
// Stretch first and last column to make the widgets horizontally centered.
|
||||
layout->setColumnStretch(0, 1);
|
||||
layout->setColumnStretch(4, 1);
|
||||
|
||||
// Public key row
|
||||
layout->addWidget(new QLabel("Public:"), 0, 1, Qt::AlignRight);
|
||||
layout->addWidget(&m_pub, 0, 2);
|
||||
layout->addWidget(&m_btn_copy_pub, 0, 3);
|
||||
|
||||
// Private key row
|
||||
|
||||
layout->addWidget(new QLabel("Private:"), 1, 1, Qt::AlignRight);
|
||||
layout->addWidget(&m_priv, 1, 2);
|
||||
layout->addWidget(&m_btn_copy_priv, 1, 3);
|
||||
|
||||
// Bottom row
|
||||
|
||||
m_btn_copy_both.setFixedWidth(80);
|
||||
|
||||
layout->addWidget(&m_btn_gen, 2, 2);
|
||||
layout->addWidget(&m_btn_copy_both, 2, 3);
|
||||
|
||||
setLayout(layout);
|
||||
|
||||
// Connections
|
||||
connect(&m_btn_gen, SIGNAL(released()), this, SLOT(generate_key()));
|
||||
connect(&m_btn_copy_both, SIGNAL(released()), this, SLOT(copy_both_keys()));
|
||||
connect(&m_btn_copy_pub, SIGNAL(released()), this, SLOT(copy_pub_key()));
|
||||
connect(&m_btn_copy_priv, SIGNAL(released()), this, SLOT(copy_priv_key()));
|
||||
}
|
||||
|
||||
void GenerateWindow::generate_key()
|
||||
{
|
||||
std::string pubstr, pvtstr;
|
||||
struct libantelope::ec_keypair pair;
|
||||
const libantelope::wif_codec_t& codec = Settings::getKeyCodec();
|
||||
|
||||
libantelope::ec_generate_key(&pair);
|
||||
|
||||
pubstr = libantelope::wif_pub_encode(pair.pub, codec.pub);
|
||||
pvtstr = libantelope::wif_priv_encode(pair.secret, codec.pvt);
|
||||
m_pub.setText(QString::fromStdString(pubstr));
|
||||
m_priv.setText(QString::fromStdString(pvtstr));
|
||||
}
|
||||
|
||||
void GenerateWindow::copy_both_keys()
|
||||
{
|
||||
QClipboard *clipboard = QGuiApplication::clipboard();
|
||||
clipboard->setText(m_pub.text() + "\n" + m_priv.text());
|
||||
}
|
||||
|
||||
void GenerateWindow::copy_pub_key()
|
||||
{
|
||||
QClipboard *clipboard = QGuiApplication::clipboard();
|
||||
clipboard->setText(m_pub.text());
|
||||
}
|
||||
|
||||
void GenerateWindow::copy_priv_key()
|
||||
{
|
||||
QClipboard *clipboard = QGuiApplication::clipboard();
|
||||
clipboard->setText(m_priv.text());
|
||||
}
|
||||
62
gui/src/GenerateWindow.hpp
Normal file
62
gui/src/GenerateWindow.hpp
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef GENERATE_WINDOW_H
|
||||
#define GENERATE_WINDOW_H
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QWidget>
|
||||
|
||||
class GenerateWindow : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GenerateWindow(QWidget *parent = 0);
|
||||
|
||||
public slots:
|
||||
|
||||
// Genereate a new key.
|
||||
void generate_key();
|
||||
|
||||
// Copy both keys to clipboard
|
||||
void copy_both_keys();
|
||||
|
||||
// copy public key to clipboard
|
||||
void copy_pub_key();
|
||||
|
||||
// copy private key to clipboard
|
||||
void copy_priv_key();
|
||||
|
||||
protected:
|
||||
|
||||
QLineEdit m_pub;
|
||||
QLineEdit m_priv;
|
||||
|
||||
QPushButton m_btn_gen;
|
||||
QPushButton m_btn_copy_both;
|
||||
QPushButton m_btn_copy_priv;
|
||||
QPushButton m_btn_copy_pub;
|
||||
};
|
||||
|
||||
#endif /* GENERATE_WINDOW_H */
|
||||
125
gui/src/MainWindow.cpp
Normal file
125
gui/src/MainWindow.cpp
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <QMessageBox>
|
||||
#include <QMenuBar>
|
||||
#include <QGridLayout>
|
||||
#include <QStackedWidget>
|
||||
#include <libantelope/WIF.hpp>
|
||||
#include "gui_text.h"
|
||||
#include "Settings.hpp"
|
||||
#include "GenerateWindow.hpp"
|
||||
#include "SearchWindow.hpp"
|
||||
#include "MainWindow.hpp"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow (parent),
|
||||
m_format_fio_action (nullptr),
|
||||
m_format_legacy_action (nullptr),
|
||||
m_format_k1_action (nullptr)
|
||||
{
|
||||
libantelope::ec_init();
|
||||
|
||||
// Create sub windows and stacked widget.
|
||||
m_stacked = new QStackedWidget();
|
||||
m_stacked->addWidget(new GenerateWindow());
|
||||
m_stacked->addWidget(new SearchWindow());
|
||||
|
||||
setCentralWidget(m_stacked);
|
||||
|
||||
// Add to menu bar.
|
||||
|
||||
menuBar()->addAction("Generate", this, SLOT(switchToGenerate()));
|
||||
menuBar()->addAction("Search", this, SLOT(switchToSearch()));
|
||||
|
||||
// Settings
|
||||
|
||||
QActionGroup* formatGroup = new QActionGroup(this);
|
||||
|
||||
m_format_fio_action = new QAction("FIO", formatGroup);
|
||||
m_format_fio_action->setCheckable(true);
|
||||
m_format_legacy_action = new QAction("Legacy", formatGroup);
|
||||
m_format_legacy_action->setCheckable(true);
|
||||
m_format_k1_action = new QAction("K1", formatGroup);
|
||||
m_format_k1_action->setCheckable(true);
|
||||
|
||||
// Set k1 and trigger the changed action so we set the codec.
|
||||
m_format_k1_action->setChecked(true);
|
||||
formatK1CheckboxChanged();
|
||||
|
||||
connect(m_format_fio_action, SIGNAL(triggered()), this, SLOT(formatFioCheckboxChanged()));
|
||||
connect(m_format_legacy_action, SIGNAL(triggered()), this, SLOT(formatLegacyCheckboxChanged()));
|
||||
connect(m_format_k1_action, SIGNAL(triggered()), this, SLOT(formatK1CheckboxChanged()));
|
||||
|
||||
QMenu *settings = menuBar()->addMenu("Settings");
|
||||
QMenu *format_menu = settings->addMenu("Key Format");
|
||||
format_menu->addAction(m_format_k1_action);
|
||||
format_menu->addAction(m_format_legacy_action);
|
||||
format_menu->addAction(m_format_fio_action);
|
||||
|
||||
// About
|
||||
menuBar()->addAction("About", this, SLOT(showAbout()));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
libantelope::ec_shutdown();
|
||||
}
|
||||
|
||||
void MainWindow::switchToGenerate()
|
||||
{
|
||||
m_stacked->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void MainWindow::switchToSearch()
|
||||
{
|
||||
m_stacked->setCurrentIndex(1);
|
||||
}
|
||||
|
||||
void MainWindow::showAbout()
|
||||
{
|
||||
QMessageBox::about(this,
|
||||
EOSIOKEYGEN_GUI_TEXT_ABOUT_TITLE,
|
||||
EOSIOKEYGEN_GUI_TEXT_ABOUT_BODY);
|
||||
}
|
||||
|
||||
void MainWindow::formatFioCheckboxChanged()
|
||||
{
|
||||
if (m_format_fio_action->isChecked()) {
|
||||
Settings::setKeyCodec(libantelope::wif_create_legacy_codec("FIO"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::formatLegacyCheckboxChanged()
|
||||
{
|
||||
if (m_format_legacy_action->isChecked()) {
|
||||
Settings::setKeyCodec(libantelope::WIF_CODEC_LEG);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::formatK1CheckboxChanged()
|
||||
{
|
||||
if (m_format_k1_action->isChecked()) {
|
||||
Settings::setKeyCodec(libantelope::WIF_CODEC_K1);
|
||||
}
|
||||
}
|
||||
63
gui/src/MainWindow.hpp
Normal file
63
gui/src/MainWindow.hpp
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef MAIN_WINDOW_H
|
||||
#define MAIN_WINDOW_H
|
||||
|
||||
#include <QAction>
|
||||
#include <QPointer>
|
||||
#include <QMainWindow>
|
||||
|
||||
class QStackedWidget;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWindow(QWidget *parent = 0);
|
||||
virtual ~MainWindow();
|
||||
|
||||
private slots :
|
||||
|
||||
// Switch to generate window.
|
||||
void switchToGenerate();
|
||||
|
||||
// Switch to search window.
|
||||
void switchToSearch();
|
||||
|
||||
void showAbout();
|
||||
|
||||
void formatFioCheckboxChanged();
|
||||
void formatLegacyCheckboxChanged();
|
||||
void formatK1CheckboxChanged();
|
||||
|
||||
private :
|
||||
|
||||
QStackedWidget* m_stacked;
|
||||
|
||||
QPointer<QAction> m_format_fio_action;
|
||||
QPointer<QAction> m_format_legacy_action;
|
||||
QPointer<QAction> m_format_k1_action;
|
||||
};
|
||||
|
||||
#endif /* MAIN_WINDOW_H */
|
||||
150
gui/src/MultiSelect.cpp
Normal file
150
gui/src/MultiSelect.cpp
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <QDialog>
|
||||
#include <QLayout>
|
||||
#include <QMouseEvent>
|
||||
#include <QListWidget>
|
||||
#include <QListWidgetItem>
|
||||
#include "MultiSelect.hpp"
|
||||
|
||||
MultiSelect::MultiSelect(const QString& text, bool user_can_add, QWidget *parent) :
|
||||
QPushButton (text + ": none", parent)
|
||||
{
|
||||
QPushButton* btn;
|
||||
QVBoxLayout* layout;
|
||||
|
||||
m_prefix = text;
|
||||
|
||||
// Dialog
|
||||
m_dialog = new QDialog(this);
|
||||
|
||||
// Dialog Widgets
|
||||
m_list = new QListWidget();
|
||||
btn = new QPushButton("Select");
|
||||
|
||||
// Dialog layout
|
||||
layout = new QVBoxLayout(m_dialog);
|
||||
layout->addWidget(m_list);
|
||||
layout->addWidget(btn);
|
||||
|
||||
// Connections
|
||||
QObject::connect(btn, SIGNAL(clicked()), m_dialog, SLOT(accept()));
|
||||
QObject::connect(m_dialog, SIGNAL(accepted()), this, SLOT(selectionConfirmed()));
|
||||
QObject::connect(m_list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(listItemClicked(QListWidgetItem*)));
|
||||
|
||||
// Configured to let users add items. provide button and signal.
|
||||
if (user_can_add) {
|
||||
btn = new QPushButton("Add");
|
||||
layout->addWidget(btn);
|
||||
QObject::connect(btn, SIGNAL(clicked()), this, SLOT(addBtnClicked()));
|
||||
}
|
||||
}
|
||||
|
||||
void MultiSelect::addItem(const QString& text, bool checked)
|
||||
{
|
||||
QListWidgetItem* item = new QListWidgetItem(text, m_list);
|
||||
item->setFlags(Qt::ItemIsEnabled);
|
||||
item->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
|
||||
}
|
||||
|
||||
void MultiSelect::addItems(const QStringList& list, bool checked)
|
||||
{
|
||||
QStringList::const_iterator it;
|
||||
|
||||
for(it = list.cbegin(); it != list.cend(); it++) {
|
||||
addItem(*it, checked);
|
||||
}
|
||||
}
|
||||
|
||||
void MultiSelect::clearItems()
|
||||
{
|
||||
m_list->clear();
|
||||
}
|
||||
|
||||
QStringList MultiSelect::getSelectedItems() const
|
||||
{
|
||||
QListWidgetItem* item;
|
||||
QStringList ret;
|
||||
|
||||
// Cannot use m_list->selectedItems() as that function only fetches
|
||||
// _selected_ and not _checked_ items (there is a difference).
|
||||
for(int i = 0; i < m_list->count(); i++) {
|
||||
item = m_list->item(i);
|
||||
// Include in list if checked.
|
||||
if (item->checkState() == Qt::Checked) {
|
||||
ret << item->text();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void MultiSelect::selectionConfirmed()
|
||||
{
|
||||
QStringList selected = getSelectedItems();
|
||||
|
||||
// Update the text for this widget to
|
||||
// reflect the selected objects.
|
||||
QString txt = m_prefix + ": ";
|
||||
|
||||
// Have more than one item. show number of items.
|
||||
if (selected.count() > 1) {
|
||||
txt += QString::number(selected.count()) + " selected";
|
||||
}
|
||||
// Just one, we can show the text.
|
||||
else if (selected.count() == 1) {
|
||||
txt += selected.at(0);
|
||||
}
|
||||
else {
|
||||
txt += "none";
|
||||
}
|
||||
|
||||
setText(txt);
|
||||
|
||||
// Emit the selectionChanged signal with the updated list
|
||||
emit selectionChanged(selected);
|
||||
}
|
||||
|
||||
void MultiSelect::listItemClicked(QListWidgetItem *item)
|
||||
{
|
||||
// toggle state when user clicks.
|
||||
bool checked = item->checkState() == Qt::Checked;
|
||||
item->setCheckState(checked ? Qt::Unchecked : Qt::Checked);
|
||||
}
|
||||
|
||||
void MultiSelect::addBtnClicked()
|
||||
{
|
||||
// Just emit addNewItem event.
|
||||
emit addNewItem();
|
||||
}
|
||||
|
||||
void MultiSelect::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
// Show select dialog.
|
||||
m_dialog->show();
|
||||
} else {
|
||||
// pass on other buttons to base class
|
||||
QPushButton::mousePressEvent(event);
|
||||
}
|
||||
}
|
||||
96
gui/src/MultiSelect.hpp
Normal file
96
gui/src/MultiSelect.hpp
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef MULTI_SELECT_H
|
||||
#define MULTI_SELECT_H
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QPushButton>
|
||||
|
||||
class QMouseEvent;
|
||||
class QPushButton;
|
||||
class QListWidget;
|
||||
class QListWidgetItem;
|
||||
class QDialog;
|
||||
class MultiSelectDialog;
|
||||
|
||||
//
|
||||
// MultiSelect implements multi selection of items using
|
||||
// a push button and a dialog with a list of checkbox items.
|
||||
//
|
||||
class MultiSelect : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MultiSelect(const QString& text, bool user_add_item = false, QWidget *parent = 0);
|
||||
|
||||
// Items.
|
||||
|
||||
void addItem(const QString& text, bool checked = false);
|
||||
|
||||
void addItems(const QStringList& list, bool checked = false);
|
||||
|
||||
void clearItems();
|
||||
|
||||
// Get a list of currently selected items.
|
||||
QStringList getSelectedItems() const;
|
||||
|
||||
signals:
|
||||
|
||||
// This signal is emitted whenever the user has made a new selection.
|
||||
void selectionChanged(QStringList selected);
|
||||
|
||||
// This signal is emitted whenever the user clicks the "Add" button.
|
||||
// NOTE: Will only be emitted if `user_add_item` has been set to `true` in the constructor.
|
||||
void addNewItem();
|
||||
|
||||
private slots :
|
||||
|
||||
// Called when the dialog is accepted.
|
||||
void selectionConfirmed();
|
||||
|
||||
// Called when a list item is clicked on.
|
||||
void listItemClicked(QListWidgetItem *item);
|
||||
|
||||
// Called when the add button is clicked on.
|
||||
void addBtnClicked();
|
||||
|
||||
protected :
|
||||
|
||||
// Event handlers
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
|
||||
private :
|
||||
|
||||
// Prefix to show on the button before value.
|
||||
QString m_prefix;
|
||||
|
||||
// List of items
|
||||
QListWidget* m_list;
|
||||
|
||||
// Dialog to show if this widget are clicked on.
|
||||
QDialog* m_dialog;
|
||||
};
|
||||
|
||||
#endif /* MULTI_SELECT_H */
|
||||
289
gui/src/SearchWindow.cpp
Normal file
289
gui/src/SearchWindow.cpp
Normal file
|
|
@ -0,0 +1,289 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QScrollBar>
|
||||
#include <QGridLayout>
|
||||
#include <QFuture>
|
||||
#include <QtConcurrent>
|
||||
#include <libantelope/WIF.hpp>
|
||||
#include <eoskeygen/core/leet.hpp>
|
||||
#include <eoskeygen/core/string.hpp>
|
||||
#include "Settings.hpp"
|
||||
#include "gui_text.h"
|
||||
#include "config.hpp"
|
||||
#include "helpers.hpp"
|
||||
#include "SearchWindow.hpp"
|
||||
|
||||
SearchWindow::SearchWindow(QWidget *parent, Qt::WindowFlags flags) :
|
||||
QWidget (parent, flags),
|
||||
m_status ("status"),
|
||||
m_leet_cb ("L33t"),
|
||||
m_dict_lang ("Dictionary Language"),
|
||||
m_dict_file ("Dictionary File", true),
|
||||
m_btn_exec ("Search"),
|
||||
m_btn_clear ("Clear")
|
||||
{
|
||||
setMinimumSize(600, 400);
|
||||
|
||||
// Monospaced font
|
||||
QFont f_mono("monospace");
|
||||
|
||||
// Output
|
||||
m_output.setFont(f_mono);
|
||||
m_output.setReadOnly(true);
|
||||
|
||||
// Layout
|
||||
// ------------------------
|
||||
setLayout(&m_layout);
|
||||
m_layout.setColumnStretch(0, 10);
|
||||
m_layout.setColumnStretch(1, 10);
|
||||
|
||||
// First row.
|
||||
m_dict_lang.addItems(get_files(CONFIG_DICT_FULL_PATH));
|
||||
m_dict_lang.setToolTip(EOSIOKEYGEN_GUI_TEXT_DICT_LANG_TOOLTIP);
|
||||
m_dict_file.setToolTip(EOSIOKEYGEN_GUI_TEXT_DICT_FILE_TOOLTIP);
|
||||
|
||||
m_layout.addWidget(&m_dict_lang, 0, 0);
|
||||
m_layout.addWidget(&m_dict_file, 0, 1);
|
||||
|
||||
m_layout.addWidget(&m_leet_cb, 0, 2);
|
||||
|
||||
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||
m_num_threads.setValue((int) antelopekeygen::KeySearch::max_threads());
|
||||
m_num_threads.setRange(1, (int) antelopekeygen::KeySearch::max_threads());
|
||||
m_num_threads.setSuffix(" Threads");
|
||||
m_layout.addWidget(&m_num_threads, 0, 3);
|
||||
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||
|
||||
m_num_results.setValue(10);
|
||||
m_num_results.setRange(1, 99);
|
||||
m_num_results.setSuffix(" Results");
|
||||
m_layout.addWidget(&m_num_results, 0, 4);
|
||||
|
||||
// Second row.
|
||||
m_layout.addWidget(&m_status, 1, 0, 1, 3);
|
||||
m_layout.addWidget(&m_txt_search, 1, 0, 1, 3);
|
||||
m_layout.addWidget(&m_btn_exec, 1, 3);
|
||||
m_layout.addWidget(&m_btn_clear, 1, 4);
|
||||
|
||||
// Third row.
|
||||
m_layout.addWidget(&m_output, 2, 0, 1, 0);
|
||||
|
||||
// Search
|
||||
// ------------------------
|
||||
|
||||
m_ksearch.setCallback(this);
|
||||
|
||||
initSignals();
|
||||
|
||||
// Focus search field.
|
||||
m_txt_search.setFocus();
|
||||
}
|
||||
|
||||
void SearchWindow::initSignals()
|
||||
{
|
||||
// Buttons
|
||||
connect(&m_btn_exec, SIGNAL(released()), this, SLOT(search()));
|
||||
connect(&m_btn_clear, SIGNAL(released()), &m_output, SLOT(clear()));
|
||||
|
||||
// Worker Thread
|
||||
connect(&m_worker, SIGNAL(started()), this, SLOT(searchStarted()));
|
||||
connect(&m_worker, SIGNAL(finished()), this, SLOT(searchFinished()));
|
||||
|
||||
connect(this, SIGNAL(addOutput(QString)), this, SLOT(output(QString)));
|
||||
|
||||
connect(&m_dict_file, SIGNAL(addNewItem()), this, SLOT(langFileAdd()));
|
||||
}
|
||||
|
||||
void SearchWindow::loadDictionaries()
|
||||
{
|
||||
QStringList list;
|
||||
antelopekeygen::Dictionary tmpDict;
|
||||
std::string base_path(CONFIG_DICT_FULL_PATH);
|
||||
|
||||
// Clear dictionary first.
|
||||
m_dict.clear();
|
||||
|
||||
// Go through all selected languages.
|
||||
list = m_dict_lang.getSelectedItems();
|
||||
for(QStringList::const_iterator it = list.cbegin(); it != list.cend(); it++) {
|
||||
|
||||
// Load and add them to dictionary.
|
||||
tmpDict.loadFromFile(base_path + "/" + it->toStdString());
|
||||
m_dict.add(tmpDict);
|
||||
}
|
||||
|
||||
// Go through all selected files.
|
||||
list = m_dict_file.getSelectedItems();
|
||||
for(QStringList::const_iterator it = list.cbegin(); it != list.cend(); it++) {
|
||||
|
||||
// Load and add them to dictionary.
|
||||
tmpDict.loadFromFile(it->toStdString());
|
||||
m_dict.add(tmpDict);
|
||||
}
|
||||
}
|
||||
|
||||
void SearchWindow::onResult(const struct libantelope::ec_keypair* key, const struct antelopekeygen::KeySearch::result& result)
|
||||
{
|
||||
int pos = (int) result.pos;
|
||||
int len = (int) result.len;
|
||||
libantelope::wif_codec_t codec = Settings::getKeyCodec();
|
||||
QString pub = QString::fromStdString(libantelope::wif_pub_encode(key->pub, codec.pub));
|
||||
int pub_prefix_len = (int) codec.pub.length();
|
||||
QString mid = pub.mid(pos, len);
|
||||
QString left = pub.left(pos);
|
||||
QString right = pub.mid(pos + len, pub.size() - pos);
|
||||
antelopekeygen::Dictionary::search_result_t dict_res = m_dict.search(pub.toStdString());
|
||||
|
||||
QString out = "Public: " + pub.left(pub_prefix_len);
|
||||
for(int i = pub_prefix_len; i < pub.length(); ) {
|
||||
|
||||
if (i == pos) {
|
||||
out += "<font color=red>" + pub.mid(pos, len) + "</font>";
|
||||
i += len;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Look in the dictionary.
|
||||
auto dp = dict_res.find(i);
|
||||
if (dp != dict_res.end()) {
|
||||
int p = (int) dp->first;
|
||||
int l = (int) dp->second;
|
||||
out += "<font color=blue>" + pub.mid(p, l) + "</font>";
|
||||
i += l;
|
||||
continue;
|
||||
}
|
||||
|
||||
out += pub[i++];
|
||||
}
|
||||
|
||||
out += "<br/>Private: " + QString::fromStdString(libantelope::wif_priv_encode(key->secret, codec.pvt));
|
||||
|
||||
// As this function could be called from a non-gui thread. we use signals.
|
||||
emit addOutput("<p>" + out + "</p>");
|
||||
}
|
||||
|
||||
// --------------------
|
||||
// Slots
|
||||
// --------------------
|
||||
|
||||
void SearchWindow::search()
|
||||
{
|
||||
if (m_worker.isRunning()) {
|
||||
m_ksearch.abort();
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string& input = m_txt_search.text().toLocal8Bit().constData();
|
||||
antelopekeygen::strlist_t list;
|
||||
|
||||
if (m_leet_cb.isChecked()) {
|
||||
list = antelopekeygen::l33twords(input);
|
||||
} else {
|
||||
list = antelopekeygen::strlist::splitw(input);
|
||||
}
|
||||
|
||||
// Validate that we atleast got something to search for.
|
||||
if (list.size() < 1 || (list.size() == 1 && list[0] == "")) {
|
||||
QMessageBox::warning( this,
|
||||
"Empty search field.",
|
||||
"You must specify atleast one search string" );
|
||||
return;
|
||||
}
|
||||
|
||||
loadDictionaries();
|
||||
|
||||
m_ksearch.clear();
|
||||
m_ksearch.addList(list);
|
||||
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||
m_ksearch.setThreadCount(m_num_threads.value());
|
||||
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||
|
||||
QFuture<void> future = QtConcurrent::run(&m_ksearch, &antelopekeygen::KeySearch::find, m_num_results.value());
|
||||
m_worker.setFuture(future);
|
||||
|
||||
m_status.setText("Searching for: " + QString::fromStdString(antelopekeygen::strlist::join(list, ", ")));
|
||||
}
|
||||
|
||||
void SearchWindow::output(const std::string& html)
|
||||
{
|
||||
output(QString::fromStdString(html));
|
||||
}
|
||||
|
||||
void SearchWindow::output(const QString& html)
|
||||
{
|
||||
if (m_output.toPlainText().size()) {
|
||||
m_output.setHtml(m_output.toHtml() + html);
|
||||
} else {
|
||||
m_output.setHtml(html);
|
||||
}
|
||||
|
||||
// Force scrollbar to the bottom.
|
||||
m_output.verticalScrollBar()->setValue(m_output.verticalScrollBar()->maximum());
|
||||
}
|
||||
|
||||
void SearchWindow::langFileAdd()
|
||||
{
|
||||
QStringList files = QFileDialog::getOpenFileNames(this,
|
||||
"Select one or more language files");
|
||||
|
||||
m_dict_file.addItems(files, true);
|
||||
}
|
||||
|
||||
void SearchWindow::searchStarted()
|
||||
{
|
||||
// Set prefix for search
|
||||
m_ksearch.setPrefix(Settings::getKeyCodec().pub);
|
||||
|
||||
m_btn_exec.setText("Cancel");
|
||||
|
||||
m_txt_search.setEnabled(false);
|
||||
m_txt_search.setHidden(true);
|
||||
m_dict_lang.setEnabled(false);
|
||||
m_dict_file.setEnabled(false);
|
||||
m_leet_cb.setEnabled(false);
|
||||
m_btn_clear.setEnabled(false);
|
||||
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||
m_num_threads.setEnabled(false);
|
||||
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||
m_num_results.setEnabled(false);
|
||||
}
|
||||
|
||||
void SearchWindow::searchFinished()
|
||||
{
|
||||
m_btn_exec.setText("Search");
|
||||
|
||||
m_txt_search.setEnabled(true);
|
||||
m_txt_search.setHidden(false);
|
||||
m_dict_lang.setEnabled(true);
|
||||
m_dict_file.setEnabled(true);
|
||||
m_leet_cb.setEnabled(true);
|
||||
m_btn_clear.setEnabled(true);
|
||||
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||
m_num_threads.setEnabled(true);
|
||||
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||
m_num_results.setEnabled(true);
|
||||
}
|
||||
117
gui/src/SearchWindow.hpp
Normal file
117
gui/src/SearchWindow.hpp
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef SEARCH_WINDOW_H
|
||||
#define SEARCH_WINDOW_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QSpinBox>
|
||||
#include <QPushButton>
|
||||
#include <QTextEdit>
|
||||
#include <QLineEdit>
|
||||
#include <QCheckBox>
|
||||
#include <QGridLayout>
|
||||
#include <QFutureWatcher>
|
||||
#include <QWidget>
|
||||
#include <eoskeygen/key_search_result.hpp>
|
||||
#include <eoskeygen/key_search.hpp>
|
||||
#include "MultiSelect.hpp"
|
||||
|
||||
class SearchWindow : public QWidget, public antelopekeygen::IKeySearchResult
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SearchWindow(QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags());
|
||||
|
||||
void onResult(const struct libantelope::ec_keypair* key, const struct antelopekeygen::KeySearch::result& result);
|
||||
|
||||
private :
|
||||
void initSignals();
|
||||
|
||||
void loadDictionaries();
|
||||
|
||||
private slots:
|
||||
|
||||
// Start a search
|
||||
void search();
|
||||
|
||||
// Output html to screen.
|
||||
void output(const std::string& html);
|
||||
void output(const QString& html);
|
||||
|
||||
// Called when a search is started.
|
||||
void searchStarted();
|
||||
|
||||
// Called when a search is done.
|
||||
void searchFinished();
|
||||
|
||||
// Called when a new language file should be added
|
||||
void langFileAdd();
|
||||
|
||||
signals:
|
||||
void addOutput(const QString& line);
|
||||
|
||||
private:
|
||||
|
||||
// Search worker thread.
|
||||
QFutureWatcher<void> m_worker;
|
||||
|
||||
antelopekeygen::KeySearch m_ksearch;
|
||||
|
||||
antelopekeygen::Dictionary m_dict;
|
||||
|
||||
// Widgets
|
||||
// ----------------
|
||||
|
||||
// Status text.
|
||||
QLabel m_status;
|
||||
|
||||
// Search input.
|
||||
QLineEdit m_txt_search;
|
||||
|
||||
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||
// Number of Threads.
|
||||
QSpinBox m_num_threads;
|
||||
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||
|
||||
// Number of Results
|
||||
QSpinBox m_num_results;
|
||||
|
||||
QCheckBox m_leet_cb;
|
||||
|
||||
MultiSelect m_dict_lang;
|
||||
|
||||
MultiSelect m_dict_file;
|
||||
|
||||
// Buttons
|
||||
QPushButton m_btn_exec;
|
||||
QPushButton m_btn_clear;
|
||||
|
||||
// Text output.
|
||||
QTextEdit m_output;
|
||||
|
||||
// Gui Layout.
|
||||
QGridLayout m_layout;
|
||||
};
|
||||
|
||||
#endif /* SEARCH_WINDOW_H */
|
||||
37
gui/src/Settings.cpp
Normal file
37
gui/src/Settings.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include "Settings.hpp"
|
||||
|
||||
namespace priv {
|
||||
|
||||
libantelope::wif_codec_t key_format = libantelope::WIF_CODEC_K1;
|
||||
} // namespace priv
|
||||
|
||||
void Settings::setKeyCodec(const libantelope::wif_codec_t& format) {
|
||||
priv::key_format = format;
|
||||
}
|
||||
|
||||
const libantelope::wif_codec_t& Settings::getKeyCodec() {
|
||||
return priv::key_format;
|
||||
}
|
||||
36
gui/src/Settings.hpp
Normal file
36
gui/src/Settings.hpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef SETTINGS_H
|
||||
#define SETTINGS_H
|
||||
|
||||
#include <libantelope/WIF.hpp>
|
||||
|
||||
namespace Settings
|
||||
{
|
||||
void setKeyCodec(const libantelope::wif_codec_t& format);
|
||||
|
||||
const libantelope::wif_codec_t& getKeyCodec();
|
||||
};
|
||||
|
||||
#endif /* SEARCH_WINDOW_H */
|
||||
42
gui/src/helpers.cpp
Normal file
42
gui/src/helpers.cpp
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include "helpers.hpp"
|
||||
|
||||
QStringList get_files(const QDir& directory) {
|
||||
|
||||
QFileInfoList list;
|
||||
QStringList ret;
|
||||
|
||||
list = directory.entryInfoList(QDir::Files);
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
QFileInfo info = list.at(i);
|
||||
ret << info.fileName();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QStringList get_files(const QString& directory)
|
||||
{
|
||||
return get_files(QDir(directory));
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2020 EOS Sw/eden
|
||||
* Copyright (c) 2020-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -21,20 +21,18 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef EC_H
|
||||
#define EC_H
|
||||
#ifndef HELPERS_H
|
||||
#define HELPERS_H
|
||||
|
||||
#include <array>
|
||||
#include "types.h"
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QDir>
|
||||
|
||||
typedef std::array<unsigned char, EC_PRIVKEY_SIZE> ec_privkey_t;
|
||||
typedef std::array<unsigned char, EC_PUBKEY_SIZE> ec_pubkey_t;
|
||||
//
|
||||
// Get a list of files for a given directory.
|
||||
// NOTE: only filenames are returned. relative to directory.
|
||||
//
|
||||
QStringList get_files(const QDir& directory);
|
||||
QStringList get_files(const QString& directory);
|
||||
|
||||
struct ec_keypair {
|
||||
ec_privkey_t secret;
|
||||
ec_pubkey_t pub;
|
||||
};
|
||||
|
||||
int ec_generate_key(struct ec_keypair *pair);
|
||||
|
||||
#endif /* EC_H */
|
||||
#endif /* HELPERS_H */
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2020 EOS Sw/eden
|
||||
* Copyright (c) 2020-2021 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -21,11 +21,16 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef KEY_SEARCH_H
|
||||
#define KEY_SEARCH_H
|
||||
#include <QApplication>
|
||||
#include "MainWindow.hpp"
|
||||
|
||||
#include "string.h"
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
void key_search(strlist_t word_list, size_t n);
|
||||
QApplication app(argc, argv);
|
||||
|
||||
#endif /* KEY_SEARCH_H */
|
||||
MainWindow window;
|
||||
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
pushd build > /dev/null
|
||||
make install $@
|
||||
popd > /dev/null
|
||||
cmake --install build $@
|
||||
|
|
|
|||
2
lib/CLI11/CMakeLists.txt
Normal file
2
lib/CLI11/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
set (LIBCLI11_INCLUDE ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
set (LIBCLI11_LICENSE ${CMAKE_CURRENT_LIST_DIR}/LICENSE)
|
||||
25
lib/CLI11/LICENSE
Normal file
25
lib/CLI11/LICENSE
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
CLI11 2.2 Copyright (c) 2017-2022 University of Cincinnati, developed by Henry
|
||||
Schreiner under NSF AWARD 1414736. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms of CLI11, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
9190
lib/CLI11/include/CLI11/CLI11.hpp
Normal file
9190
lib/CLI11/include/CLI11/CLI11.hpp
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,45 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
PACKAGE_NAME="@PROJECT_NAME@"
|
||||
PACKAGE_VERSION="@PROJECT_VERSION@"
|
||||
PACKAGE_DESCRIPTION="Keygenerator for EOSIO"
|
||||
PACKAGE_PREFIX=$(echo "@CMAKE_INSTALL_PREFIX@" | sed -E 's~^/~~')
|
||||
PACKAGE_BINDIR="@INSTALL_BIN_DIR@"
|
||||
PACKAGE_SHAREDIR="@INSTALL_SHARE_DIR@"
|
||||
PACKAGE_TMPDIR="tmp/debroot"
|
||||
|
||||
# Default to 1 if no release is set.
|
||||
if [[ -z $RELEASE ]]; then
|
||||
RELEASE="1"
|
||||
fi
|
||||
|
||||
PACKAGE_FULLNAME="${PACKAGE_NAME}_${PACKAGE_VERSION}-${RELEASE}_amd64"
|
||||
|
||||
rm -fr ${BASE_DIR}/${PACKAGE_TMPDIR}
|
||||
|
||||
# Create debian files.
|
||||
mkdir -p ${BASE_DIR}/${PACKAGE_TMPDIR}/DEBIAN
|
||||
echo "Package: ${PACKAGE_NAME}
|
||||
Version: ${PACKAGE_VERSION}-${RELEASE}
|
||||
Section: misc
|
||||
Priority: optional
|
||||
Architecture: amd64
|
||||
Homepage: https://github.com/eosswedenorg/eosio-keygen
|
||||
Maintainer: Henrik Hautakoski <henrik@eossweden.org>
|
||||
Description: ${PACKAGE_DESCRIPTION}
|
||||
Depends: libssl1.1, libc6" &> ${BASE_DIR}/${PACKAGE_TMPDIR}/DEBIAN/control
|
||||
|
||||
cat ${BASE_DIR}/${PACKAGE_TMPDIR}/DEBIAN/control
|
||||
|
||||
mkdir -p ${BASE_DIR}/${PACKAGE_TMPDIR}/${PACKAGE_PREFIX}/${PACKAGE_BINDIR}
|
||||
mkdir -p ${BASE_DIR}/${PACKAGE_TMPDIR}/${PACKAGE_PREFIX}/${PACKAGE_SHAREDIR}
|
||||
|
||||
cp ${BASE_DIR}/${PACKAGE_NAME} ${BASE_DIR}/${PACKAGE_TMPDIR}/${PACKAGE_PREFIX}/${PACKAGE_BINDIR}/${PACKAGE_NAME}
|
||||
|
||||
for file in README.md LICENSE LICENSE.bitcoin ; do
|
||||
cp ${BASE_DIR}/../${file} ${BASE_DIR}/${PACKAGE_TMPDIR}/${PACKAGE_PREFIX}/${PACKAGE_SHAREDIR}
|
||||
done
|
||||
|
||||
fakeroot dpkg-deb --build ${BASE_DIR}/${PACKAGE_TMPDIR} ${BASE_DIR}/${PACKAGE_FULLNAME}.deb
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2009-2019 The Bitcoin Core developers
|
||||
* Copyright (c) 2009-2019 Bitcoin Developers
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* Based on code from https://github.com/bitcoin/bitcoin/blob/f1e2f2a85962c1664e4e55471061af0eaa798d40/src/base58.cpp
|
||||
*/
|
||||
#include <cassert>
|
||||
#include "base58.h"
|
||||
|
||||
static const char charmap[59] = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
||||
|
||||
std::string base58_encode(const unsigned char* pbegin, const unsigned char* pend) {
|
||||
|
||||
// Skip & count leading zeroes.
|
||||
int zeroes = 0;
|
||||
int length = 0;
|
||||
while (pbegin != pend && *pbegin == 0) {
|
||||
pbegin++;
|
||||
zeroes++;
|
||||
}
|
||||
// Allocate enough space in big-endian base58 representation.
|
||||
int size = (pend - pbegin) * 138 / 100 + 1; // log(256) / log(58), rounded up.
|
||||
std::vector<unsigned char> b58(size);
|
||||
// Process the bytes.
|
||||
while (pbegin != pend) {
|
||||
int carry = *pbegin;
|
||||
int i = 0;
|
||||
// Apply "b58 = b58 * 256 + ch".
|
||||
for (std::vector<unsigned char>::reverse_iterator it = b58.rbegin(); (carry != 0 || i < length) && (it != b58.rend()); it++, i++) {
|
||||
carry += 256 * (*it);
|
||||
*it = carry % 58;
|
||||
carry /= 58;
|
||||
}
|
||||
|
||||
assert(carry == 0);
|
||||
length = i;
|
||||
pbegin++;
|
||||
}
|
||||
// Skip leading zeroes in base58 result.
|
||||
std::vector<unsigned char>::iterator it = b58.begin() + (size - length);
|
||||
while (it != b58.end() && *it == 0)
|
||||
it++;
|
||||
// Translate the result into a string.
|
||||
std::string str;
|
||||
str.reserve(zeroes + (b58.end() - it));
|
||||
str.assign(zeroes, '1');
|
||||
while (it != b58.end())
|
||||
str += charmap[*(it++)];
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string base58_encode(const std::string& str) {
|
||||
|
||||
const unsigned char *ptr = (const unsigned char *) str.c_str();
|
||||
return base58_encode(ptr, ptr + str.length());
|
||||
}
|
||||
|
||||
std::string base58_encode(const std::vector<unsigned char>& vch) {
|
||||
|
||||
return base58_encode(vch.data(), vch.data() + vch.size());
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2020 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/ripemd.h>
|
||||
#include <cstring>
|
||||
#include "checksum.h"
|
||||
|
||||
inline void sha256d(const unsigned char *data, unsigned int len, unsigned char *out) {
|
||||
SHA256(data, len, out);
|
||||
SHA256(out, 32, out);
|
||||
}
|
||||
|
||||
#define checksum_impl(name, func) \
|
||||
checksum_t checksum_##name(const unsigned char *data, unsigned int len) { \
|
||||
\
|
||||
checksum_t crc; \
|
||||
unsigned char hash[32]; \
|
||||
\
|
||||
func(data, len, hash); \
|
||||
\
|
||||
std::memcpy(crc.data(), hash, crc.size()); \
|
||||
return crc; \
|
||||
}
|
||||
|
||||
|
||||
checksum_impl(sha256d, sha256d)
|
||||
checksum_impl(ripemd160, RIPEMD160)
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
|
||||
#ifdef HAVE_THREADS
|
||||
#include <mutex>
|
||||
#endif /* HAVE_THREADS */
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "ec.h"
|
||||
#include "WIF.h"
|
||||
#include "key_search.h"
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
// Guards result output.
|
||||
std::mutex search_mutex;
|
||||
#endif /* HAVE_THREADS */
|
||||
|
||||
static void key_result(const std::string& word, const struct ec_keypair* pair) {
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
// Guard output with mutex, so we don't get interrupted mid write.
|
||||
const std::lock_guard<std::mutex> lock(search_mutex);
|
||||
#endif /* HAVE_THREADS */
|
||||
|
||||
std::cout << "----" << std::endl;
|
||||
std::cout << "Found: " << word << std::endl;
|
||||
wif_print_key(pair);
|
||||
}
|
||||
|
||||
void key_search(strlist_t word_list, size_t n) {
|
||||
|
||||
size_t count = 0;
|
||||
struct ec_keypair pair;
|
||||
|
||||
while (count < n) {
|
||||
std::string pubstr;
|
||||
ec_generate_key(&pair);
|
||||
pubstr = wif_pub_encode(pair.pub);
|
||||
strtolower(pubstr);
|
||||
|
||||
for(auto const& word: word_list) {
|
||||
if (pubstr.find(word) != std::string::npos) {
|
||||
key_result(word, &pair);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
170
src/main.cpp
170
src/main.cpp
|
|
@ -1,170 +0,0 @@
|
|||
/**
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019-2020 EOS Sw/eden
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include "string.h"
|
||||
#include "base58.h"
|
||||
#include "WIF.h"
|
||||
#include "ec.h"
|
||||
#include "key_search.h"
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
// Minium number of threads.
|
||||
#define MIN_THREADS 2
|
||||
|
||||
// Number of threads to use.
|
||||
static int n_threads = std::thread::hardware_concurrency();
|
||||
|
||||
#define search_func thread_search
|
||||
static void thread_search(const strlist_t& words, int n) {
|
||||
|
||||
std::vector<std::thread> t;
|
||||
int d, m;
|
||||
|
||||
// We can use all threads
|
||||
if (n >= n_threads) {
|
||||
|
||||
// create n_threads - 1 as we use main process also.
|
||||
t.resize(n_threads - 1);
|
||||
// divide the number of results for all threads.
|
||||
d = n / n_threads;
|
||||
// Also calculate the reminder (will be assigned to the main thread)
|
||||
m = n % n_threads;
|
||||
}
|
||||
// not enough results to use all threads.
|
||||
else {
|
||||
t.resize(n);
|
||||
d = 1;
|
||||
m = 0;
|
||||
}
|
||||
|
||||
// Launch threads.
|
||||
for(int i = 0; i < t.size(); i++) {
|
||||
t[i] = std::thread(key_search, words, d);
|
||||
}
|
||||
|
||||
// Use main thread for 1 search
|
||||
key_search(words, d + m);
|
||||
|
||||
// Wait for all threads to compelete.
|
||||
for(int i = 0; i < t.size(); i++) {
|
||||
t[i].join();
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define search_func key_search
|
||||
#endif
|
||||
|
||||
void cmd_search(int argc, char **argv) {
|
||||
|
||||
int n = 100;
|
||||
std::string search(argv[0]);
|
||||
strlist_t words = strsplitwords(strtolower(search));
|
||||
|
||||
if (argc > 1) {
|
||||
n = atoi(argv[1]);
|
||||
if (n < 1) {
|
||||
n = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
if (argc > 2) {
|
||||
n_threads = atoi(argv[2]);
|
||||
// Make sure we never go under min threads.
|
||||
if (n_threads < MIN_THREADS) {
|
||||
n_threads = MIN_THREADS;
|
||||
}
|
||||
}
|
||||
# endif /* HAVE_THREADS */
|
||||
|
||||
std::cout << "Searching for " << n
|
||||
<< " keys containing: " << search
|
||||
#ifdef HAVE_THREADS
|
||||
<< ", Using: " << n_threads << " threads"
|
||||
#endif /* HAVE_THREADS */
|
||||
<< std::endl;
|
||||
|
||||
search_func(words, n);
|
||||
}
|
||||
|
||||
void usage(const char *name) {
|
||||
|
||||
std::cout << name
|
||||
<< " [ --help|-h ] [ search <word_list> [ <count:100> ]"
|
||||
#ifdef HAVE_THREADS
|
||||
<< " [ <threads:2> ]"
|
||||
#endif /* HAVE_THREADS */
|
||||
" ]" << std::endl << std::endl;
|
||||
|
||||
std::cout << " - Output one EOSIO key pair if no arguments are given" << std::endl << std::endl;
|
||||
|
||||
std::cout << " search: " << std::endl
|
||||
<< " performs a search, finding <count> public keys "
|
||||
<< "containing one or more words from <word_list> (separated with ',')."
|
||||
#ifdef HAVE_THREADS
|
||||
<< std::endl << " <threads> specify the number of parallel threads to use."
|
||||
#endif /* HAVE_THREADS */
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
// search <word_list> [ <count> ]
|
||||
if (argc > 1) {
|
||||
|
||||
if (!strcmp(argv[1], "-h") && !strcmp(argv[1], "--help")) {
|
||||
usage(argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "search")) {
|
||||
int n = 100;
|
||||
std::string search;
|
||||
strlist_t words;
|
||||
|
||||
if (argc < 3) {
|
||||
std::cout << "You must specify a word list." << std::endl;
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
cmd_search(argc - 2, &argv[2]);
|
||||
} else {
|
||||
std::cout << "Unrecogniced command: " << argv[1] << std::endl;
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
struct ec_keypair pair;
|
||||
ec_generate_key(&pair);
|
||||
wif_print_key(&pair);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue