From 3d70455534cb00e0bb057edd70a976ece3493aaa Mon Sep 17 00:00:00 2001 From: dsc Date: Fri, 20 May 2022 17:25:47 +0200 Subject: [PATCH] wowify --- CMakeLists.txt | 10 +++---- README.md | 22 +++++++------- .../galois_field.hpp | 0 .../{monero_seed => wownero_seed}/gf_elem.hpp | 0 .../{monero_seed => wownero_seed}/gf_poly.hpp | 0 .../reed_solomon_code.hpp | 0 .../secure_random.hpp | 0 .../wordlist.hpp | 0 .../wownero_seed.hpp} | 10 +++---- src/galois_field.cpp | 2 +- src/gf_elem.cpp | 2 +- src/gf_poly.cpp | 2 +- src/main.cpp | 14 ++++----- src/reed_solomon_code.cpp | 2 +- src/secure_random.cpp | 2 +- src/wordlist.cpp | 2 +- src/{monero_seed.cpp => wownero_seed.cpp} | 30 +++++++++---------- 17 files changed, 49 insertions(+), 49 deletions(-) rename include/{monero_seed => wownero_seed}/galois_field.hpp (100%) rename include/{monero_seed => wownero_seed}/gf_elem.hpp (100%) rename include/{monero_seed => wownero_seed}/gf_poly.hpp (100%) rename include/{monero_seed => wownero_seed}/reed_solomon_code.hpp (100%) rename include/{monero_seed => wownero_seed}/secure_random.hpp (100%) rename include/{monero_seed => wownero_seed}/wordlist.hpp (100%) rename include/{monero_seed/monero_seed.hpp => wownero_seed/wownero_seed.hpp} (70%) rename src/{monero_seed.cpp => wownero_seed.cpp} (89%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2028ceb..e7462d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,14 +2,14 @@ cmake_minimum_required(VERSION 3.13) -option(MONERO_SEED_DEMO "Build a demo executable for monero-seed") +option(WOWNERO_SEED_DEMO "Build a demo executable for wownero-seed") if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) message(STATUS "Setting default build type: ${CMAKE_BUILD_TYPE}") endif() -project(monero-seed) +project(wownero-seed) include(GNUInstallDirs) @@ -21,7 +21,7 @@ src/argon2/ref.c src/galois_field.cpp src/gf_elem.cpp src/gf_poly.cpp -src/monero_seed.cpp +src/wownero_seed.cpp src/pbkdf2.c src/reed_solomon_code.cpp src/secure_random.cpp @@ -30,9 +30,9 @@ src/wordlist.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_include_directories(${PROJECT_NAME} PUBLIC $ - $) + $) -if(MONERO_SEED_DEMO) +if(WOWNERO_SEED_DEMO) add_executable(demo src/main.cpp) set_property(TARGET demo PROPERTY CXX_STANDARD 11) target_link_libraries(demo -Wl,--whole-archive ${PROJECT_NAME} -Wl,--no-whole-archive) diff --git a/README.md b/README.md index d44196e..ca8e585 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ## Build ``` -git clone https://github.com/tevador/monero-seed.git -cd monero-seed +git clone https://git.wownero.com/wowlet/wownero-seed.git +cd wownero-seed mkdir build && cd build cmake .. make @@ -19,35 +19,35 @@ make ### Create a new seed ``` -> ./monero-seed --create [--date ] [--coin ] +> ./wownero-seed --create [--date ] [--coin ] ``` Example: ``` -> ./monero-seed --create --date 2100/03/14 --coin monero +> ./wownero-seed --create --date 2100/03/14 --coin monero Mnemonic phrase: test park taste security oxygen decorate essence ridge ship fish vehicle dream fluid pattern -- coin: monero +- coin: wownero - private key: 7b816d8134e29393b0333eed4b6ed6edf97c156ad139055a706a6fb9599dcf8c - created on or after: 02/Mar/2100 ``` ### Restore seed ``` -./monero-seed --restore "<14-word seed>" [--coin ] +./wownero-seed --restore "<14-word seed>" [--coin ] ``` Example: ``` -> ./monero-seed --restore "test park taste security oxygen decorate essence ridge ship fish vehicle dream fluid pattern" --coin monero -- coin: monero +> ./wownero-seed --restore "test park taste security oxygen decorate essence ridge ship fish vehicle dream fluid pattern" --coin monero +- coin: wownero - private key: 7b816d8134e29393b0333eed4b6ed6edf97c156ad139055a706a6fb9599dcf8c - created on or after: 02/Mar/2100 ``` Attempting to restore the same seed under a different coin will fail: ``` -> ./monero-seed --restore "test park taste security oxygen decorate essence ridge ship fish vehicle dream fluid pattern" --coin aeon +> ./wownero-seed --restore "test park taste security oxygen decorate essence ridge ship fish vehicle dream fluid pattern" --coin aeon ERROR: phrase is invalid (checksum mismatch) ``` @@ -55,9 +55,9 @@ Restore has limited error correction capability, namely it can correct a single This can be tested by replacing a word with `xxxx`: ``` -> ./monero-seed --restore "test park xxxx security oxygen decorate essence ridge ship fish vehicle dream fluid pattern" --coin monero +> ./wownero-seed --restore "test park xxxx security oxygen decorate essence ridge ship fish vehicle dream fluid pattern" --coin monero Warning: corrected erasure: xxxx -> taste -- coin: monero +- coin: wownero - private key: 7b816d8134e29393b0333eed4b6ed6edf97c156ad139055a706a6fb9599dcf8c - created on or after: 02/Mar/2100 ``` diff --git a/include/monero_seed/galois_field.hpp b/include/wownero_seed/galois_field.hpp similarity index 100% rename from include/monero_seed/galois_field.hpp rename to include/wownero_seed/galois_field.hpp diff --git a/include/monero_seed/gf_elem.hpp b/include/wownero_seed/gf_elem.hpp similarity index 100% rename from include/monero_seed/gf_elem.hpp rename to include/wownero_seed/gf_elem.hpp diff --git a/include/monero_seed/gf_poly.hpp b/include/wownero_seed/gf_poly.hpp similarity index 100% rename from include/monero_seed/gf_poly.hpp rename to include/wownero_seed/gf_poly.hpp diff --git a/include/monero_seed/reed_solomon_code.hpp b/include/wownero_seed/reed_solomon_code.hpp similarity index 100% rename from include/monero_seed/reed_solomon_code.hpp rename to include/wownero_seed/reed_solomon_code.hpp diff --git a/include/monero_seed/secure_random.hpp b/include/wownero_seed/secure_random.hpp similarity index 100% rename from include/monero_seed/secure_random.hpp rename to include/wownero_seed/secure_random.hpp diff --git a/include/monero_seed/wordlist.hpp b/include/wownero_seed/wordlist.hpp similarity index 100% rename from include/monero_seed/wordlist.hpp rename to include/wownero_seed/wordlist.hpp diff --git a/include/monero_seed/monero_seed.hpp b/include/wownero_seed/wownero_seed.hpp similarity index 70% rename from include/monero_seed/monero_seed.hpp rename to include/wownero_seed/wownero_seed.hpp index 33c8d6a..42a06f0 100644 --- a/include/monero_seed/monero_seed.hpp +++ b/include/wownero_seed/wownero_seed.hpp @@ -11,15 +11,15 @@ #include #include "gf_poly.hpp" -class monero_seed { +class wownero_seed { public: static const std::string erasure; static constexpr size_t size = 16; static constexpr size_t key_size = 32; using secret_key = std::array; using secret_seed = std::array; - monero_seed(const std::string& phrase, const std::string& coin); - monero_seed(std::time_t date_created, const std::string& coin); + wownero_seed(const std::string& phrase, const std::string& coin); + wownero_seed(std::time_t date_created, const std::string& coin); std::time_t date() const { return date_; } @@ -29,7 +29,7 @@ public: const secret_key& key() const { return key_; } - friend std::ostream& operator<<(std::ostream& os, const monero_seed& seed); + friend std::ostream& operator<<(std::ostream& os, const wownero_seed& seed); private: secret_seed seed_; secret_key key_; @@ -39,4 +39,4 @@ private: gf_poly message_; }; -std::ostream& operator<<(std::ostream& os, const monero_seed::secret_key& key); +std::ostream& operator<<(std::ostream& os, const wownero_seed::secret_key& key); diff --git a/src/galois_field.cpp b/src/galois_field.cpp index 675dd26..02f641c 100644 --- a/src/galois_field.cpp +++ b/src/galois_field.cpp @@ -3,7 +3,7 @@ All rights reserved. */ -#include +#include template galois_field::galois_field() { diff --git a/src/gf_elem.cpp b/src/gf_elem.cpp index 6f2a69b..5762df3 100644 --- a/src/gf_elem.cpp +++ b/src/gf_elem.cpp @@ -3,6 +3,6 @@ All rights reserved. */ -#include +#include const gf_2048 gf_elem::field; diff --git a/src/gf_poly.cpp b/src/gf_poly.cpp index cc8af39..8ba1ccc 100644 --- a/src/gf_poly.cpp +++ b/src/gf_poly.cpp @@ -3,7 +3,7 @@ All rights reserved. */ -#include +#include gf_poly::gf_poly(gf_elem coeff, unsigned degree) : degree_(0) { coeff_[degree] = coeff; diff --git a/src/main.cpp b/src/main.cpp index 577b40c..33590f9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,7 +3,7 @@ All rights reserved. */ -#include +#include #include #include #include @@ -51,9 +51,9 @@ static time_t parse_date(const char* s) { throw std::runtime_error("invalid date"); } -void print_seed(const monero_seed& seed, const char* coin, bool phrase) { +void print_seed(const wownero_seed& seed, const char* coin, bool phrase) { if (!seed.correction().empty()) { - std::cout << "Warning: corrected erasure: " << monero_seed::erasure << " -> " << seed.correction() << std::endl; + std::cout << "Warning: corrected erasure: " << wownero_seed::erasure << " -> " << seed.correction() << std::endl; } if (phrase) { std::cout << "Mnemonic phrase: " << seed << std::endl; @@ -72,7 +72,7 @@ int main(int argc, const char* argv[]) { const char* restore; read_option("--create", argc, argv, create); read_string_option("--date", argc, argv, &create_date); - read_string_option("--coin", argc, argv, &coin, "monero"); + read_string_option("--coin", argc, argv, &coin, "wownero"); read_string_option("--restore", argc, argv, &restore); try { @@ -84,15 +84,15 @@ int main(int argc, const char* argv[]) { else { time = std::time(nullptr); } - monero_seed seed(time, coin); + wownero_seed seed(time, coin); print_seed(seed, coin, true); } else if (restore != nullptr) { - monero_seed seed(restore, coin); + wownero_seed seed(restore, coin); print_seed(seed, coin, false); } else { - std::cout << "Monero 14-word mnemonic seed proof of concept" << std::endl; + std::cout << "14-word mnemonic seed" << std::endl; std::cout << "Usage: " << std::endl; std::cout << argv[0] << " --create [--date ] [--coin ]" << std::endl; std::cout << argv[0] << " --restore \"<14-word seed>\" [--coin ]" << std::endl; diff --git a/src/reed_solomon_code.cpp b/src/reed_solomon_code.cpp index 4b80539..d0a4f8e 100644 --- a/src/reed_solomon_code.cpp +++ b/src/reed_solomon_code.cpp @@ -3,7 +3,7 @@ All rights reserved. */ -#include +#include #include reed_solomon_code::reed_solomon_code(unsigned check_digits) : generator(1, 0) { diff --git a/src/secure_random.cpp b/src/secure_random.cpp index d23648b..f4b29d4 100644 --- a/src/secure_random.cpp +++ b/src/secure_random.cpp @@ -3,7 +3,7 @@ All rights reserved. */ -#include +#include #include #include diff --git a/src/wordlist.cpp b/src/wordlist.cpp index dc1cd1f..20eb00a 100644 --- a/src/wordlist.cpp +++ b/src/wordlist.cpp @@ -3,7 +3,7 @@ All rights reserved. */ -#include +#include #include const static std::string english_words[] = { diff --git a/src/monero_seed.cpp b/src/wownero_seed.cpp similarity index 89% rename from src/monero_seed.cpp rename to src/wownero_seed.cpp index 720c06c..523bce4 100644 --- a/src/monero_seed.cpp +++ b/src/wownero_seed.cpp @@ -3,11 +3,11 @@ All rights reserved. */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "argon2/argon2.h" #include "argon2/blake2/blake2-impl.h" #include "pbkdf2.h" @@ -20,14 +20,14 @@ #include #include -const std::string monero_seed::erasure = "xxxx"; +const std::string wownero_seed::erasure = "xxxx"; -class monero_seed_exception : public std::exception { +class wownero_seed_exception : public std::exception { public: - monero_seed_exception(const std::string& msg) + wownero_seed_exception(const std::string& msg) : msg_(msg) { } - ~monero_seed_exception() throw() {} + ~wownero_seed_exception() throw() {} const char* what() const throw() override { return msg_.c_str(); @@ -39,7 +39,7 @@ private: #define THROW_EXCEPTION(message) do { \ std::ostringstream oss; \ oss << message; \ - throw monero_seed_exception(oss.str()); } \ + throw wownero_seed_exception(oss.str()); } \ while(false) constexpr std::time_t epoch = 1590969600; //1st June 2020 @@ -69,7 +69,7 @@ static const char* KDF_PBKDF2 = "PBKDF2-HMAC-SHA256/4096"; static_assert(total_bits == reserved_bits + date_bits + checksum_size + - sizeof(monero_seed::secret_seed) * CHAR_BIT, + sizeof(wownero_seed::secret_seed) * CHAR_BIT, "Invalid mnemonic seed size"); static void write_data(gf_poly& poly, unsigned& rem_bits, unsigned value, unsigned bits) { @@ -117,7 +117,7 @@ static gf_elem get_coin_flag(const std::string& coin) { static const reed_solomon_code rs(check_digits); -monero_seed::monero_seed(std::time_t date_created, const std::string& coin) { +wownero_seed::wownero_seed(std::time_t date_created, const std::string& coin) { if (date_created < epoch) { THROW_EXCEPTION("date_created must not be before 1st June 2020"); } @@ -142,7 +142,7 @@ monero_seed::monero_seed(std::time_t date_created, const std::string& coin) { message_[check_digits] -= coin_flag; } -monero_seed::monero_seed(const std::string& phrase, const std::string& coin) { +wownero_seed::wownero_seed(const std::string& phrase, const std::string& coin) { gf_elem coin_flag = get_coin_flag(coin); int word_count = 0; size_t offset = 0; @@ -222,7 +222,7 @@ monero_seed::monero_seed(const std::string& phrase, const std::string& coin) { pbkdf2_hmac_sha256(seed_.data(), seed_.size(), salt, sizeof(salt), pbkdf2_iterations, key_.data(), key_.size()); } -std::ostream& operator<<(std::ostream& os, const monero_seed& seed) { +std::ostream& operator<<(std::ostream& os, const wownero_seed& seed) { for (int i = 0; i <= seed.message_.degree(); ++i) { if (i > 0) { os << " "; @@ -232,7 +232,7 @@ std::ostream& operator<<(std::ostream& os, const monero_seed& seed) { return os; } -std::ostream& operator<<(std::ostream& os, const monero_seed::secret_key& key) { +std::ostream& operator<<(std::ostream& os, const wownero_seed::secret_key& key) { os << std::hex; for (int i = 0; i < key.size(); ++i) { os << std::setw(2) << std::setfill('0') << (unsigned)key[i];