1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-keygen synced 2026-06-20 09:56:45 +02:00

Update from libeosio v0.1.7 to libantelope v0.2.0

This commit is contained in:
Henrik Hautakoski 2023-04-06 15:04:12 +02:00
parent d5da7d1491
commit 914205541a
17 changed files with 119 additions and 119 deletions

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
#include <chrono>
#include <libeosio/ec.hpp>
#include <libantelope/ec.hpp>
#include "benchmark.hpp"
namespace eoskeygen {
@ -30,8 +30,8 @@ namespace eoskeygen {
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 libeosio::ec_keypair k;
libeosio::ec_generate_key(&k);
struct libantelope::ec_keypair k;
libantelope::ec_generate_key(&k);
}
return std::chrono::steady_clock::now() - start;
}

View file

@ -23,7 +23,7 @@
*/
#include <string>
#include <iostream>
#include <libeosio/WIF.hpp>
#include <libantelope/WIF.hpp>
#include <eoskeygen/core/dictionary.hpp>
#include "console.hpp"
#include "cli_key_search_result.hpp"
@ -38,15 +38,15 @@ static size_t highlight(console::Color color, const std::string& str, size_t pos
return len;
}
CliKeySearchResult::CliKeySearchResult(const Dictionary& dict, const libeosio::wif_codec_t& codec) :
CliKeySearchResult::CliKeySearchResult(const Dictionary& dict, const libantelope::wif_codec_t& codec) :
m_dict (dict),
m_codec (codec)
{
}
void CliKeySearchResult::onResult(const struct libeosio::ec_keypair* key, const struct KeySearch::result& result) {
void CliKeySearchResult::onResult(const struct libantelope::ec_keypair* key, const struct KeySearch::result& result) {
std::string pub = libeosio::wif_pub_encode(key->pub, m_codec.pub);
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();
@ -71,7 +71,7 @@ void CliKeySearchResult::onResult(const struct libeosio::ec_keypair* key, const
}
std::cout << std::endl
<< "Private: " << libeosio::wif_priv_encode(key->secret, m_codec.pvt) << std::endl;
<< "Private: " << libantelope::wif_priv_encode(key->secret, m_codec.pvt) << std::endl;
}
} // namespace eoskeygen

View file

@ -25,8 +25,8 @@
#define EOSIOKEYGEN_KEY_SEARCH_HELPERS_H
#include <string>
#include <libeosio/ec.hpp>
#include <libeosio/WIF.hpp>
#include <libantelope/ec.hpp>
#include <libantelope/WIF.hpp>
#include <eoskeygen/core/string.hpp>
#include <eoskeygen/key_search.hpp>
#include <eoskeygen/key_search_result.hpp>
@ -38,15 +38,15 @@ class Dictionary;
class CliKeySearchResult : public IKeySearchResult
{
public:
CliKeySearchResult(const Dictionary& dict, const libeosio::wif_codec_t& codec);
CliKeySearchResult(const Dictionary& dict, const libantelope::wif_codec_t& codec);
virtual void onResult(const struct libeosio::ec_keypair* key, const struct KeySearch::result& result);
virtual void onResult(const struct libantelope::ec_keypair* key, const struct KeySearch::result& result);
protected :
const Dictionary& m_dict;
libeosio::wif_codec_t m_codec;
libantelope::wif_codec_t m_codec;
};
} // namespace eoskeygen

View file

