From b625c63b5bbd10a19807f7dacb48254f7209da82 Mon Sep 17 00:00:00 2001 From: Neill Miller Date: Thu, 8 Feb 2018 22:21:31 -0600 Subject: [PATCH 1/4] Allow electrum-new to take input entropy of any length from seed and use only what is required. By default, 132 bits of entropy are used to match the default for electrum 2.x+. If more input entropy is provided and more entropy for the electrum-mnemonic is desired, a -b,bit-length option is provided to specify how much. --- .gitignore | 7 ++++ .../explorer/commands/electrum-new.hpp | 30 +++++++++++++- .../explorer/commands/electrum-to-seed.hpp | 2 +- include/bitcoin/explorer/define.hpp | 5 +++ model/generate.xml | 6 ++- src/commands/electrum-new.cpp | 39 +++++++++++++++++-- src/commands/electrum-to-seed.cpp | 2 +- src/commands/seed.cpp | 1 - test/commands/electrum-new.cpp | 14 ++++++- 9 files changed, 95 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 6e7db3614..4642caf33 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,10 @@ console/bx /release/bx /release/bx.exe *.zpl + +build-libbitcoin-explorer +libbitcoin_explorer_test_runner.sh.log +libbitcoin_explorer_test_runner.sh.trs +test-suite.log +test.log +test/libbitcoin_explorer_test diff --git a/include/bitcoin/explorer/commands/electrum-new.hpp b/include/bitcoin/explorer/commands/electrum-new.hpp index d7b7da227..411d0daca 100644 --- a/include/bitcoin/explorer/commands/electrum-new.hpp +++ b/include/bitcoin/explorer/commands/electrum-new.hpp @@ -58,7 +58,9 @@ namespace commands { /** * Various localizable strings. */ -#define BX_EC_ELECTRUM_NEW_UNSUPPORTED \ +#define BX_ELECTRUM_NEW_BIT_LENGTH_UNSUPPORTED \ + "The seed size is not supported." +#define BX_ELECTRUM_NEW_UNSUPPORTED \ "The electrum-new command requires an ICU build." /** @@ -145,6 +147,11 @@ class BCX_API electrum_new value(), "The path to the configuration settings file." ) + ( + "bit_length,b", + value(&option_.bit_length)->default_value(132), + "The minimum required length of the input seed in bits, defaults to 132." + ) ( "prefix,p", value(&option_.prefix), @@ -200,6 +207,23 @@ class BCX_API electrum_new argument_.seed = value; } + /** + * Get the value of the bit_length option. + */ + virtual uint16_t& get_bit_length_option() + { + return option_.bit_length; + } + + /** + * Set the value of the bit_length option. + */ + virtual void set_bit_length_option( + const uint16_t& value) + { + option_.bit_length = value; + } + /** * Get the value of the prefix option. */ @@ -259,11 +283,13 @@ class BCX_API electrum_new struct option { option() - : prefix(), + : bit_length(), + prefix(), language() { } + uint16_t bit_length; explorer::config::electrum prefix; explorer::config::language language; } option_; diff --git a/include/bitcoin/explorer/commands/electrum-to-seed.hpp b/include/bitcoin/explorer/commands/electrum-to-seed.hpp index 9836cc10e..3f40e9792 100644 --- a/include/bitcoin/explorer/commands/electrum-to-seed.hpp +++ b/include/bitcoin/explorer/commands/electrum-to-seed.hpp @@ -58,7 +58,7 @@ namespace commands { /** * Various localizable strings. */ -#define BX_EC_ELECTRUM_TO_SEED_PASSPHRASE_UNSUPPORTED \ +#define BX_ELECTRUM_TO_SEED_PASSPHRASE_UNSUPPORTED \ "The passphrase option requires an ICU build." /** diff --git a/include/bitcoin/explorer/define.hpp b/include/bitcoin/explorer/define.hpp index 5fa36511f..2ba9e7c24 100644 --- a/include/bitcoin/explorer/define.hpp +++ b/include/bitcoin/explorer/define.hpp @@ -97,6 +97,11 @@ BC_CONSTEXPR size_t minimum_seed_bits = 128; */ BC_CONSTEXPR size_t minimum_seed_size = minimum_seed_bits / bc::byte_bits; +/** + * The minimum safe length of an electrum seed in bits. + */ +BC_CONSTEXPR size_t minimum_electrum_seed_bits = 132; + /** * Suppported output encoding engines. */ diff --git a/model/generate.xml b/model/generate.xml index d4685a63b..6ac7eb6be 100644 --- a/model/generate.xml +++ b/model/generate.xml @@ -205,17 +205,19 @@ + diff --git a/src/commands/electrum-new.cpp b/src/commands/electrum-new.cpp index 341404505..0a29cff43 100644 --- a/src/commands/electrum-new.cpp +++ b/src/commands/electrum-new.cpp @@ -18,15 +18,17 @@ */ #include -#include +#include #include #include #include +#include namespace libbitcoin { namespace explorer { namespace commands { using namespace bc::wallet; +using namespace boost::multiprecision; console_result electrum_new::invoke(std::ostream& output, std::ostream& error) @@ -35,16 +37,47 @@ console_result electrum_new::invoke(std::ostream& output, // Bound parameters. const dictionary_list& language = get_language_option(); const data_chunk& seed = get_seed_argument(); + const auto bit_length = get_bit_length_option(); const auto prefix = get_prefix_option(); + const auto bits_per_word = std::log2(bc::wallet::dictionary_size); + + const auto number_of_entropy_bits = static_cast( + std::ceil(bit_length / bits_per_word) * bits_per_word); + + if ((bit_length < minimum_electrum_seed_bits) || + (seed.size() * byte_bits < number_of_entropy_bits)) + { + error << BX_ELECTRUM_NEW_BIT_LENGTH_UNSUPPORTED << std::endl; + return console_result::failure; + } + // If 'any' default to first ('en'), otherwise the one specified. const auto dictionary = language.front(); - const auto words = electrum::create_mnemonic(seed, *dictionary, prefix); + + // convert the provided entropy to a large number and make sure it + // does not exceed the required entropy bits + const cpp_int entropy_number = cpp_int("0x" + encode_base16(seed)) % + boost::multiprecision::pow(cpp_int(2), number_of_entropy_bits); + + // convert large number back into a base16 decode-able string + std::stringstream sstream; + sstream << std::hex << entropy_number; + + // pre-pend zero if the string conversion length is not even + const auto entropy_prefix = ((sstream.str().size() % 2 == 0) ? "" : "0"); + const auto entropy_string = entropy_prefix + sstream.str(); + + data_chunk electrum_seed; + decode_base16(electrum_seed, entropy_string); + + const auto words = electrum::create_mnemonic( + electrum_seed, *dictionary, prefix); output << join(words) << std::endl; return console_result::okay; #else - error << BX_EC_ELECTRUM_NEW_UNSUPPORTED << std::endl; + error << BX_ELECTRUM_NEW_UNSUPPORTED << std::endl; return console_result::failure; #endif } diff --git a/src/commands/electrum-to-seed.cpp b/src/commands/electrum-to-seed.cpp index eee82cc05..5c53a695d 100644 --- a/src/commands/electrum-to-seed.cpp +++ b/src/commands/electrum-to-seed.cpp @@ -42,7 +42,7 @@ console_result electrum_to_seed::invoke(std::ostream& output, // The passphrase requires ICU normalization. if (!passphrase.empty()) { - error << BX_EC_ELECTRUM_TO_SEED_PASSPHRASE_UNSUPPORTED << std::endl; + error << BX_ELECTRUM_TO_SEED_PASSPHRASE_UNSUPPORTED << std::endl; return console_result::failure; } diff --git a/src/commands/seed.cpp b/src/commands/seed.cpp index bd6ec9dea..8a4ca99af 100644 --- a/src/commands/seed.cpp +++ b/src/commands/seed.cpp @@ -18,7 +18,6 @@ */ #include -#include #include #include #include diff --git a/test/commands/electrum-new.cpp b/test/commands/electrum-new.cpp index 876fd28ed..8e725adcc 100644 --- a/test/commands/electrum-new.cpp +++ b/test/commands/electrum-new.cpp @@ -29,6 +29,7 @@ BOOST_AUTO_TEST_SUITE(electrum_new__invoke) BOOST_AUTO_TEST_CASE(electrum_new__invoke__17_bytes__okay_output) { BX_DECLARE_COMMAND(electrum_new); + command.set_bit_length_option(132); command.set_seed_argument({ "05e669b4270f4e25bce6fc3736170d423c" }); BX_REQUIRE_OKAY(command.invoke(output, error)); BX_REQUIRE_OUTPUT("giggle crush argue inflict wear defy combine evolve tiger spatial crumble fury\n"); @@ -37,6 +38,7 @@ BOOST_AUTO_TEST_CASE(electrum_new__invoke__17_bytes__okay_output) BOOST_AUTO_TEST_CASE(electrum_new__invoke__dictionary_prefix__okay_output) { BX_DECLARE_COMMAND(electrum_new); + command.set_bit_length_option(132); command.set_seed_argument({ "05e669b4270f4e25bce6fc3736170d423c" }); command.set_language_option({ "en" }); command.set_prefix_option({ "standard" }); @@ -47,9 +49,19 @@ BOOST_AUTO_TEST_CASE(electrum_new__invoke__dictionary_prefix__okay_output) BOOST_AUTO_TEST_CASE(electrum_new__invoke__32_bytes__okay_output) { BX_DECLARE_COMMAND(electrum_new); + command.set_bit_length_option(132); command.set_seed_argument({ "b0756302179e800b182514c729f1d6814c377ff06097569ef540e6c1f1950f08" }); BX_REQUIRE_OKAY(command.invoke(output, error)); - BX_REQUIRE_OUTPUT("divide february web hire limb run reject nuclear army zone brick below public ladder deer below again cluster divorce ketchup aerobic flee lonely absent\n"); + BX_REQUIRE_OUTPUT("tube feature web hire limb run reject nuclear army zone brick below\n"); +} + +BOOST_AUTO_TEST_CASE(electrum_new__invoke__32_bytes_220_bit_entropy__okay_output) +{ + BX_DECLARE_COMMAND(electrum_new); + command.set_bit_length_option(220); + command.set_seed_argument({ "b0756302179e800b182514c729f1d6814c377ff06097569ef540e6c1f1950f08" }); + BX_REQUIRE_OKAY(command.invoke(output, error)); + BX_REQUIRE_OUTPUT("cruise february web hire limb run reject nuclear army zone brick below public ladder deer below again cluster divorce ketchup\n"); } #endif From 7d67053f03c44b379888b7e50f37369bc643512c Mon Sep 17 00:00:00 2001 From: evoskuil Date: Mon, 19 Feb 2018 08:53:30 -0800 Subject: [PATCH 2/4] Simplify electrum-new, make symbols consistent. --- .../explorer/commands/electrum-new.hpp | 32 ++---------- .../explorer/commands/electrum-to-seed.hpp | 2 +- .../explorer/commands/mnemonic-decode.hpp | 2 +- .../explorer/commands/mnemonic-encode.hpp | 2 +- .../explorer/commands/mnemonic-new.hpp | 2 +- .../explorer/commands/mnemonic-to-seed.hpp | 2 +- include/bitcoin/explorer/define.hpp | 5 -- model/generate.xml | 15 +++--- src/commands/electrum-new.cpp | 50 +++++++------------ src/commands/electrum-to-seed.cpp | 2 +- src/commands/mnemonic-new.cpp | 2 +- src/commands/mnemonic-to-seed.cpp | 2 +- test/commands/electrum-new.cpp | 4 -- test/commands/mnemonic-new.cpp | 2 +- test/commands/mnemonic-to-seed.cpp | 18 +++---- 15 files changed, 46 insertions(+), 96 deletions(-) diff --git a/include/bitcoin/explorer/commands/electrum-new.hpp b/include/bitcoin/explorer/commands/electrum-new.hpp index 411d0daca..7268f915f 100644 --- a/include/bitcoin/explorer/commands/electrum-new.hpp +++ b/include/bitcoin/explorer/commands/electrum-new.hpp @@ -58,10 +58,10 @@ namespace commands { /** * Various localizable strings. */ -#define BX_ELECTRUM_NEW_BIT_LENGTH_UNSUPPORTED \ +#define BX_ELECTRUM_NEW_INVALID_SEED \ "The seed size is not supported." -#define BX_ELECTRUM_NEW_UNSUPPORTED \ - "The electrum-new command requires an ICU build." +#define BX_ELECTRUM_REQUIRES_ICU \ + "The command requires an ICU build." /** * Class to implement the electrum-new command. @@ -147,11 +147,6 @@ class BCX_API electrum_new value(), "The path to the configuration settings file." ) - ( - "bit_length,b", - value(&option_.bit_length)->default_value(132), - "The minimum required length of the input seed in bits, defaults to 132." - ) ( "prefix,p", value(&option_.prefix), @@ -207,23 +202,6 @@ class BCX_API electrum_new argument_.seed = value; } - /** - * Get the value of the bit_length option. - */ - virtual uint16_t& get_bit_length_option() - { - return option_.bit_length; - } - - /** - * Set the value of the bit_length option. - */ - virtual void set_bit_length_option( - const uint16_t& value) - { - option_.bit_length = value; - } - /** * Get the value of the prefix option. */ @@ -283,13 +261,11 @@ class BCX_API electrum_new struct option { option() - : bit_length(), - prefix(), + : prefix(), language() { } - uint16_t bit_length; explorer::config::electrum prefix; explorer::config::language language; } option_; diff --git a/include/bitcoin/explorer/commands/electrum-to-seed.hpp b/include/bitcoin/explorer/commands/electrum-to-seed.hpp index 3f40e9792..85ffd08f3 100644 --- a/include/bitcoin/explorer/commands/electrum-to-seed.hpp +++ b/include/bitcoin/explorer/commands/electrum-to-seed.hpp @@ -58,7 +58,7 @@ namespace commands { /** * Various localizable strings. */ -#define BX_ELECTRUM_TO_SEED_PASSPHRASE_UNSUPPORTED \ +#define BX_ELECTRUM_TO_SEED_REQUIRES_ICU \ "The passphrase option requires an ICU build." /** diff --git a/include/bitcoin/explorer/commands/mnemonic-decode.hpp b/include/bitcoin/explorer/commands/mnemonic-decode.hpp index 3ff5e2220..8e373001b 100644 --- a/include/bitcoin/explorer/commands/mnemonic-decode.hpp +++ b/include/bitcoin/explorer/commands/mnemonic-decode.hpp @@ -59,7 +59,7 @@ namespace commands { * Various localizable strings. */ #define BX_MNEMONIC_DECODE_OBSOLETE \ - "Electrum style key functions are obsolete. Use mnemonic-to-seed (BIP39) command instead." + "Electrum version 1 functions are obsolete. Use electrum-to-seed or mnemonic-to-seed (BIP39) command instead." /** * Class to implement the mnemonic-decode command. diff --git a/include/bitcoin/explorer/commands/mnemonic-encode.hpp b/include/bitcoin/explorer/commands/mnemonic-encode.hpp index c061cfd0d..806d975eb 100644 --- a/include/bitcoin/explorer/commands/mnemonic-encode.hpp +++ b/include/bitcoin/explorer/commands/mnemonic-encode.hpp @@ -59,7 +59,7 @@ namespace commands { * Various localizable strings. */ #define BX_MNEMONIC_ENCODE_OBSOLETE \ - "Electrum style key functions are obsolete. Use mnemonic-new (BIP39) command instead." + "Electrum version 1 functions are obsolete. Use electrum-new or mnemonic-new (BIP39) command instead." /** * Class to implement the mnemonic-encode command. diff --git a/include/bitcoin/explorer/commands/mnemonic-new.hpp b/include/bitcoin/explorer/commands/mnemonic-new.hpp index 88e517ff8..d4646e8b1 100644 --- a/include/bitcoin/explorer/commands/mnemonic-new.hpp +++ b/include/bitcoin/explorer/commands/mnemonic-new.hpp @@ -58,7 +58,7 @@ namespace commands { /** * Various localizable strings. */ -#define BX_EC_MNEMONIC_NEW_INVALID_ENTROPY \ +#define BX_EC_MNEMONIC_NEW_INVALID_SEED \ "The seed length in bytes is not evenly divisible by 32 bits." /** diff --git a/include/bitcoin/explorer/commands/mnemonic-to-seed.hpp b/include/bitcoin/explorer/commands/mnemonic-to-seed.hpp index 5eb1abdc4..341518405 100644 --- a/include/bitcoin/explorer/commands/mnemonic-to-seed.hpp +++ b/include/bitcoin/explorer/commands/mnemonic-to-seed.hpp @@ -60,7 +60,7 @@ namespace commands { */ #define BX_EC_MNEMONIC_TO_SEED_LENGTH_INVALID_SENTENCE \ "The number of words must be divisible by 3." -#define BX_EC_MNEMONIC_TO_SEED_PASSPHRASE_UNSUPPORTED \ +#define BX_EC_MNEMONIC_TO_SEED_REQUIRES_ICU \ "The passphrase option requires an ICU build." #define BX_EC_MNEMONIC_TO_SEED_INVALID_IN_LANGUAGE \ "The specified words are not a valid mnemonic in the specified dictionary." diff --git a/include/bitcoin/explorer/define.hpp b/include/bitcoin/explorer/define.hpp index 2ba9e7c24..5fa36511f 100644 --- a/include/bitcoin/explorer/define.hpp +++ b/include/bitcoin/explorer/define.hpp @@ -97,11 +97,6 @@ BC_CONSTEXPR size_t minimum_seed_bits = 128; */ BC_CONSTEXPR size_t minimum_seed_size = minimum_seed_bits / bc::byte_bits; -/** - * The minimum safe length of an electrum seed in bits. - */ -BC_CONSTEXPR size_t minimum_electrum_seed_bits = 132; - /** * Suppported output encoding engines. */ diff --git a/model/generate.xml b/model/generate.xml index 6ac7eb6be..7ef8f4d28 100644 --- a/model/generate.xml +++ b/model/generate.xml @@ -205,19 +205,18 @@ - @@ -414,17 +413,17 @@ - + - + @@ -432,7 +431,7 @@ diff --git a/src/commands/electrum-new.cpp b/src/commands/electrum-new.cpp index 0a29cff43..1f640f92a 100644 --- a/src/commands/electrum-new.cpp +++ b/src/commands/electrum-new.cpp @@ -18,66 +18,50 @@ */ #include -#include +#include #include -#include #include -#include namespace libbitcoin { namespace explorer { namespace commands { using namespace bc::wallet; -using namespace boost::multiprecision; -console_result electrum_new::invoke(std::ostream& output, - std::ostream& error) +// Requires a seed of at least 17 bytes (136 bits). +static const size_t minimum_electrum_words = 12; + +console_result electrum_new::invoke(std::ostream& output, std::ostream& error) { #ifdef WITH_ICU // Bound parameters. const dictionary_list& language = get_language_option(); const data_chunk& seed = get_seed_argument(); - const auto bit_length = get_bit_length_option(); const auto prefix = get_prefix_option(); - const auto bits_per_word = std::log2(bc::wallet::dictionary_size); + // trunc(log2(2048)) = 11 + const auto word_bits = static_cast(std::log2(dictionary_size)); + + // 17 * 8 = 136 + const auto seed_bits = seed.size() * byte_bits; - const auto number_of_entropy_bits = static_cast( - std::ceil(bit_length / bits_per_word) * bits_per_word); + // 136 / 11 = 12 + const auto words = seed_bits / word_bits; - if ((bit_length < minimum_electrum_seed_bits) || - (seed.size() * byte_bits < number_of_entropy_bits)) + if (words < minimum_electrum_words) { - error << BX_ELECTRUM_NEW_BIT_LENGTH_UNSUPPORTED << std::endl; + error << BX_ELECTRUM_NEW_INVALID_SEED << std::endl; return console_result::failure; } // If 'any' default to first ('en'), otherwise the one specified. const auto dictionary = language.front(); - // convert the provided entropy to a large number and make sure it - // does not exceed the required entropy bits - const cpp_int entropy_number = cpp_int("0x" + encode_base16(seed)) % - boost::multiprecision::pow(cpp_int(2), number_of_entropy_bits); - - // convert large number back into a base16 decode-able string - std::stringstream sstream; - sstream << std::hex << entropy_number; - - // pre-pend zero if the string conversion length is not even - const auto entropy_prefix = ((sstream.str().size() % 2 == 0) ? "" : "0"); - const auto entropy_string = entropy_prefix + sstream.str(); - - data_chunk electrum_seed; - decode_base16(electrum_seed, entropy_string); - - const auto words = electrum::create_mnemonic( - electrum_seed, *dictionary, prefix); + auto mnemonic = electrum::create_mnemonic(seed, *dictionary, prefix); - output << join(words) << std::endl; + output << join(mnemonic) << std::endl; return console_result::okay; #else - error << BX_ELECTRUM_NEW_UNSUPPORTED << std::endl; + error << BX_ELECTRUM_REQUIRES_ICU << std::endl; return console_result::failure; #endif } diff --git a/src/commands/electrum-to-seed.cpp b/src/commands/electrum-to-seed.cpp index 5c53a695d..f068cc1f5 100644 --- a/src/commands/electrum-to-seed.cpp +++ b/src/commands/electrum-to-seed.cpp @@ -42,7 +42,7 @@ console_result electrum_to_seed::invoke(std::ostream& output, // The passphrase requires ICU normalization. if (!passphrase.empty()) { - error << BX_ELECTRUM_TO_SEED_PASSPHRASE_UNSUPPORTED << std::endl; + error << BX_ELECTRUM_TO_SEED_REQUIRES_ICU << std::endl; return console_result::failure; } diff --git a/src/commands/mnemonic-new.cpp b/src/commands/mnemonic-new.cpp index 723e03d74..e39346fac 100644 --- a/src/commands/mnemonic-new.cpp +++ b/src/commands/mnemonic-new.cpp @@ -38,7 +38,7 @@ console_result mnemonic_new::invoke(std::ostream& output, if ((entropy_size % bc::wallet::mnemonic_seed_multiple) != 0) { - error << BX_EC_MNEMONIC_NEW_INVALID_ENTROPY << std::endl; + error << BX_EC_MNEMONIC_NEW_INVALID_SEED << std::endl; return console_result::failure; } diff --git a/src/commands/mnemonic-to-seed.cpp b/src/commands/mnemonic-to-seed.cpp index 88fb02236..d7b40208e 100644 --- a/src/commands/mnemonic-to-seed.cpp +++ b/src/commands/mnemonic-to-seed.cpp @@ -62,7 +62,7 @@ console_result mnemonic_to_seed::invoke(std::ostream& output, #else if (!passphrase.empty()) { - error << BX_EC_MNEMONIC_TO_SEED_PASSPHRASE_UNSUPPORTED << std::endl; + error << BX_EC_MNEMONIC_TO_SEED_REQUIRES_ICU << std::endl; return console_result::failure; } diff --git a/test/commands/electrum-new.cpp b/test/commands/electrum-new.cpp index 8e725adcc..739181239 100644 --- a/test/commands/electrum-new.cpp +++ b/test/commands/electrum-new.cpp @@ -29,7 +29,6 @@ BOOST_AUTO_TEST_SUITE(electrum_new__invoke) BOOST_AUTO_TEST_CASE(electrum_new__invoke__17_bytes__okay_output) { BX_DECLARE_COMMAND(electrum_new); - command.set_bit_length_option(132); command.set_seed_argument({ "05e669b4270f4e25bce6fc3736170d423c" }); BX_REQUIRE_OKAY(command.invoke(output, error)); BX_REQUIRE_OUTPUT("giggle crush argue inflict wear defy combine evolve tiger spatial crumble fury\n"); @@ -38,7 +37,6 @@ BOOST_AUTO_TEST_CASE(electrum_new__invoke__17_bytes__okay_output) BOOST_AUTO_TEST_CASE(electrum_new__invoke__dictionary_prefix__okay_output) { BX_DECLARE_COMMAND(electrum_new); - command.set_bit_length_option(132); command.set_seed_argument({ "05e669b4270f4e25bce6fc3736170d423c" }); command.set_language_option({ "en" }); command.set_prefix_option({ "standard" }); @@ -49,7 +47,6 @@ BOOST_AUTO_TEST_CASE(electrum_new__invoke__dictionary_prefix__okay_output) BOOST_AUTO_TEST_CASE(electrum_new__invoke__32_bytes__okay_output) { BX_DECLARE_COMMAND(electrum_new); - command.set_bit_length_option(132); command.set_seed_argument({ "b0756302179e800b182514c729f1d6814c377ff06097569ef540e6c1f1950f08" }); BX_REQUIRE_OKAY(command.invoke(output, error)); BX_REQUIRE_OUTPUT("tube feature web hire limb run reject nuclear army zone brick below\n"); @@ -58,7 +55,6 @@ BOOST_AUTO_TEST_CASE(electrum_new__invoke__32_bytes__okay_output) BOOST_AUTO_TEST_CASE(electrum_new__invoke__32_bytes_220_bit_entropy__okay_output) { BX_DECLARE_COMMAND(electrum_new); - command.set_bit_length_option(220); command.set_seed_argument({ "b0756302179e800b182514c729f1d6814c377ff06097569ef540e6c1f1950f08" }); BX_REQUIRE_OKAY(command.invoke(output, error)); BX_REQUIRE_OUTPUT("cruise february web hire limb run reject nuclear army zone brick below public ladder deer below again cluster divorce ketchup\n"); diff --git a/test/commands/mnemonic-new.cpp b/test/commands/mnemonic-new.cpp index 711056c6d..3d54933df 100644 --- a/test/commands/mnemonic-new.cpp +++ b/test/commands/mnemonic-new.cpp @@ -37,7 +37,7 @@ BOOST_AUTO_TEST_CASE(mnemonic_new__invoke__136_bits__failure_error) BX_DECLARE_COMMAND(mnemonic_new); command.set_seed_argument({ "baadf00dbaadf00dbaadf00dbaadf00dff" }); BX_REQUIRE_FAILURE(command.invoke(output, error)); - BX_REQUIRE_ERROR(BX_EC_MNEMONIC_NEW_INVALID_ENTROPY "\n"); + BX_REQUIRE_ERROR(BX_EC_MNEMONIC_NEW_INVALID_SEED "\n"); } BOOST_AUTO_TEST_CASE(mnemonic_new__invoke__128_bits__okay_output) diff --git a/test/commands/mnemonic-to-seed.cpp b/test/commands/mnemonic-to-seed.cpp index 0f6870bb4..5b14d2fcb 100644 --- a/test/commands/mnemonic-to-seed.cpp +++ b/test/commands/mnemonic-to-seed.cpp @@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(mnemonic_to_seed__invoke__standard__okay_output) BX_REQUIRE_OUTPUT("2e8905819b8723fe2c1d161860e5ee1830318dbf49a83bd451cfb8440c28bd6fa457fe1296106559a3c80937a1c1069be3a3a5bd381ee6260e8d9739fce1f607\n"); #else BX_REQUIRE_FAILURE(command.invoke(output, error)); - BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_PASSPHRASE_UNSUPPORTED "\n"); + BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_REQUIRES_ICU "\n"); #endif } @@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE(mnemonic_to_seed__invoke__non_ascii_passphrase__okay_output BX_REQUIRE_OUTPUT("3e52585ea1275472a82fa0dcd84121e742140f64a302eca7c390832ba428c707a7ebf449267ae592c51f1740259226e31520de39fd8f33e08788fd21221c6f4e\n"); #else BX_REQUIRE_FAILURE(command.invoke(output, error)); - BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_PASSPHRASE_UNSUPPORTED "\n"); + BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_REQUIRES_ICU "\n"); #endif } @@ -119,7 +119,7 @@ BOOST_AUTO_TEST_CASE(mnemonic_to_seed__invoke__non_ascii_passphrase_and_words__o BX_REQUIRE_OUTPUT("e72505021b97e15171fe09e996898888579c4196c445d7629762c5b09586e3fb3d68380120b8d8a6ed6f9a73306dab7bf54127f3a610ede2a2d5b4e59916ac73\n"); #else BX_REQUIRE_FAILURE(command.invoke(output, error)); - BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_PASSPHRASE_UNSUPPORTED "\n"); + BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_REQUIRES_ICU "\n"); #endif } @@ -137,7 +137,7 @@ BOOST_AUTO_TEST_CASE(mnemonic_to_seed__invoke__non_ascii_passphrase_and_words_an BX_REQUIRE_OUTPUT("e72505021b97e15171fe09e996898888579c4196c445d7629762c5b09586e3fb3d68380120b8d8a6ed6f9a73306dab7bf54127f3a610ede2a2d5b4e59916ac73\n"); #else BX_REQUIRE_FAILURE(command.invoke(output, error)); - BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_PASSPHRASE_UNSUPPORTED "\n"); + BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_REQUIRES_ICU "\n"); #endif } @@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE(mnemonic_to_seed__invoke__non_ascii_passphrase_and_words_es BX_REQUIRE_OUTPUT("e72505021b97e15171fe09e996898888579c4196c445d7629762c5b09586e3fb3d68380120b8d8a6ed6f9a73306dab7bf54127f3a610ede2a2d5b4e59916ac73\n"); #else BX_REQUIRE_FAILURE(command.invoke(output, error)); - BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_PASSPHRASE_UNSUPPORTED "\n"); + BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_REQUIRES_ICU "\n"); #endif } @@ -173,7 +173,7 @@ BOOST_AUTO_TEST_CASE(mnemonic_to_seed__invoke__non_ascii_passphrase_and_words_an BX_REQUIRE_OUTPUT("a92538e2827914d13ead2b426aa45ebd0b16590318e04b6ef78780c8eb803269f08662dd74bc4982e7cbb71f15c71f310168457d570ad5fd89c98a6095bac560\n"); #else BX_REQUIRE_FAILURE(command.invoke(output, error)); - BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_PASSPHRASE_UNSUPPORTED "\n"); + BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_REQUIRES_ICU "\n"); #endif } @@ -191,7 +191,7 @@ BOOST_AUTO_TEST_CASE(mnemonic_to_seed__invoke__non_ascii_passphrase_and_words_fr BX_REQUIRE_OUTPUT("a92538e2827914d13ead2b426aa45ebd0b16590318e04b6ef78780c8eb803269f08662dd74bc4982e7cbb71f15c71f310168457d570ad5fd89c98a6095bac560\n"); #else BX_REQUIRE_FAILURE(command.invoke(output, error)); - BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_PASSPHRASE_UNSUPPORTED "\n"); + BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_REQUIRES_ICU "\n"); #endif } @@ -209,7 +209,7 @@ BOOST_AUTO_TEST_CASE(mnemonic_to_seed__invoke__non_ascii_passphrase_and_words_an BX_REQUIRE_OUTPUT("b145e13882dc52b64a868ba35c3a95de5f468f2963d9feca9a8b345e3a60ef02af42347f99bc35a72d88bdabe8d63a4f5b61a63d6cd549461b5dd11027b66cf7\n"); #else BX_REQUIRE_FAILURE(command.invoke(output, error)); - BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_PASSPHRASE_UNSUPPORTED "\n"); + BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_REQUIRES_ICU "\n"); #endif } @@ -227,7 +227,7 @@ BOOST_AUTO_TEST_CASE(mnemonic_to_seed__invoke__non_ascii_passphrase_and_words_it BX_REQUIRE_OUTPUT("b145e13882dc52b64a868ba35c3a95de5f468f2963d9feca9a8b345e3a60ef02af42347f99bc35a72d88bdabe8d63a4f5b61a63d6cd549461b5dd11027b66cf7\n"); #else BX_REQUIRE_FAILURE(command.invoke(output, error)); - BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_PASSPHRASE_UNSUPPORTED "\n"); + BX_REQUIRE_ERROR(BX_EC_MNEMONIC_TO_SEED_REQUIRES_ICU "\n"); #endif } From d75dec3f5d130ee9d69562f45b6687ff91a19dba Mon Sep 17 00:00:00 2001 From: evoskuil Date: Mon, 19 Feb 2018 11:10:24 -0800 Subject: [PATCH 3/4] Prioritize prefix package config in PKG_CONFIG_PATH search path. --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index b4b443a60..d1a4d4f6b 100755 --- a/install.sh +++ b/install.sh @@ -279,8 +279,8 @@ fi # Set the prefix-based package config directory. PREFIX_PKG_CONFIG_DIR="$PREFIX/lib/pkgconfig" -# Augment PKG_CONFIG_PATH search path with our prefix. -export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PREFIX_PKG_CONFIG_DIR" +# Prioritize prefix package config in PKG_CONFIG_PATH search path. +export PKG_CONFIG_PATH="$PREFIX_PKG_CONFIG_DIR:$PKG_CONFIG_PATH" # Set a package config save path that can be passed via our builds. with_pkgconfigdir="--with-pkgconfigdir=$PREFIX_PKG_CONFIG_DIR" From 6300c1eea0cf10d492a4b0adf12228da602a3373 Mon Sep 17 00:00:00 2001 From: Neill Miller Date: Mon, 19 Feb 2018 16:12:58 -0600 Subject: [PATCH 4/4] Update electrum-new tests --- test/commands/electrum-new.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/commands/electrum-new.cpp b/test/commands/electrum-new.cpp index 739181239..c2f355c52 100644 --- a/test/commands/electrum-new.cpp +++ b/test/commands/electrum-new.cpp @@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(electrum_new__invoke__17_bytes__okay_output) BX_REQUIRE_OUTPUT("giggle crush argue inflict wear defy combine evolve tiger spatial crumble fury\n"); } -BOOST_AUTO_TEST_CASE(electrum_new__invoke__dictionary_prefix__okay_output) +BOOST_AUTO_TEST_CASE(electrum_new__invoke__en_dictionary_prefix__okay_output) { BX_DECLARE_COMMAND(electrum_new); command.set_seed_argument({ "05e669b4270f4e25bce6fc3736170d423c" }); @@ -44,20 +44,22 @@ BOOST_AUTO_TEST_CASE(electrum_new__invoke__dictionary_prefix__okay_output) BX_REQUIRE_OUTPUT("giggle crush argue inflict wear defy combine evolve tiger spatial crumble fury\n"); } -BOOST_AUTO_TEST_CASE(electrum_new__invoke__32_bytes__okay_output) +BOOST_AUTO_TEST_CASE(electrum_new__invoke__es_dictionary_prefix__okay_output) { BX_DECLARE_COMMAND(electrum_new); - command.set_seed_argument({ "b0756302179e800b182514c729f1d6814c377ff06097569ef540e6c1f1950f08" }); + command.set_seed_argument({ "05e669b4270f4e25bce6fc3736170d423c" }); + command.set_language_option({ "es" }); + command.set_prefix_option({ "standard" }); BX_REQUIRE_OKAY(command.invoke(output, error)); - BX_REQUIRE_OUTPUT("tube feature web hire limb run reject nuclear army zone brick below\n"); + BX_REQUIRE_OUTPUT("gigante codo ámbar insecto verbo cráter celoso entrar tarjeta sala coco frito\n"); } -BOOST_AUTO_TEST_CASE(electrum_new__invoke__32_bytes_220_bit_entropy__okay_output) +BOOST_AUTO_TEST_CASE(electrum_new__invoke__32_bytes__okay_output) { BX_DECLARE_COMMAND(electrum_new); command.set_seed_argument({ "b0756302179e800b182514c729f1d6814c377ff06097569ef540e6c1f1950f08" }); BX_REQUIRE_OKAY(command.invoke(output, error)); - BX_REQUIRE_OUTPUT("cruise february web hire limb run reject nuclear army zone brick below public ladder deer below again cluster divorce ketchup\n"); + BX_REQUIRE_OUTPUT("divide february web hire limb run reject nuclear army zone brick below public ladder deer below again cluster divorce ketchup aerobic flee lonely absent\n"); } #endif