Cut short word lists to 1626 words, added attribution to Electrum, some bug fixes

This commit is contained in:
Oran Juice 2014-10-02 21:14:29 +05:30
parent 4517bac7f3
commit fa723d8af8
No known key found for this signature in database
GPG Key ID: 71C5AF46CCB28124
8 changed files with 8511 additions and 9604 deletions

View File

@ -111,7 +111,7 @@ namespace
// Iterate through all the words and see if they're all present // Iterate through all the words and see if they're all present
for (it2 = seed.begin(), it3 = trimmed_seed.begin(); for (it2 = seed.begin(), it3 = trimmed_seed.begin();
it2 != seed.end() && it3 != trimmed_seed.end(); it2++, it3++) it2 != seed.end(); it2++, it3++)
{ {
if (has_checksum) if (has_checksum)
{ {
@ -235,10 +235,11 @@ namespace crypto
// Checksum fail // Checksum fail
return false; return false;
} }
seed.pop_back();
} }
std::vector<uint32_t> matched_indices; std::vector<uint32_t> matched_indices;
uint32_t word_list_length; uint32_t word_list_length = 0;
if (!find_seed_language(seed, has_checksum, matched_indices, word_list_length, language_name)) if (!find_seed_language(seed, has_checksum, matched_indices, word_list_length, language_name))
{ {
return false; return false;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,61 +1,61 @@
#ifndef LANGUAGE_BASE_H #ifndef LANGUAGE_BASE_H
#define LANGUAGE_BASE_H #define LANGUAGE_BASE_H
#include <vector> #include <vector>
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
namespace Language namespace Language
{ {
const int unique_prefix_length = 4; const int unique_prefix_length = 4;
class Base class Base
{ {
protected: protected:
std::vector<std::string> *word_list; std::vector<std::string> *word_list;
std::unordered_map<std::string, uint32_t> *word_map; std::unordered_map<std::string, uint32_t> *word_map;
std::unordered_map<std::string, uint32_t> *trimmed_word_map; std::unordered_map<std::string, uint32_t> *trimmed_word_map;
std::string language_name; std::string language_name;
void populate_maps() void populate_maps()
{ {
int ii; int ii;
std::vector<std::string>::iterator it; std::vector<std::string>::iterator it;
for (it = word_list->begin(), ii = 0; it != word_list->end(); it++, ii++) for (it = word_list->begin(), ii = 0; it != word_list->end(); it++, ii++)
{ {
(*word_map)[*it] = ii; (*word_map)[*it] = ii;
if (it->length() > 4) if (it->length() > 4)
{ {
(*trimmed_word_map)[it->substr(0, 4)] = ii; (*trimmed_word_map)[it->substr(0, 4)] = ii;
} }
else else
{ {
(*trimmed_word_map)[*it] = ii; (*trimmed_word_map)[*it] = ii;
} }
} }
} }
public: public:
Base() Base()
{ {
word_list = new std::vector<std::string>; word_list = new std::vector<std::string>;
word_map = new std::unordered_map<std::string, uint32_t>; word_map = new std::unordered_map<std::string, uint32_t>;
trimmed_word_map = new std::unordered_map<std::string, uint32_t>; trimmed_word_map = new std::unordered_map<std::string, uint32_t>;
} }
const std::vector<std::string>& get_word_list() const const std::vector<std::string>& get_word_list() const
{ {
return *word_list; return *word_list;
} }
const std::unordered_map<std::string, uint32_t>& get_word_map() const const std::unordered_map<std::string, uint32_t>& get_word_map() const
{ {
return *word_map; return *word_map;
} }
const std::unordered_map<std::string, uint32_t>& get_trimmed_word_map() const const std::unordered_map<std::string, uint32_t>& get_trimmed_word_map() const
{ {
return *trimmed_word_map; return *trimmed_word_map;
} }
std::string get_language_name() const std::string get_language_name() const
{ {
return language_name; return language_name;
} }
}; };
} }
#endif #endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,44 @@
namespace Language // Copyright (c) 2014, The Monero Project
{ //
template <class T> // All rights reserved.
class Singleton //
{ // Redistribution and use in source and binary forms, with or without modification, are
Singleton() {} // permitted provided that the following conditions are met:
Singleton(Singleton &s) {} //
Singleton& operator=(const Singleton&) {} // 1. Redistributions of source code must retain the above copyright notice, this list of
public: // conditions and the following disclaimer.
static T* instance() //
{ // 2. Redistributions in binary form must reproduce the above copyright notice, this list
static T* obj = new T; // of conditions and the following disclaimer in the documentation and/or other
return obj; // materials provided with the distribution.
} //
}; // 3. Neither the name of the copyright holder nor the names of its contributors may be
} // used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Language
{
template <class T>
class Singleton
{
Singleton() {}
Singleton(Singleton &s) {}
Singleton& operator=(const Singleton&) {}
public:
static T* instance()
{
static T* obj = new T;
return obj;
}
};
}

File diff suppressed because it is too large Load Diff