1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-keygen synced 2026-07-04 12:03:41 +02:00

Merge pull request #35 from eosswedenorg/fio

Adding FIO support
This commit is contained in:
Henrik Hautakoski 2021-05-07 13:59:51 +02:00 committed by GitHub
commit a73689e275
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 130 additions and 16 deletions

View file

@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*/ */
#include <string>
#include <iostream> #include <iostream>
#include <libeosio/WIF.hpp> #include <libeosio/WIF.hpp>
#include <eoskeygen/core/dictionary.hpp> #include <eoskeygen/core/dictionary.hpp>
@ -37,8 +38,9 @@ static size_t highlight(console::Color color, const std::string& str, size_t pos
return len; return len;
} }
CliKeySearchResult::CliKeySearchResult(const Dictionary& dict) : CliKeySearchResult::CliKeySearchResult(const Dictionary& dict, const std::string& prefix) :
m_dict (dict) m_dict (dict),
m_prefix (prefix)
{ {
} }
@ -50,7 +52,7 @@ void CliKeySearchResult::onResult(const struct libeosio::ec_keypair* key, const
std::cout << "----" << std::endl; std::cout << "----" << std::endl;
std::cout << "Found: " << pub.substr(result.pos, result.len) << std::endl; std::cout << "Found: " << pub.substr(result.pos, result.len) << std::endl;
std::cout << "Public: EOS"; std::cout << "Public: " << m_prefix.substr(0, 3);
for(size_t i = 3; i < pub.length(); ) { for(size_t i = 3; i < pub.length(); ) {
if (i == result.pos) { if (i == result.pos) {

View file

@ -24,6 +24,7 @@
#ifndef EOSIOKEYGEN_KEY_SEARCH_HELPERS_H #ifndef EOSIOKEYGEN_KEY_SEARCH_HELPERS_H
#define EOSIOKEYGEN_KEY_SEARCH_HELPERS_H #define EOSIOKEYGEN_KEY_SEARCH_HELPERS_H
#include <string>
#include <libeosio/types.hpp> #include <libeosio/types.hpp>
#include <eoskeygen/core/string.hpp> #include <eoskeygen/core/string.hpp>
#include <eoskeygen/key_search.hpp> #include <eoskeygen/key_search.hpp>
@ -36,13 +37,15 @@ class Dictionary;
class CliKeySearchResult : public IKeySearchResult class CliKeySearchResult : public IKeySearchResult
{ {
public: public:
CliKeySearchResult(const Dictionary& dict); CliKeySearchResult(const Dictionary& dict, const std::string& prefix);
virtual void onResult(const struct libeosio::ec_keypair* key, const struct KeySearch::result& result); virtual void onResult(const struct libeosio::ec_keypair* key, const struct KeySearch::result& result);
protected : protected :
const Dictionary& m_dict; const Dictionary& m_dict;
std::string m_prefix;
}; };
} // namespace eoskeygen } // namespace eoskeygen

View file

@ -39,6 +39,7 @@
// Command line options. // Command line options.
bool option_l33t = false; bool option_l33t = false;
std::string key_prefix = "EOS";
#ifdef EOSIOKEYGEN_HAVE_THREADS #ifdef EOSIOKEYGEN_HAVE_THREADS
size_t option_num_threads = eoskeygen::KeySearch::max_threads(); size_t option_num_threads = eoskeygen::KeySearch::max_threads();
@ -48,10 +49,10 @@ void usage(const char *name) {
std::cout << std::endl std::cout << std::endl
<< "Usage:" << std::endl << "Usage:" << std::endl
<< " " << name << std::endl; << " " << name << " [ options ]" << std::endl;
std::cout << " " << name std::cout << " " << name
<< " search [ -m | --l33t" << " [ options ] search [ -m | --l33t"
#ifdef EOSIOKEYGEN_HAVE_THREADS #ifdef EOSIOKEYGEN_HAVE_THREADS
<< " | --threads=<num>" << " | --threads=<num>"
#endif /* EOSIOKEYGEN_HAVE_THREADS */ #endif /* EOSIOKEYGEN_HAVE_THREADS */
@ -60,7 +61,7 @@ void usage(const char *name) {
<< " ]" << " ]"
<< std::endl; << std::endl;
std::cout << " " << name << " benchmark [ <num:1000> ]" << std::endl; std::cout << " " << name << " [ options ] benchmark [ <num:1000> ]" << std::endl;
std::cout << " " << name << " -h | --help" << std::endl; std::cout << " " << name << " -h | --help" << std::endl;
std::cout << " " << name << " -v" << std::endl; std::cout << " " << name << " -v" << std::endl;
@ -73,6 +74,8 @@ void usage(const char *name) {
<< " -h --help Shows this help text." << " -h --help Shows this help text."
<< std::endl << std::endl << std::endl << std::endl
<< " -v Shows version." << " -v Shows version."
<< std::endl << std::endl
<< " --fio Generate keys from FIO network instead of EOSIO."
<< std::endl << std::endl; << std::endl << std::endl;
std::cout << "search: " << std::endl std::cout << "search: " << std::endl
@ -112,7 +115,7 @@ void usage(const char *name) {
int cmd_search(const eoskeygen::strlist_t& words, const eoskeygen::Dictionary& dict, int count) { int cmd_search(const eoskeygen::strlist_t& words, const eoskeygen::Dictionary& dict, int count) {
eoskeygen::KeySearch ks; eoskeygen::KeySearch ks;
eoskeygen::CliKeySearchResult rs(dict); eoskeygen::CliKeySearchResult rs(dict, key_prefix);
ks.setCallback(&rs); ks.setCallback(&rs);
@ -169,11 +172,16 @@ int main(int argc, char **argv) {
// when parsing command line. // when parsing command line.
int p = 1; int p = 1;
if (p < argc && !strcmp(argv[p], "--fio")) {
p++;
key_prefix = "FIO";
}
// No args, just print a key. // No args, just print a key.
if (argc <= 1) { if (p >= argc) {
struct libeosio::ec_keypair pair; struct libeosio::ec_keypair pair;
libeosio::ec_generate_key(&pair); libeosio::ec_generate_key(&pair);
libeosio::wif_print_key(&pair); libeosio::wif_print_key(&pair, key_prefix);
return 0; return 0;
} }

View file

@ -2,7 +2,7 @@
# Variables # Variables
# -------------------------------- # --------------------------------
set( LIBEOSIO_GIT_URL "https://github.com/eosswedenorg/libeosio.git" ) set( LIBEOSIO_GIT_URL "https://github.com/eosswedenorg/libeosio.git" )
set( LIBEOSIO_WANTED_VERSION v0.1.2 ) set( LIBEOSIO_WANTED_VERSION v0.1.3 )
# -------------------------------- # --------------------------------
# Macros # Macros

View file

@ -39,6 +39,7 @@ set( PROGRAM_SRC
src/GenerateWindow.cpp src/GenerateWindow.cpp
src/SearchWindow.cpp src/SearchWindow.cpp
src/MultiSelect.cpp src/MultiSelect.cpp
src/Settings.cpp
src/helpers.cpp src/helpers.cpp
) )

View file

@ -28,6 +28,7 @@
#include <QGuiApplication> #include <QGuiApplication>
#include <libeosio/ec.hpp> #include <libeosio/ec.hpp>
#include <libeosio/WIF.hpp> #include <libeosio/WIF.hpp>
#include "Settings.hpp"
#include "GenerateWindow.hpp" #include "GenerateWindow.hpp"
void _initKeyWidget(QLineEdit& w) { void _initKeyWidget(QLineEdit& w) {
@ -91,12 +92,13 @@ m_btn_copy_both ("Copy keys")
void GenerateWindow::generate_key() void GenerateWindow::generate_key()
{ {
std::string pubstr, privstr; std::string pubstr;
struct libeosio::ec_keypair pair; struct libeosio::ec_keypair pair;
libeosio::ec_generate_key(&pair); libeosio::ec_generate_key(&pair);
m_pub.setText(QString::fromStdString(libeosio::wif_pub_encode(pair.pub))); pubstr = libeosio::wif_pub_encode(pair.pub, Settings::shouldGenerateFioKeys() ? "FIO" : "EOS");
m_pub.setText(QString::fromStdString(pubstr));
m_priv.setText(QString::fromStdString(libeosio::wif_priv_encode(pair.secret))); m_priv.setText(QString::fromStdString(libeosio::wif_priv_encode(pair.secret)));
} }

View file

@ -26,12 +26,14 @@
#include <QGridLayout> #include <QGridLayout>
#include <QStackedWidget> #include <QStackedWidget>
#include "gui_text.h" #include "gui_text.h"
#include "Settings.hpp"
#include "GenerateWindow.hpp" #include "GenerateWindow.hpp"
#include "SearchWindow.hpp" #include "SearchWindow.hpp"
#include "MainWindow.hpp" #include "MainWindow.hpp"
MainWindow::MainWindow(QWidget *parent) : MainWindow::MainWindow(QWidget *parent) :
QMainWindow (parent) QMainWindow (parent),
m_fio_action (nullptr)
{ {
// Create sub windows and stacked widget. // Create sub windows and stacked widget.
m_stacked = new QStackedWidget(); m_stacked = new QStackedWidget();
@ -40,10 +42,21 @@ QMainWindow (parent)
setCentralWidget(m_stacked); setCentralWidget(m_stacked);
// Menu bar. // Add to menu bar.
menuBar()->addAction("Generate", this, SLOT(switchToGenerate())); menuBar()->addAction("Generate", this, SLOT(switchToGenerate()));
menuBar()->addAction("Search", this, SLOT(switchToSearch())); menuBar()->addAction("Search", this, SLOT(switchToSearch()));
// Settings
m_fio_action = new QAction("FIO Keys", this);
m_fio_action->setCheckable(true);
connect(m_fio_action, SIGNAL(triggered()), this, SLOT(fioKeysCheckboxChanged()));
QMenu *settings_menu = menuBar()->addMenu("Settings");
settings_menu->addAction(m_fio_action);
// About
menuBar()->addAction("About", this, SLOT(showAbout())); menuBar()->addAction("About", this, SLOT(showAbout()));
} }
@ -63,3 +76,8 @@ void MainWindow::showAbout()
EOSIOKEYGEN_GUI_TEXT_ABOUT_TITLE, EOSIOKEYGEN_GUI_TEXT_ABOUT_TITLE,
EOSIOKEYGEN_GUI_TEXT_ABOUT_BODY); EOSIOKEYGEN_GUI_TEXT_ABOUT_BODY);
} }
void MainWindow::fioKeysCheckboxChanged()
{
Settings::setGenerateFioKeys(m_fio_action ? m_fio_action->isChecked() : false);
}

View file

@ -24,6 +24,8 @@
#ifndef MAIN_WINDOW_H #ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H #define MAIN_WINDOW_H
#include <QAction>
#include <QPointer>
#include <QMainWindow> #include <QMainWindow>
class QStackedWidget; class QStackedWidget;
@ -44,9 +46,13 @@ private slots :
void showAbout(); void showAbout();
void fioKeysCheckboxChanged();
private : private :
QStackedWidget* m_stacked; QStackedWidget* m_stacked;
QPointer<QAction> m_fio_action;
}; };
#endif /* MAIN_WINDOW_H */ #endif /* MAIN_WINDOW_H */

View file

@ -31,6 +31,7 @@
#include <libeosio/WIF.hpp> #include <libeosio/WIF.hpp>
#include <eoskeygen/core/leet.hpp> #include <eoskeygen/core/leet.hpp>
#include <eoskeygen/core/string.hpp> #include <eoskeygen/core/string.hpp>
#include "Settings.hpp"
#include "gui_text.h" #include "gui_text.h"
#include "config.hpp" #include "config.hpp"
#include "helpers.hpp" #include "helpers.hpp"
@ -149,7 +150,7 @@ void SearchWindow::onResult(const struct libeosio::ec_keypair* key, const struct
{ {
int pos = (int) result.pos; int pos = (int) result.pos;
int len = (int) result.len; int len = (int) result.len;
QString pub = QString::fromStdString(libeosio::wif_pub_encode(key->pub)); QString pub = QString::fromStdString(libeosio::wif_pub_encode(key->pub, Settings::shouldGenerateFioKeys() ? "FIO" : "EOS"));
QString mid = pub.mid(pos, len); QString mid = pub.mid(pos, len);
QString left = pub.left(pos); QString left = pub.left(pos);
QString right = pub.mid(pos + len, pub.size() - pos); QString right = pub.mid(pos + len, pub.size() - pos);

39
gui/src/Settings.cpp Normal file
View file

@ -0,0 +1,39 @@
/**
* 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 {
bool fio_keys = false;
} // namespace priv
bool Settings::shouldGenerateFioKeys()
{
return priv::fio_keys;
}
void Settings::setGenerateFioKeys(bool value)
{
priv::fio_keys = value;
}

34
gui/src/Settings.hpp Normal file
View file

@ -0,0 +1,34 @@
/**
* 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
namespace Settings
{
bool shouldGenerateFioKeys();
void setGenerateFioKeys(bool value);
};
#endif /* SEARCH_WINDOW_H */