1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-keygen synced 2026-06-16 03:44:56 +02:00

Use the "common" subfolder instead of libeoskeygen repository.

This commit is contained in:
Henrik Hautakoski 2020-04-03 16:53:32 +02:00
parent 654a53698f
commit dd9dd484e3
6 changed files with 34 additions and 83 deletions

View file

@ -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")
include(libeoskeygen)
# Use installpath from GNUInstallDirs as default.
include(GNUInstallDirs)
@ -39,6 +37,11 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_definitions( "-D_CRT_SECURE_NO_WARNINGS=1" )
endif()
# --------------------------------
# Common code
# --------------------------------
add_subdirectory( common )
# --------------------------------
# Program
# --------------------------------
@ -66,7 +69,7 @@ include_directories(${PROJECT_BINARY_DIR})
add_executable( ${PROGRAM_EXE} ${PROGRAM_SOURCE} )
target_link_libraries( ${PROGRAM_EXE} PUBLIC eoskeygen )
target_link_libraries( ${PROGRAM_EXE} PUBLIC common )
# --------------------------------
# Install

View file

@ -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()

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
#include <chrono>
#include <eoskeygen/crypto/ec.h>
#include <libeosio/ec.h>
#include "benchmark.h"
using std::chrono::steady_clock;
@ -43,8 +43,8 @@ void benchmark(size_t num_keys, struct benchmark_result* res) {
start = steady_clock::now();
for(size_t i = 0; i < num_keys; i++) {
struct ec_keypair k;
ec_generate_key(&k);
struct libeosio::ec_keypair k;
libeosio::ec_generate_key(&k);
}
res->sec = duration<float>(steady_clock::now() - start).count();

View file

@ -22,8 +22,8 @@
* SOFTWARE.
*/
#include <iostream>
#include <libeosio/WIF.h>
#include <eoskeygen/core/dictionary.h>
#include <eoskeygen/crypto/WIF.h>
#include "console.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);
std::cout << "----" << std::endl;
@ -68,7 +68,7 @@ void CliKeySearchResult::onResult(const struct ec_keypair* key, const struct Key
}
std::cout << std::endl
<< "Private: " << wif_priv_encode(key->secret) << std::endl;
<< "Private: " << libeosio::wif_priv_encode(key->secret) << std::endl;
}
} // namespace eoskeygen

View file

@ -24,8 +24,8 @@
#ifndef EOSIOKEYGEN_KEY_SEARCH_HELPERS_H
#define EOSIOKEYGEN_KEY_SEARCH_HELPERS_H
#include <libeosio/types.h>
#include <eoskeygen/core/string.h>
#include <eoskeygen/crypto/types.h>
#include <eoskeygen/key_search.h>
#include <eoskeygen/key_search_result.h>
@ -38,7 +38,7 @@ class CliKeySearchResult : public IKeySearchResult
public:
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 :

View file

@ -23,13 +23,13 @@
*/
#include <iostream>
#include <cstring>
#include <libeosio/base58.h>
#include <libeosio/ec.h>
#include <libeosio/WIF.h>
#include <eoskeygen/config.h>
#include <eoskeygen/core/file.h>
#include <eoskeygen/core/string.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/key_search.h>
#include "cli_key_search_result.h"
@ -40,9 +40,9 @@
// Command line options.
bool option_l33t = false;
#ifdef LIBEOSKEYGEN_HAVE_THREADS
#ifdef EOSIOKEYGEN_HAVE_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) {
@ -52,7 +52,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 = eoskeygen::is_base58(*it);
size_t p = libeosio::is_base58(*it);
if (p != std::string::npos) {
std::cerr << "The word '"
<< *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);
}
#ifdef LIBEOSKEYGEN_HAVE_THREADS
#ifdef EOSIOKEYGEN_HAVE_THREADS
ks.setThreadCount(option_num_threads);
#endif /* LIBEOSKEYGEN_HAVE_THREADS */
#endif /* EOSIOKEYGEN_HAVE_THREADS */
std::cout << "Searching for " << count
<< " keys containing: " << eoskeygen::strlist::join(ks.getList(), ",")
#ifdef LIBEOSKEYGEN_HAVE_THREADS
#ifdef EOSIOKEYGEN_HAVE_THREADS
<< ", Using: " << option_num_threads << " threads"
#endif /* LIBEOSKEYGEN_HAVE_THREADS */
#endif /* EOSIOKEYGEN_HAVE_THREADS */
<< std::endl;
ks.find(count);
@ -89,9 +89,9 @@ void usage(const char *name) {
std::cout << name
<< " [ -h | --help | -v | search [ -m | --l33t"
#ifdef LIBEOSKEYGEN_HAVE_THREADS
#ifdef EOSIOKEYGEN_HAVE_THREADS
<< " | --threads=<num>"
#endif /* LIBEOSKEYGEN_HAVE_THREADS */
#endif /* EOSIOKEYGEN_HAVE_THREADS */
<< " | --dict=<file> ... "
<< " | --lang=<value> ... ] <word_list>|file:<filename> [ <count:10> ]"
<< " | benchmark [ <num:1000> ]"
@ -119,11 +119,11 @@ void usage(const char *name) {
<< std::endl << 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."
#ifdef LIBEOSKEYGEN_HAVE_THREADS
#ifdef EOSIOKEYGEN_HAVE_THREADS
<< std::endl << std::endl
<< " --threads=<num>: Use <num> of parallel threads for searching." << std::endl
<< " Default is what the operating system recomend."
#endif /* LIBEOSKEYGEN_HAVE_THREADS */
#endif /* EOSIOKEYGEN_HAVE_THREADS */
<< std::endl << 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
@ -163,9 +163,9 @@ int main(int argc, char **argv) {
// No args, just print a key.
if (argc <= 1) {
struct eoskeygen::ec_keypair pair;
eoskeygen::ec_generate_key(&pair);
eoskeygen::wif_print_key(&pair);
struct libeosio::ec_keypair pair;
libeosio::ec_generate_key(&pair);
libeosio::wif_print_key(&pair);
return 0;
}
@ -191,7 +191,7 @@ int main(int argc, char **argv) {
} else if (!strcmp(argv[p], "--l33t")) {
option_l33t = true;
} else if (!memcmp(argv[p], "--threads=", 10)) {
#ifdef LIBEOSKEYGEN_HAVE_THREADS
#ifdef EOSIOKEYGEN_HAVE_THREADS
option_num_threads = atoi(argv[p] + 10);
if (option_num_threads < 2) {
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.
std::cerr << "NOTICE: eosio-keygen is not compiled with"
<< " thread support. this option is ignored." << std::endl;
#endif /* LIBEOSKEYGEN_HAVE_THREADS */
#endif /* EOSIOKEYGEN_HAVE_THREADS */
}
// Dictionary.
else if (!memcmp(argv[p], "--dict=", 7)) {