14 std::shared_ptr<Pbkdf2Provider> pbkdf2_provider)
15 : pbkdf2_provider_(
std::move(pbkdf2_provider)),
21 const std::vector<std::string> &word_list)
const {
23 OUTCOME_TRY(entropy_accumulator,
27 for (
const auto &w : word_list) {
29 OUTCOME_TRY(entropy_accumulator.append(entropy_token));
32 OUTCOME_TRY(mnemonic_checksum, entropy_accumulator.getChecksum());
33 OUTCOME_TRY(calculated_checksum, entropy_accumulator.calculateChecksum());
35 if (mnemonic_checksum != calculated_checksum) {
40 return entropy_accumulator.getEntropy();
44 gsl::span<const uint8_t> entropy, std::string_view password)
const {
45 constexpr
size_t iterations_count = 2048u;
46 constexpr
auto default_salt =
"mnemonic";
49 salt.
put(default_salt);
57 std::string_view mnemonic_phrase)
const {
60 return makeSeed(entropy, mnemonic.password);
Class represents arbitrary (including empty) byte buffer.
outcome::result< EntropyToken > findValue(std::string_view word) const
looks for word in dictionary
Bip39ProviderImpl(std::shared_ptr< Pbkdf2Provider > pbkdf2_provider)
bip39::Dictionary dictionary_
constexpr size_t BIP39_SEED_LEN_512
outcome::result< bip39::Bip39Seed > makeSeed(gsl::span< const uint8_t > entropy, std::string_view password) const override
makes seed from entropy
static outcome::result< EntropyAccumulator > create(size_t words_count)
create class instance
outcome::result< bip39::Bip39Seed > generateSeed(std::string_view mnemonic_phrase) const override
SLBuffer & put(std::string_view view)
Put a string into byte buffer.
static outcome::result< Mnemonic > parse(std::string_view phrase)
parse mnemonic from phrase
std::shared_ptr< Pbkdf2Provider > pbkdf2_provider_
void initialize()
initializes dictionary
Logger createLogger(const std::string &tag)
outcome::result< std::vector< uint8_t > > calculateEntropy(const std::vector< std::string > &word_list) const override
calculates entropy from mnemonic