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
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)
{
@ -235,10 +235,11 @@ namespace crypto
// Checksum fail
return false;
}
seed.pop_back();
}
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))
{
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
#define LANGUAGE_BASE_H
#include <vector>
#include <unordered_map>
#include <string>
namespace Language
{
const int unique_prefix_length = 4;
class Base
{
protected:
std::vector<std::string> *word_list;
std::unordered_map<std::string, uint32_t> *word_map;
std::unordered_map<std::string, uint32_t> *trimmed_word_map;
std::string language_name;
void populate_maps()
{
int ii;
std::vector<std::string>::iterator it;
for (it = word_list->begin(), ii = 0; it != word_list->end(); it++, ii++)
{
(*word_map)[*it] = ii;
if (it->length() > 4)
{
(*trimmed_word_map)[it->substr(0, 4)] = ii;
}
else
{
(*trimmed_word_map)[*it] = ii;
}
}
}
public:
Base()
{
word_list = new std::vector<std::string>;
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
{
return *word_list;
}
const std::unordered_map<std::string, uint32_t>& get_word_map() const
{
return *word_map;
}
const std::unordered_map<std::string, uint32_t>& get_trimmed_word_map() const
{
return *trimmed_word_map;
}
std::string get_language_name() const
{
return language_name;
}
};
}
#endif
#ifndef LANGUAGE_BASE_H
#define LANGUAGE_BASE_H
#include <vector>
#include <unordered_map>
#include <string>
namespace Language
{
const int unique_prefix_length = 4;
class Base
{
protected:
std::vector<std::string> *word_list;
std::unordered_map<std::string, uint32_t> *word_map;
std::unordered_map<std::string, uint32_t> *trimmed_word_map;
std::string language_name;
void populate_maps()
{
int ii;
std::vector<std::string>::iterator it;
for (it = word_list->begin(), ii = 0; it != word_list->end(); it++, ii++)
{
(*word_map)[*it] = ii;
if (it->length() > 4)
{
(*trimmed_word_map)[it->substr(0, 4)] = ii;
}
else
{
(*trimmed_word_map)[*it] = ii;
}
}
}
public:
Base()
{
word_list = new std::vector<std::string>;
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
{
return *word_list;
}
const std::unordered_map<std::string, uint32_t>& get_word_map() const
{
return *word_map;
}
const std::unordered_map<std::string, uint32_t>& get_trimmed_word_map() const
{
return *trimmed_word_map;
}
std::string get_language_name() const
{
return language_name;
}
};
}
#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
{
template <class T>
class Singleton
{
Singleton() {}
Singleton(Singleton &s) {}
Singleton& operator=(const Singleton&) {}
public:
static T* instance()
{
static T* obj = new T;
return obj;
}
};
}
// Copyright (c) 2014, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// 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