3 #include <graphene/utilities/key_conversion.hpp>
4 #include <graphene/utilities/words.hpp>
6 #define BRAIN_KEY_WORD_COUNT 16
13 uint32_t x = fc::sha256::hash(key)._hash[0];
14 static const char hd[] =
"0123456789abcdef";
17 result += hd[(x >> 0x1c) & 0x0f];
18 result += hd[(x >> 0x18) & 0x0f];
19 result += hd[(x >> 0x14) & 0x0f];
20 result += hd[(x >> 0x10) & 0x0f];
21 result += hd[(x >> 0x0c) & 0x0f];
22 result += hd[(x >> 0x08) & 0x0f];
23 result += hd[(x >> 0x04) & 0x0f];
31 size_t i = 0, n = s.length();
36 bool preceded_by_whitespace =
false;
37 bool non_empty =
false;
49 preceded_by_whitespace =
true;
134 if (preceded_by_whitespace && non_empty)
137 preceded_by_whitespace =
false;
145 std::string sequence_string = std::to_string(sequence_number);
146 fc::sha512 h = fc::sha512::hash(prefix_string +
" " + sequence_string);
147 fc::ecc::private_key derived_key = fc::ecc::private_key::regenerate(fc::sha256::hash(h));
155 fc::sha256 sha_entropy1 = fc::ecc::private_key::generate().get_secret();
156 fc::sha256 sha_entropy2 = fc::ecc::private_key::generate().get_secret();
157 fc::bigint entropy1(sha_entropy1.data(), sha_entropy1.data_size());
158 fc::bigint entropy2(sha_entropy2.data(), sha_entropy2.data_size());
159 fc::bigint entropy(entropy1);
160 entropy <<= 8 * sha_entropy1.data_size();
162 std::string brain_key =
"";
166 fc::bigint choice = entropy % graphene::words::word_list_size;
167 entropy /= graphene::words::word_list_size;
170 brain_key += graphene::words::word_list[choice.to_int64()];
175 result.brain_priv_key = brain_key;
176 result.wif_priv_key = graphene::utilities::key_to_wif(priv_key);
177 result.pub_key = priv_key.get_public_key();
fc::ecc::private_key derive_private_key(const std::string &prefix_string, int sequence_number)
brain_key_info suggest_brain_key()
std::string pubkey_to_shorthash(const sp::public_key_type &key)
std::string normalize_brain_key(const std::string &s)
#define BRAIN_KEY_WORD_COUNT