@ -24,9 +24,9 @@
#include <iostream>
#include <cstring>
#include <CLI11/CLI11.hpp>
#include <libeosio/base58.hpp>
#include <libeosio/ec.hpp>
#include <libeosio/WIF.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>
@ -40,7 +40,7 @@
// Command line options.
bool option_l33t = false;
libeosio::wif_codec_t key_codec;
libantelope::wif_codec_t key_codec;
#ifdef EOSIOKEYGEN_HAVE_THREADS
size_t option_num_threads;
@ -71,7 +71,7 @@ int cmd_search(const eoskeygen::strlist_t& words, const eoskeygen::Dictionary& d
ks.setCallback(&rs);
for(auto it = words.begin(); it != words.end(); it++) {
size_t p = libeosio::is_base58(*it);
size_t p = libantelope::is_base58(*it);
if (p != std::string::npos) {
std::cerr << "The word '"
<< *it << "' contains an invalid non-base58 character '"
@ -128,7 +128,7 @@ int main(int argc, char **argv) {
size_t bench_count;
int rc = 0;
libeosio::ec_init();
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");
@ -174,11 +174,11 @@ int main(int argc, char **argv) {
}
if (key_format == "fio") {
key_codec = libeosio::wif_create_legacy_codec("FIO");
key_codec = libantelope::wif_create_legacy_codec("FIO");
} else if (key_format == "legacy") {
key_codec = libeosio::WIF_CODEC_LEG;
key_codec = libantelope::WIF_CODEC_LEG;
} else if (key_format == "K1") {
key_codec = libeosio::WIF_CODEC_K1;
key_codec = libantelope::WIF_CODEC_K1;
} else {
std::cerr << "invalid key format: " << key_format << std::endl;
goto end;
@ -236,12 +236,12 @@ int main(int argc, char **argv) {
}
// No subcommand given, just generate and print a keypair.
else {
struct libeosio::ec_keypair pair;
libeosio::ec_generate_key(&pair);
libeosio::wif_print_key(&pair, key_codec);
struct libantelope::ec_keypair pair;
libantelope::ec_generate_key(&pair);
libantelope::wif_print_key(&pair, key_codec);
goto end;
}
end: libeosio::ec_shutdown();
end: libantelope::ec_shutdown();
return rc;
}

View file

@ -40,10 +40,10 @@ add_library( ${COMMON_NAME} STATIC ${COMMON_SOURCE} )
target_include_directories( ${COMMON_NAME} PUBLIC include )
# Link with libeosio and threads library.
include( libeosio )
# Link with libantelope and threads library.
include( libantelope )
target_link_libraries( ${COMMON_NAME}
PUBLIC
libeosio
libantelope
${CMAKE_THREAD_LIBS_INIT}
)

View file

@ -0,0 +1,53 @@
# --------------------------------
# Variables
# --------------------------------
set( LIBANTELOPE_GIT_URL "https://github.com/eosswedenorg/libantelope.git" )
set( LIBANTELOPE_WANTED_VERSION v0.2.0 )
# --------------------------------
# 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()

View file

@ -1,53 +0,0 @@
# --------------------------------
# Variables
# --------------------------------
set( LIBEOSIO_GIT_URL "https://github.com/eosswedenorg/libeosio.git" )
set( LIBEOSIO_WANTED_VERSION v0.1.7 )
# --------------------------------
# Macros
# --------------------------------
macro(fromGit tag)
message ("Using libeosio from: ${LIBEOSIO_GIT_URL}@${tag}")
include(FetchContent)
FetchContent_Declare(libeosio
GIT_REPOSITORY ${LIBEOSIO_GIT_URL}
GIT_TAG ${tag}
SOURCE_DIR ${DOWNLOAD_CACHE_DIR}/libeosio/src
STAMP_DIR ${DOWNLOAD_CACHE_DIR}/libeosio/stamp
)
FetchContent_GetProperties(libeosio)
if (NOT libeosio_POPULATED)
FetchContent_Populate(libeosio)
add_subdirectory(${libeosio_SOURCE_DIR} ${libeosio_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
endmacro()
macro(buildLocal src)
message ("Using local libeosio at: ${src}")
add_subdirectory(${src} ${src}/build EXCLUDE_FROM_ALL)
endmacro()
# If we have a locallibeosio
if (LIBEOSIO_SOURCE_DIR)
buildLocal( ${LIBEOSIO_SOURCE_DIR} )
else()
# Check if version is in fact a version.
if (LIBEOSIO_WANTED_VERSION MATCHES "^[0-9]+(.[0-9]+)?(.[0-9]+)(-[a-zA-Z0-9]+)?$")
# Try finding the package on the system.
find_package(libeosio ${LIBEOSIO_WANTED_VERSION} QUIET)
if (libeoskeygen_FOUND)
message ("Using libeosio in: ${libeosio_DIR}")
# Not found, download from git.
else()
fromGit( v${LIBEOSIO_WANTED_VERSION} )
endif()
# Assume version contains a git branch.
else()
fromGit( ${LIBEOSIO_WANTED_VERSION} )
endif()
endif()

View file

@ -26,7 +26,7 @@
#include <stdint.h>
#include <string>
#include <libeosio/ec.hpp>
#include <libantelope/ec.hpp>
#include <eoskeygen/config.hpp>
#include <eoskeygen/core/dictionary.hpp>
#include <eoskeygen/core/strlist.hpp>
@ -88,7 +88,7 @@ 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 libeosio::ec_keypair* key, struct result& result);
bool _contains_word(const struct libantelope::ec_keypair* key, struct result& result);
#ifdef EOSIOKEYGEN_HAVE_THREADS
void _thr_proc();

View file

@ -32,7 +32,7 @@ class IKeySearchResult
{
public :
virtual void onResult(const struct libeosio::ec_keypair* key, const struct KeySearch::result& result) = 0;
virtual void onResult(const struct libantelope::ec_keypair* key, const struct KeySearch::result& result) = 0;
};
} // namespace eoskeygen

View file

@ -21,8 +21,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <libeosio/ec.hpp>
#include <libeosio/WIF.hpp>
#include <libantelope/ec.hpp>
#include <libantelope/WIF.hpp>
#include <eoskeygen/config.hpp>
#include <eoskeygen/core/string.hpp>
#include <eoskeygen/key_search_result.hpp>
@ -77,11 +77,11 @@ void KeySearch::setCallback(IKeySearchResult* callback)
void KeySearch::_search_linear()
{
struct libeosio::ec_keypair pair;
struct libantelope::ec_keypair pair;
while (m_count < m_max) {
struct result res;
libeosio::ec_generate_key(&pair);
libantelope::ec_generate_key(&pair);
if (_contains_word(&pair, res)) {
m_callback->onResult(&pair, res);
m_count++;
@ -111,10 +111,10 @@ void KeySearch::find(size_t num_results)
_search_linear();
}
bool KeySearch::_contains_word(const struct libeosio::ec_keypair* key, struct result& result) {
bool KeySearch::_contains_word(const struct libantelope::ec_keypair* key, struct result& result) {
size_t prefix_len = m_prefix.length();
std::string pubstr = libeosio::wif_pub_encode(key->pub, m_prefix).substr(prefix_len);
std::string pubstr = libantelope::wif_pub_encode(key->pub, m_prefix).substr(prefix_len);
strtolower(pubstr);
for(auto const& w: m_words) {

View file

@ -25,7 +25,7 @@
#include <thread>
#include <mutex>
#include <vector>
#include <libeosio/ec.hpp>
#include <libantelope/ec.hpp>
#include <eoskeygen/key_search_result.hpp>
#include <eoskeygen/key_search.hpp>
@ -37,12 +37,12 @@ std::mutex g_count_mtx;
// Thread process.
void KeySearch::_thr_proc()
{
struct libeosio::ec_keypair pair;
struct libantelope::ec_keypair pair;
while (m_count < m_max) {
struct result res;
libeosio::ec_generate_key(&pair);
libantelope::ec_generate_key(&pair);
if (_contains_word(&pair, res)) {
// Guard output with mutex, so we don't get

View file

@ -28,8 +28,8 @@
#include <QGuiApplication>
#include <QFont>
#include <QFontDatabase>
#include <libeosio/ec.hpp>
#include <libeosio/WIF.hpp>
#include <libantelope/ec.hpp>
#include <libantelope/WIF.hpp>
#include "Settings.hpp"
#include "GenerateWindow.hpp"
@ -98,13 +98,13 @@ m_btn_copy_both ("Copy keys")
void GenerateWindow::generate_key()
{
std::string pubstr, pvtstr;
struct libeosio::ec_keypair pair;
const libeosio::wif_codec_t& codec = Settings::getKeyCodec();
struct libantelope::ec_keypair pair;
const libantelope::wif_codec_t& codec = Settings::getKeyCodec();
libeosio::ec_generate_key(&pair);
libantelope::ec_generate_key(&pair);
pubstr = libeosio::wif_pub_encode(pair.pub, codec.pub);
pvtstr = libeosio::wif_priv_encode(pair.secret, codec.pvt);
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));
}

View file

@ -25,7 +25,7 @@
#include <QMenuBar>
#include <QGridLayout>
#include <QStackedWidget>
#include <libeosio/WIF.hpp>
#include <libantelope/WIF.hpp>
#include "gui_text.h"
#include "Settings.hpp"
#include "GenerateWindow.hpp"
@ -38,7 +38,7 @@ m_format_fio_action (nullptr),
m_format_legacy_action (nullptr),
m_format_k1_action (nullptr)
{
libeosio::ec_init();
libantelope::ec_init();
// Create sub windows and stacked widget.
m_stacked = new QStackedWidget();
@ -83,7 +83,7 @@ m_format_k1_action (nullptr)
MainWindow::~MainWindow()
{
libeosio::ec_shutdown();
libantelope::ec_shutdown();
}
void MainWindow::switchToGenerate()
@ -106,20 +106,20 @@ void MainWindow::showAbout()
void MainWindow::formatFioCheckboxChanged()
{
if (m_format_fio_action->isChecked()) {
Settings::setKeyCodec(libeosio::wif_create_legacy_codec("FIO"));
Settings::setKeyCodec(libantelope::wif_create_legacy_codec("FIO"));
}
}
void MainWindow::formatLegacyCheckboxChanged()
{
if (m_format_legacy_action->isChecked()) {
Settings::setKeyCodec(libeosio::WIF_CODEC_LEG);
Settings::setKeyCodec(libantelope::WIF_CODEC_LEG);
}
}
void MainWindow::formatK1CheckboxChanged()
{
if (m_format_k1_action->isChecked()) {
Settings::setKeyCodec(libeosio::WIF_CODEC_K1);
Settings::setKeyCodec(libantelope::WIF_CODEC_K1);
}
}

View file

@ -28,7 +28,7 @@
#include <QGridLayout>
#include <QFuture>
#include <QtConcurrent>
#include <libeosio/WIF.hpp>
#include <libantelope/WIF.hpp>
#include <eoskeygen/core/leet.hpp>
#include <eoskeygen/core/string.hpp>
#include "Settings.hpp"
@ -146,12 +146,12 @@ void SearchWindow::loadDictionaries()
}
}
void SearchWindow::onResult(const struct libeosio::ec_keypair* key, const struct eoskeygen::KeySearch::result& result)
void SearchWindow::onResult(const struct libantelope::ec_keypair* key, const struct eoskeygen::KeySearch::result& result)
{
int pos = (int) result.pos;
int len = (int) result.len;
libeosio::wif_codec_t codec = Settings::getKeyCodec();
QString pub = QString::fromStdString(libeosio::wif_pub_encode(key->pub, codec.pub));
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);
@ -180,7 +180,7 @@ void SearchWindow::onResult(const struct libeosio::ec_keypair* key, const struct
out += pub[i++];
}
out += "<br/>Private: " + QString::fromStdString(libeosio::wif_priv_encode(key->secret, codec.pvt));
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>");

View file

@ -43,7 +43,7 @@ class SearchWindow : public QWidget, public eoskeygen::IKeySearchResult
public:
explicit SearchWindow(QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags());
void onResult(const struct libeosio::ec_keypair* key, const struct eoskeygen::KeySearch::result& result);
void onResult(const struct libantelope::ec_keypair* key, const struct eoskeygen::KeySearch::result& result);
private :
void initSignals();

View file

@ -25,13 +25,13 @@
namespace priv {
libeosio::wif_codec_t key_format = libeosio::WIF_CODEC_K1;
libantelope::wif_codec_t key_format = libantelope::WIF_CODEC_K1;
} // namespace priv
void Settings::setKeyCodec(const libeosio::wif_codec_t& format) {
void Settings::setKeyCodec(const libantelope::wif_codec_t& format) {
priv::key_format = format;
}
const libeosio::wif_codec_t& Settings::getKeyCodec() {
const libantelope::wif_codec_t& Settings::getKeyCodec() {
return priv::key_format;
}

View file

@ -24,13 +24,13 @@
#ifndef SETTINGS_H
#define SETTINGS_H
#include <libeosio/WIF.hpp>
#include <libantelope/WIF.hpp>
namespace Settings
{
void setKeyCodec(const libeosio::wif_codec_t& format);
void setKeyCodec(const libantelope::wif_codec_t& format);
const libeosio::wif_codec_t& getKeyCodec();
const libantelope::wif_codec_t& getKeyCodec();
};
#endif /* SEARCH_WINDOW_H */