mirror of
https://github.com/eosswedenorg/antelope-keygen
synced 2026-07-02 11:43:40 +02:00
Use the "common" subfolder instead of libeoskeygen repository.
This commit is contained in:
parent
654a53698f
commit
dd9dd484e3
6 changed files with 34 additions and 83 deletions
|
|
@ -13,8 +13,6 @@ option(FORCE_ANSI "Force ANSI console colors even on windows" OFF)
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
|
||||||
|
|
||||||
include(libeoskeygen)
|
|
||||||
|
|
||||||
# Use installpath from GNUInstallDirs as default.
|
# Use installpath from GNUInstallDirs as default.
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
|
@ -39,6 +37,11 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
add_definitions( "-D_CRT_SECURE_NO_WARNINGS=1" )
|
add_definitions( "-D_CRT_SECURE_NO_WARNINGS=1" )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# --------------------------------
|
||||||
|
# Common code
|
||||||
|
# --------------------------------
|
||||||
|
add_subdirectory( common )
|
||||||
|
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
# Program
|
# Program
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
|
|
@ -66,7 +69,7 @@ include_directories(${PROJECT_BINARY_DIR})
|
||||||
|
|
||||||
add_executable( ${PROGRAM_EXE} ${PROGRAM_SOURCE} )
|
add_executable( ${PROGRAM_EXE} ${PROGRAM_SOURCE} )
|
||||||
|
|
||||||
target_link_libraries( ${PROGRAM_EXE} PUBLIC eoskeygen )
|
target_link_libraries( ${PROGRAM_EXE} PUBLIC common )
|
||||||
|
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
# Install
|
# Install
|
||||||
|
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
|
|
||||||
# --------------------------------
|
|
||||||
# Variables
|
|
||||||
# --------------------------------
|
|
||||||
set( LIBEOSKEYGEN_GIT_URL "https://github.com/eosswedenorg/libeoskeygen.git" )
|
|
||||||
set( LIBEOSKEYGEN_WANTED_VERSION 0.1.1 )
|
|
||||||
|
|
||||||
# --------------------------------
|
|
||||||
# Macros
|
|
||||||
# --------------------------------
|
|
||||||
macro(fromGit tag)
|
|
||||||
|
|
||||||
message ("Using libeoskeygen from: ${LIBEOSKEYGEN_GIT_URL}@${tag}")
|
|
||||||
|
|
||||||
include(FetchContent)
|
|
||||||
FetchContent_Declare(libeoskeygen
|
|
||||||
GIT_REPOSITORY ${LIBEOSKEYGEN_GIT_URL}
|
|
||||||
GIT_TAG ${tag}
|
|
||||||
)
|
|
||||||
|
|
||||||
FetchContent_GetProperties(libeoskeygen)
|
|
||||||
if (NOT libeoskeygen_POPULATED)
|
|
||||||
FetchContent_Populate(libeoskeygen)
|
|
||||||
add_subdirectory(${libeoskeygen_SOURCE_DIR} ${libeoskeygen_BINARY_DIR} EXCLUDE_FROM_ALL)
|
|
||||||
endif()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
macro(buildLocal src)
|
|
||||||
message ("Using local libeoskeygen at: ${src}")
|
|
||||||
add_subdirectory(${src} ${src}/build EXCLUDE_FROM_ALL)
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
# If we have a local libeoskeygen
|
|
||||||
if (LIBEOSKEYGEN_SOURCE_DIR)
|
|
||||||
buildLocal( ${LIBEOSKEYGEN_SOURCE_DIR} )
|
|
||||||
else()
|
|
||||||
|
|
||||||
# Check if version is in fact a version.
|
|
||||||
if (LIBEOSKEYGEN_WANTED_VERSION MATCHES "^[0-9]+(.[0-9]+)?(.[0-9]+)(-[a-zA-Z0-9]+)?$")
|
|
||||||
# Try finding the package on the system.
|
|
||||||
find_package(libeoskeygen ${LIBEOSKEYGEN_WANTED_VERSION} QUIET)
|
|
||||||
if (libeoskeygen_FOUND)
|
|
||||||
message ("Using libeoskeygen in: ${libeoskeygen_DIR}")
|
|
||||||
# Not found, download from git.
|
|
||||||
else()
|
|
||||||
fromGit( v${LIBEOSKEYGEN_WANTED_VERSION} )
|
|
||||||
endif()
|
|
||||||
# Assume version contains a git branch.
|
|
||||||
else()
|
|
||||||
fromGit( ${LIBEOSKEYGEN_WANTED_VERSION} )
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <eoskeygen/crypto/ec.h>
|
#include <libeosio/ec.h>
|
||||||
#include "benchmark.h"
|
#include "benchmark.h"
|
||||||
|
|
||||||
using std::chrono::steady_clock;
|
using std::chrono::steady_clock;
|
||||||
|
|
@ -43,8 +43,8 @@ void benchmark(size_t num_keys, struct benchmark_result* res) {
|
||||||
start = steady_clock::now();
|
start = steady_clock::now();
|
||||||
|
|
||||||
for(size_t i = 0; i < num_keys; i++) {
|
for(size_t i = 0; i < num_keys; i++) {
|
||||||
struct ec_keypair k;
|
struct libeosio::ec_keypair k;
|
||||||
ec_generate_key(&k);
|
libeosio::ec_generate_key(&k);
|
||||||
}
|
}
|
||||||
|
|
||||||
res->sec = duration<float>(steady_clock::now() - start).count();
|
res->sec = duration<float>(steady_clock::now() - start).count();
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <libeosio/WIF.h>
|
||||||
#include <eoskeygen/core/dictionary.h>
|
#include <eoskeygen/core/dictionary.h>
|
||||||
#include <eoskeygen/crypto/WIF.h>
|
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "cli_key_search_result.h"
|
#include "cli_key_search_result.h"
|
||||||
|
|
||||||
|
|
@ -42,9 +42,9 @@ m_dict (dict)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CliKeySearchResult::onResult(const struct ec_keypair* key, const struct KeySearch::result& result) {
|
void CliKeySearchResult::onResult(const struct libeosio::ec_keypair* key, const struct KeySearch::result& result) {
|
||||||
|
|
||||||
std::string pub = wif_pub_encode(key->pub);
|
std::string pub = libeosio::wif_pub_encode(key->pub);
|
||||||
Dictionary::search_result_t dict_res = m_dict.search(pub);
|
Dictionary::search_result_t dict_res = m_dict.search(pub);
|
||||||
|
|
||||||
std::cout << "----" << std::endl;
|
std::cout << "----" << std::endl;
|
||||||
|
|
@ -68,7 +68,7 @@ void CliKeySearchResult::onResult(const struct ec_keypair* key, const struct Key
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << std::endl
|
std::cout << std::endl
|
||||||
<< "Private: " << wif_priv_encode(key->secret) << std::endl;
|
<< "Private: " << libeosio::wif_priv_encode(key->secret) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace eoskeygen
|
} // namespace eoskeygen
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@
|
||||||
#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 <libeosio/types.h>
|
||||||
#include <eoskeygen/core/string.h>
|
#include <eoskeygen/core/string.h>
|
||||||
#include <eoskeygen/crypto/types.h>
|
|
||||||
#include <eoskeygen/key_search.h>
|
#include <eoskeygen/key_search.h>
|
||||||
#include <eoskeygen/key_search_result.h>
|
#include <eoskeygen/key_search_result.h>
|
||||||
|
|
||||||
|
|
@ -38,7 +38,7 @@ class CliKeySearchResult : public IKeySearchResult
|
||||||
public:
|
public:
|
||||||
CliKeySearchResult(const Dictionary& dict);
|
CliKeySearchResult(const Dictionary& dict);
|
||||||
|
|
||||||
virtual void onResult(const struct ec_keypair* key, const struct KeySearch::result& result);
|
virtual void onResult(const struct libeosio::ec_keypair* key, const struct KeySearch::result& result);
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
|
|
||||||
|
|
|
||||||
38
src/main.cpp
38
src/main.cpp
|
|
@ -23,13 +23,13 @@
|
||||||
*/
|
*/
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <libeosio/base58.h>
|
||||||
|
#include <libeosio/ec.h>
|
||||||
|
#include <libeosio/WIF.h>
|
||||||
#include <eoskeygen/config.h>
|
#include <eoskeygen/config.h>
|
||||||
#include <eoskeygen/core/file.h>
|
#include <eoskeygen/core/file.h>
|
||||||
#include <eoskeygen/core/string.h>
|
#include <eoskeygen/core/string.h>
|
||||||
#include <eoskeygen/core/dictionary.h>
|
#include <eoskeygen/core/dictionary.h>
|
||||||
#include <eoskeygen/crypto/base58.h>
|
|
||||||
#include <eoskeygen/crypto/ec.h>
|
|
||||||
#include <eoskeygen/crypto/WIF.h>
|
|
||||||
#include <eoskeygen/core/leet.h>
|
#include <eoskeygen/core/leet.h>
|
||||||
#include <eoskeygen/key_search.h>
|
#include <eoskeygen/key_search.h>
|
||||||
#include "cli_key_search_result.h"
|
#include "cli_key_search_result.h"
|
||||||
|
|
@ -40,9 +40,9 @@
|
||||||
// Command line options.
|
// Command line options.
|
||||||
bool option_l33t = false;
|
bool option_l33t = false;
|
||||||
|
|
||||||
#ifdef LIBEOSKEYGEN_HAVE_THREADS
|
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||||
size_t option_num_threads = eoskeygen::KeySearch::max_threads();
|
size_t option_num_threads = eoskeygen::KeySearch::max_threads();
|
||||||
#endif /* LIBEOSKEYGEN_HAVE_THREADS */
|
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||||
|
|
||||||
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) {
|
||||||
|
|
||||||
|
|
@ -52,7 +52,7 @@ int cmd_search(const eoskeygen::strlist_t& words, const eoskeygen::Dictionary& d
|
||||||
ks.setCallback(&rs);
|
ks.setCallback(&rs);
|
||||||
|
|
||||||
for(auto it = words.begin(); it != words.end(); it++) {
|
for(auto it = words.begin(); it != words.end(); it++) {
|
||||||
size_t p = eoskeygen::is_base58(*it);
|
size_t p = libeosio::is_base58(*it);
|
||||||
if (p != std::string::npos) {
|
if (p != std::string::npos) {
|
||||||
std::cerr << "The word '"
|
std::cerr << "The word '"
|
||||||
<< *it << "' contains an invalid non-base58 character '"
|
<< *it << "' contains an invalid non-base58 character '"
|
||||||
|
|
@ -69,15 +69,15 @@ int cmd_search(const eoskeygen::strlist_t& words, const eoskeygen::Dictionary& d
|
||||||
ks.addList(words);
|
ks.addList(words);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LIBEOSKEYGEN_HAVE_THREADS
|
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||||
ks.setThreadCount(option_num_threads);
|
ks.setThreadCount(option_num_threads);
|
||||||
#endif /* LIBEOSKEYGEN_HAVE_THREADS */
|
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||||
|
|
||||||
std::cout << "Searching for " << count
|
std::cout << "Searching for " << count
|
||||||
<< " keys containing: " << eoskeygen::strlist::join(ks.getList(), ",")
|
<< " keys containing: " << eoskeygen::strlist::join(ks.getList(), ",")
|
||||||
#ifdef LIBEOSKEYGEN_HAVE_THREADS
|
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||||
<< ", Using: " << option_num_threads << " threads"
|
<< ", Using: " << option_num_threads << " threads"
|
||||||
#endif /* LIBEOSKEYGEN_HAVE_THREADS */
|
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
ks.find(count);
|
ks.find(count);
|
||||||
|
|
@ -89,9 +89,9 @@ void usage(const char *name) {
|
||||||
|
|
||||||
std::cout << name
|
std::cout << name
|
||||||
<< " [ -h | --help | -v | search [ -m | --l33t"
|
<< " [ -h | --help | -v | search [ -m | --l33t"
|
||||||
#ifdef LIBEOSKEYGEN_HAVE_THREADS
|
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||||
<< " | --threads=<num>"
|
<< " | --threads=<num>"
|
||||||
#endif /* LIBEOSKEYGEN_HAVE_THREADS */
|
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||||
<< " | --dict=<file> ... "
|
<< " | --dict=<file> ... "
|
||||||
<< " | --lang=<value> ... ] <word_list>|file:<filename> [ <count:10> ]"
|
<< " | --lang=<value> ... ] <word_list>|file:<filename> [ <count:10> ]"
|
||||||
<< " | benchmark [ <num:1000> ]"
|
<< " | benchmark [ <num:1000> ]"
|
||||||
|
|
@ -119,11 +119,11 @@ void usage(const char *name) {
|
||||||
<< std::endl << std::endl
|
<< std::endl << std::endl
|
||||||
<< " --l33t: Takes each word in <word_list> and find all l33tspeak" << std::endl
|
<< " --l33t: Takes each word in <word_list> and find all l33tspeak" << std::endl
|
||||||
<< " combinations of that word and uses the new list for the search."
|
<< " combinations of that word and uses the new list for the search."
|
||||||
#ifdef LIBEOSKEYGEN_HAVE_THREADS
|
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||||
<< std::endl << std::endl
|
<< std::endl << std::endl
|
||||||
<< " --threads=<num>: Use <num> of parallel threads for searching." << std::endl
|
<< " --threads=<num>: Use <num> of parallel threads for searching." << std::endl
|
||||||
<< " Default is what the operating system recomend."
|
<< " Default is what the operating system recomend."
|
||||||
#endif /* LIBEOSKEYGEN_HAVE_THREADS */
|
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||||
<< std::endl << std::endl
|
<< std::endl << std::endl
|
||||||
<< " --dict=<file>: Use words found in <file> (separated by newline) to" << std::endl
|
<< " --dict=<file>: Use words found in <file> (separated by newline) to" << std::endl
|
||||||
<< " highlight words in the keys found (note that the words in this" << std::endl
|
<< " highlight words in the keys found (note that the words in this" << std::endl
|
||||||
|
|
@ -163,9 +163,9 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
// No args, just print a key.
|
// No args, just print a key.
|
||||||
if (argc <= 1) {
|
if (argc <= 1) {
|
||||||
struct eoskeygen::ec_keypair pair;
|
struct libeosio::ec_keypair pair;
|
||||||
eoskeygen::ec_generate_key(&pair);
|
libeosio::ec_generate_key(&pair);
|
||||||
eoskeygen::wif_print_key(&pair);
|
libeosio::wif_print_key(&pair);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -191,7 +191,7 @@ int main(int argc, char **argv) {
|
||||||
} else if (!strcmp(argv[p], "--l33t")) {
|
} else if (!strcmp(argv[p], "--l33t")) {
|
||||||
option_l33t = true;
|
option_l33t = true;
|
||||||
} else if (!memcmp(argv[p], "--threads=", 10)) {
|
} else if (!memcmp(argv[p], "--threads=", 10)) {
|
||||||
#ifdef LIBEOSKEYGEN_HAVE_THREADS
|
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||||
option_num_threads = atoi(argv[p] + 10);
|
option_num_threads = atoi(argv[p] + 10);
|
||||||
if (option_num_threads < 2) {
|
if (option_num_threads < 2) {
|
||||||
std::cerr << "NOTICE: Number of threads less than 2 does not make sense."
|
std::cerr << "NOTICE: Number of threads less than 2 does not make sense."
|
||||||
|
|
@ -203,7 +203,7 @@ int main(int argc, char **argv) {
|
||||||
// otherwise we might break scripts. Print a nice message instead.
|
// otherwise we might break scripts. Print a nice message instead.
|
||||||
std::cerr << "NOTICE: eosio-keygen is not compiled with"
|
std::cerr << "NOTICE: eosio-keygen is not compiled with"
|
||||||
<< " thread support. this option is ignored." << std::endl;
|
<< " thread support. this option is ignored." << std::endl;
|
||||||
#endif /* LIBEOSKEYGEN_HAVE_THREADS */
|
#endif /* EOSIOKEYGEN_HAVE_THREADS */
|
||||||
}
|
}
|
||||||
// Dictionary.
|
// Dictionary.
|
||||||
else if (!memcmp(argv[p], "--dict=", 7)) {
|
else if (!memcmp(argv[p], "--dict=", 7)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue