mirror of
https://github.com/eosswedenorg/antelope-keygen
synced 2026-07-02 11:43:40 +02:00
common/include/eoskeygen/key_search.hpp: make prefix into a variable (we need it for k1 keys).
This commit is contained in:
parent
b39a2a09ae
commit
d579879d71
2 changed files with 15 additions and 3 deletions
|
|
@ -47,6 +47,8 @@ public :
|
||||||
public :
|
public :
|
||||||
KeySearch();
|
KeySearch();
|
||||||
|
|
||||||
|
void setPrefix(const std::string& prefix);
|
||||||
|
|
||||||
// Add a word to search for.
|
// Add a word to search for.
|
||||||
void addWord(const std::string& str);
|
void addWord(const std::string& str);
|
||||||
|
|
||||||
|
|
@ -97,6 +99,10 @@ protected :
|
||||||
void _search_linear();
|
void _search_linear();
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
|
|
||||||
|
// Public key prefix.
|
||||||
|
std::string m_prefix;
|
||||||
|
|
||||||
// List of words to search for.
|
// List of words to search for.
|
||||||
strlist_t m_words;
|
strlist_t m_words;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
namespace eoskeygen {
|
namespace eoskeygen {
|
||||||
|
|
||||||
KeySearch::KeySearch() :
|
KeySearch::KeySearch() :
|
||||||
|
m_prefix ("EOS"),
|
||||||
m_max (0),
|
m_max (0),
|
||||||
m_count (0),
|
m_count (0),
|
||||||
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||||
|
|
@ -40,6 +41,11 @@ KeySearch::KeySearch() :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KeySearch::setPrefix(const std::string& prefix)
|
||||||
|
{
|
||||||
|
m_prefix = prefix;
|
||||||
|
}
|
||||||
|
|
||||||
void KeySearch::addWord(const std::string& str)
|
void KeySearch::addWord(const std::string& str)
|
||||||
{
|
{
|
||||||
std::string tmp = str;
|
std::string tmp = str;
|
||||||
|
|
@ -107,14 +113,14 @@ void KeySearch::find(size_t num_results)
|
||||||
|
|
||||||
bool KeySearch::_contains_word(const struct libeosio::ec_keypair* key, struct result& result) {
|
bool KeySearch::_contains_word(const struct libeosio::ec_keypair* key, struct result& result) {
|
||||||
|
|
||||||
// skip first 3 chars, as those are always "EOS"
|
size_t prefix_len = m_prefix.length();
|
||||||
std::string pubstr = libeosio::wif_pub_encode(key->pub).substr(3);
|
std::string pubstr = libeosio::wif_pub_encode(key->pub, m_prefix).substr(prefix_len);
|
||||||
strtolower(pubstr);
|
strtolower(pubstr);
|
||||||
|
|
||||||
for(auto const& w: m_words) {
|
for(auto const& w: m_words) {
|
||||||
size_t p = pubstr.find(w);
|
size_t p = pubstr.find(w);
|
||||||
if (p != std::string::npos) {
|
if (p != std::string::npos) {
|
||||||
result.pos = p + 3;
|
result.pos = p + prefix_len;
|
||||||
result.len = w.length();
|
result.len = w.length();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue