Electroneum
Functions | Variables
crypto::ElectrumWords Namespace Reference

Mnemonic seed word generation and wallet restoration helper functions. More...

Functions

std::vector< const Language::Base * > get_language_list ()
 
bool words_to_bytes (const epee::wipeable_string &words, epee::wipeable_string &dst, size_t len, bool duplicate, std::string &language_name)
 Converts seed words to bytes (secret key). More...
 
bool words_to_bytes (const epee::wipeable_string &words, crypto::secret_key &dst, std::string &language_name)
 Converts seed words to bytes (secret key). More...
 
bool bytes_to_words (const char *src, size_t len, epee::wipeable_string &words, const std::string &language_name)
 Converts bytes (secret key) to seed words. More...
 
bool bytes_to_words (const crypto::secret_key &src, epee::wipeable_string &words, const std::string &language_name)
 Converts bytes (secret key) to seed words. More...
 
void get_language_list (std::vector< std::string > &languages, bool english)
 Gets a list of seed languages that are supported. More...
 
bool get_is_old_style_seed (const epee::wipeable_string &seed)
 Tells if the seed passed is an old style seed or not. More...
 
std::string get_english_name_for (const std::string &name)
 Returns the name of a language in English. More...
 

Variables

const int seed_length = 24
 
const std::string old_language_name = "EnglishOld"
 

Detailed Description

Mnemonic seed word generation and wallet restoration helper functions.

Function Documentation

◆ bytes_to_words() [1/2]

bool crypto::ElectrumWords::bytes_to_words ( const char *  src,
size_t  len,
epee::wipeable_string &  words,
const std::string &  language_name 
)

Converts bytes (secret key) to seed words.

Converts bytes to seed words.

Parameters
srcSecret key
wordsSpace delimited concatenated words get written here.
language_nameSeed language name
Returns
true if successful false if not. Unsuccessful if wrong key size.
Parameters
srcSecret data
lenSecret data length in bytes (positive multiples of 4 only)
wordsSpace delimited concatenated words get written here.
language_nameSeed language name
Returns
true if successful false if not. Unsuccessful if wrong key size.

◆ bytes_to_words() [2/2]

bool crypto::ElectrumWords::bytes_to_words ( const crypto::secret_key src,
epee::wipeable_string &  words,
const std::string &  language_name 
)

Converts bytes (secret key) to seed words.

Parameters
srcSecret key
wordsSpace delimited concatenated words get written here.
language_nameSeed language name
Returns
true if successful false if not. Unsuccessful if wrong key size.

◆ get_english_name_for()

std::string crypto::ElectrumWords::get_english_name_for ( const std::string &  name)

Returns the name of a language in English.

Parameters
namethe name of the language in its own language
Returns
the name of the language in English

◆ get_is_old_style_seed()

bool crypto::ElectrumWords::get_is_old_style_seed ( const epee::wipeable_string &  seed)

Tells if the seed passed is an old style seed or not.

Parameters
seedThe seed to check (a space delimited concatenated word list)
Returns
true if the seed passed is a old style seed false if not.

◆ get_language_list() [1/2]

std::vector< const Language::Base * > crypto::ElectrumWords::get_language_list ( )

◆ get_language_list() [2/2]

void crypto::ElectrumWords::get_language_list ( std::vector< std::string > &  languages,
bool  english 
)

Gets a list of seed languages that are supported.

Parameters
languagesThe vector is set to the list of languages.
languagesA vector is set to the list of languages.
englishwhether to get the names in English or the language language

◆ words_to_bytes() [1/2]

bool crypto::ElectrumWords::words_to_bytes ( const epee::wipeable_string &  words,
crypto::secret_key dst,
std::string &  language_name 
)

Converts seed words to bytes (secret key).

Parameters
wordsString containing the words separated by spaces.
dstTo put the secret key restored from the words.
language_nameLanguage of the seed as found gets written here.
Returns
false if not a multiple of 3 words, or if word is not in the words list

◆ words_to_bytes() [2/2]

bool crypto::ElectrumWords::words_to_bytes ( const epee::wipeable_string &  words,
epee::wipeable_string &  dst,
size_t  len,
bool  duplicate,
std::string &  language_name 
)

Converts seed words to bytes (secret key).

Parameters
wordsString containing the words separated by spaces.
dstTo put the secret data restored from the words.
lenThe number of bytes to expect, 0 if unknown
duplicateIf true and len is not zero, we accept half the data, and duplicate it
language_nameLanguage of the seed as found gets written here.
Returns
false if not a multiple of 3 words, or if word is not in the words list

Variable Documentation

◆ old_language_name

const std::string crypto::ElectrumWords::old_language_name = "EnglishOld"

◆ seed_length

const int crypto::ElectrumWords::seed_length = 24