diff --git a/.gitmodules b/.gitmodules
index 398e14cd..cce2097f 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,9 +1,6 @@
[submodule "src/lib/uECC"]
path = src/lib/uECC
url = https://github.com/kmackay/micro-ecc
-[submodule "src/lib/bip39"]
- path = src/lib/bip39
- url = https://github.com/ciband/bip39.git
[submodule "test/lib/googletest"]
path = test/lib/googletest
url = https://github.com/google/googletest.git
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d04e81a0..900370c5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+## [0.5.0] - 2019-02-20
+
+### Changed
+
+- removed bip39 and mnemonic feature ([#86])
+
## [0.4.0] - 2019-05-20
### Changed
diff --git a/docs/INSTALL_PLATFORMIO.md b/docs/INSTALL_PLATFORMIO.md
index 7466e153..f1eab693 100644
--- a/docs/INSTALL_PLATFORMIO.md
+++ b/docs/INSTALL_PLATFORMIO.md
@@ -18,8 +18,8 @@ or
also install platformio dependencies:
-> install AUnit (2778), micro-ecc (1665) bip39 (5886) ArduinoJson@6.10.0 libraries
->```platformio lib -g install 2778 1665 5886 ArduinoJson@6.10.0```
+> install AUnit (2778), micro-ecc (1665) ArduinoJson@6.10.0 libraries
+>```platformio lib -g install 2778 1665 ArduinoJson@6.10.0```
#
diff --git a/docs/cpp.md b/docs/cpp.md
index ed031d48..14ebd569 100644
--- a/docs/cpp.md
+++ b/docs/cpp.md
@@ -68,18 +68,6 @@ message.verify();
## Identities
-### Passphrase
-
-#### Generate a default passphrase with 12 words in English
-```cpp
-const auto passphrase = Ark::Crypto::Identies::Mnemonic::generate();
-```
-
-#### Generate a passphrase with the given language and 24 words
-```cpp
-const auto passphrase = Ark::Crypto::Identies::Mnemonic::generate(24, Ark::Crypto::Identies::Language::en);
-```
-
### Address
#### Get an address from a passphrase
diff --git a/examples/cmake_example/main.cpp b/examples/cmake_example/main.cpp
index 240df745..b42f2bac 100644
--- a/examples/cmake_example/main.cpp
+++ b/examples/cmake_example/main.cpp
@@ -34,11 +34,6 @@ int main(int argc, char* argv[]) {
std::cout << "\tVerified: " << std::boolalpha << message.verify() << '\n';
std::cout << '\n';
- // Mnemonic
- const auto new_passphrase = Ark::Crypto::Identities::Mnemonic::generate();
- std::cout << "Generated Mnemonic: " << new_passphrase << '\n';
- std::cout << '\n';
-
// Address - from passphrase
const uint8_t networkVersion = 0x1E;
auto address = Address::fromPassphrase(passphrase, networkVersion);
diff --git a/examples/platformio_example/src/main.ino b/examples/platformio_example/src/main.ino
index 9194ae72..c6eee361 100644
--- a/examples/platformio_example/src/main.ino
+++ b/examples/platformio_example/src/main.ino
@@ -42,11 +42,6 @@ void loop() {
Serial.print("\tVerified: "); Serial.print(message.verify()); Serial.println();
Serial.println();
- // Mnemonic
- const auto new_passphrase = Ark::Crypto::Identities::Mnemonic::generate();
- Serial.print("Generated Mnemonic: "); Serial.print(new_passphrase.c_str()); Serial.println();
- Serial.println();
-
// Address - from passphrase
const uint8_t networkVersion = 0x1E;
auto address = Address::fromPassphrase(passphrase, networkVersion);
diff --git a/extras/ARDUINO_IDE.sh b/extras/ARDUINO_IDE.sh
index 4ed924ce..53ddf899 100644
--- a/extras/ARDUINO_IDE.sh
+++ b/extras/ARDUINO_IDE.sh
@@ -115,15 +115,6 @@ if [[ -d ${INCLUDE_DIR} ]]; then
mkdir ${SRC_ENCODING_DIR}
mv ${INCLUDE_HELPERS_DIR}/encoding/hex.h ${SRC_ENCODING_DIR}
- ## 'bip39' library is not supported in Arduino
- echo -e "Backing up and removing 'mnemonic.h'.\n"
- mkdir ${EXTRAS_BACKUP_DIR}
- mkdir ${EXTRAS_IDENTITIES_DIR}
- mv ${INCLUDE_IDENTITIES_DIR}/mnemonic.h ${EXTRAS_IDENTITIES_DIR}
- mv ${SRC_IDENTITIES_DIR}/mnemonic.cpp ${EXTRAS_IDENTITIES_DIR}
- echo "// this is a dummy file" >> ${SRC_IDENTITIES_DIR}/mnemonic.h
- echo "// this is a dummy file" >> ${SRC_IDENTITIES_DIR}/mnemonic.cpp
-
echo -e "Moving 'identites' headers.\n"
mv ${INCLUDE_IDENTITIES_DIR}/address.h ${SRC_IDENTITIES_DIR}
mv ${INCLUDE_IDENTITIES_DIR}/privatekey.h ${SRC_IDENTITIES_DIR}
@@ -144,7 +135,6 @@ if [[ -d ${INCLUDE_DIR} ]]; then
echo -e "Backing up, moving, and removing relevant modules from the 'lib' directory.\n"
mv ${SRC_LIB_DIR}/ArduinoJson ${EXTRAS_BACKUP_DIR}
- mv ${SRC_LIB_DIR}/bip39 ${EXTRAS_BACKUP_DIR}
mv ${SRC_LIB_DIR}/uECC ${EXTRAS_BACKUP_DIR}
mv ${SRC_LIB_DIR}/bcl ${SRC_DIR}
mv ${SRC_LIB_DIR}/date ${SRC_DIR}
@@ -196,7 +186,6 @@ else
echo -e "Moving 'identities' headers.\n"
mv ${SRC_IDENTITIES_DIR}/address.h ${INCLUDE_IDENTITIES_DIR}
- mv ${SRC_IDENTITIES_DIR}/mnemonic.h ${INCLUDE_IDENTITIES_DIR}
mv ${SRC_IDENTITIES_DIR}/privatekey.h ${INCLUDE_IDENTITIES_DIR}
mv ${SRC_IDENTITIES_DIR}/publickey.h ${INCLUDE_IDENTITIES_DIR}
mv ${SRC_IDENTITIES_DIR}/wif.h ${INCLUDE_IDENTITIES_DIR}
@@ -213,18 +202,9 @@ else
mv ${SRC_TRANSACTIONS_DIR}/serializer.h ${INCLUDE_TRANSACTIONS_DIR}
mv ${SRC_TRANSACTIONS_DIR}/transaction.h ${INCLUDE_TRANSACTIONS_DIR}
- ## 'bip39' library is not supported in Arduino
- echo -e "Restoring 'mnemonic.h'.\n"
- rm -rf ${SRC_IDENTITIES_DIR}/mnemonic.h
- rm -rf ${SRC_IDENTITIES_DIR}/mnemonic.cpp
- mv ${EXTRAS_IDENTITIES_DIR}/mnemonic.h ${INCLUDE_IDENTITIES_DIR}
- mv ${EXTRAS_IDENTITIES_DIR}/mnemonic.cpp ${SRC_IDENTITIES_DIR}
- rm -rf ${EXTRAS_IDENTITIES_DIR}/mnemonic.cpp
-
echo -e "Restoring the 'lib' directory.\n"
mkdir ${SRC_LIB_DIR}
mv ${EXTRAS_BACKUP_DIR}/ArduinoJson ${SRC_LIB_DIR}
- mv ${EXTRAS_BACKUP_DIR}/bip39 ${SRC_LIB_DIR}
mv ${EXTRAS_BACKUP_DIR}/uECC ${SRC_LIB_DIR}
mv ${SRC_DIR}/bcl ${SRC_LIB_DIR}
mv ${SRC_DIR}/date ${SRC_LIB_DIR}
diff --git a/keywords.txt b/keywords.txt
index 88450489..98cd5e48 100644
--- a/keywords.txt
+++ b/keywords.txt
@@ -22,7 +22,6 @@ Fees KEYWORD1
Types KEYWORD1
Address KEYWORD1
-Mnemonic KEYWORD1
PrivateKey KEYWORD1
PublicKey KEYWORD1
WIF KEYWORD1
diff --git a/library.json b/library.json
index 9cb19d62..c02cabc3 100644
--- a/library.json
+++ b/library.json
@@ -7,7 +7,7 @@
"type": "git",
"url": "https://github.com/ArkEcosystem/Cpp-Crypto.git"
},
- "version": "0.4.0",
+ "version": "0.5.0",
"authors": [
{
"name": "Ark Ecosystem",
@@ -21,9 +21,6 @@
{
"name": "micro-ecc"
},
- {
- "name": "bip39"
- },
{
"name": "ArduinoJson"
}
diff --git a/library.properties b/library.properties
index c9ac8409..7821733c 100644
--- a/library.properties
+++ b/library.properties
@@ -1,5 +1,5 @@
name=Ark-Cpp-Crypto
-version=0.4.0
+version=0.5.0
author=Ark Ecosystem
maintainer=Ark Ecosystem
sentence=A simple Cryptography Implementation in C++ for the ARK Blockchain.
diff --git a/platformio.ini b/platformio.ini
index 8cc3220f..5ad5519d 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -15,7 +15,7 @@ description = "A simple Cryptography Implementation in C++ for the ARK Blockchai
lib_ldf_mode = off
lib_deps = micro-ecc, bip39@^1.1, ArduinoJson@6.10.0, BIP66
build_flags = -I./src/ -I./src/lib -I./src/include/cpp-crypto
-src_filter = +<*> -<.git/> - - - - - -
+src_filter = +<*> -<.git/> - -- - -
upload_speed = 921600
[env:esp8266]
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7e1c1144..0511290d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -3,8 +3,6 @@ cmake_minimum_required(VERSION 3.2.2)
project(Ark-Cpp-Crypto-lib C CXX)
-add_subdirectory(lib/bip39/src)
-
set(BIP66_SRC
${PROJECT_SOURCE_DIR}/lib/BIP66/src/bip66.cpp
)
@@ -31,7 +29,6 @@ set(COMMON_SRC
configuration/network.cpp
helpers/crypto.cpp
identities/address.cpp
- identities/mnemonic.cpp
identities/privatekey.cpp
identities/publickey.cpp
identities/wif.cpp
@@ -60,7 +57,6 @@ include_directories(${cpp_crypto_build_include_dirs})
include_directories(${PROJECT_SOURCE_DIR}/lib/)
include_directories(${PROJECT_SOURCE_DIR}/lib/ArduinoJson)
include_directories(${PROJECT_SOURCE_DIR}/lib/bcl)
-include_directories(${PROJECT_SOURCE_DIR}/lib/bip39)
include_directories(${PROJECT_SOURCE_DIR}/lib/rfc6979)
include_directories(${PROJECT_SOURCE_DIR}/lib/uECC)
include_directories(${PROJECT_SOURCE_DIR}/lib/BIP66/src)
@@ -69,8 +65,6 @@ target_include_directories( ${PROJECT_NAME}
PUBLIC ${cpp_crypto_build_include_dirs}
)
-target_link_libraries(${PROJECT_NAME} PRIVATE bip39)
-
if (MSVC)
target_link_libraries(${PROJECT_NAME} PUBLIC crypt32)
endif()
diff --git a/src/identities/mnemonic.cpp b/src/identities/mnemonic.cpp
deleted file mode 100644
index d3bffc76..00000000
--- a/src/identities/mnemonic.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * This file is part of Ark Cpp Crypto.
- *
- * (c) Ark Ecosystem
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- **/
-
-#include "identities/mnemonic.h"
-
-#include "bip39/bip39.h"
-
-#include
-
-namespace Ark {
-namespace Crypto {
-namespace Identities {
-
-std::string Mnemonic::generate(size_t num_words /* = 12u */, Language language /* = Language::en */) {
- static const std::map words_to_entropy = {{12, BIP39::entropy_bits_t::_128},
- {15, BIP39::entropy_bits_t::_160},
- {18, BIP39::entropy_bits_t::_192},
- {21, BIP39::entropy_bits_t::_224},
- {24, BIP39::entropy_bits_t::_256}};
- static const std::map language_map = {
- {Language::en, BIP39::language::en}, {Language::es, BIP39::language::es},
- {Language::ja, BIP39::language::ja}, {Language::it, BIP39::language::it},
- {Language::fr, BIP39::language::fr}, {Language::ko, BIP39::language::ko},
- {Language::zh_Hans, BIP39::language::zh_Hans}, {Language::zh_Hant, BIP39::language::zh_Hant}};
-
- const auto entropy_it = words_to_entropy.find(num_words);
- assert(entropy_it != words_to_entropy.end());
-
- const auto lang = language_map.find(language);
- assert(lang != language_map.end());
-
- return BIP39::generate_mnemonic(entropy_it->second, lang->second).to_string();
-}
-
-} // namespace Identities
-} // namespace Crypto
-} // namespace Ark
diff --git a/src/include/cpp-crypto/arkCrypto.h b/src/include/cpp-crypto/arkCrypto.h
index ff9f56b9..17f23742 100644
--- a/src/include/cpp-crypto/arkCrypto.h
+++ b/src/include/cpp-crypto/arkCrypto.h
@@ -22,7 +22,6 @@
#include "enums/types.h"
#include "identities/address.h"
-#include "identities/mnemonic.h"
#include "identities/privatekey.h"
#include "identities/publickey.h"
#include "identities/wif.h"
diff --git a/src/include/cpp-crypto/identities/mnemonic.h b/src/include/cpp-crypto/identities/mnemonic.h
deleted file mode 100644
index 831a1988..00000000
--- a/src/include/cpp-crypto/identities/mnemonic.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * This file is part of Ark Cpp Crypto.
- *
- * (c) Ark Ecosystem
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- **/
-
-#ifndef MNEMONIC_H
-#define MNEMONIC_H
-
-#include
-
-namespace Ark {
-namespace Crypto {
-namespace Identities {
-
-enum class Language { en, es, ja, it, fr, ko, zh_Hans, zh_Hant };
-
-class Mnemonic {
- public:
- /// Generate a BIP39 passphrase with the given number of words (12,15,18,21,24) and given language
- static std::string generate(size_t num_words = 12u, Language language = Language::en);
-};
-
-} // namespace Identities
-} // namespace Crypto
-} // namespace Ark
-#endif
diff --git a/src/lib/bip39 b/src/lib/bip39
deleted file mode 160000
index ea4224e8..00000000
--- a/src/lib/bip39
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit ea4224e8055210f2578a862ce00fee7429fabeba
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 9cb1b7d4..b79d8dc9 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -24,7 +24,6 @@ set (TEST_SRC
${PROJECT_SOURCE_DIR}/enums/fees.cpp
${PROJECT_SOURCE_DIR}/enums/types.cpp
${PROJECT_SOURCE_DIR}/identities/address.cpp
- ${PROJECT_SOURCE_DIR}/identities/mnemonic.cpp
${PROJECT_SOURCE_DIR}/identities/privatekey.cpp
${PROJECT_SOURCE_DIR}/identities/publickey.cpp
${PROJECT_SOURCE_DIR}/identities/wif.cpp
diff --git a/test/identities/mnemonic.cpp b/test/identities/mnemonic.cpp
deleted file mode 100644
index c021244d..00000000
--- a/test/identities/mnemonic.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-
-#include "gtest/gtest.h"
-
-#include "identities/mnemonic.h"
-
-#include
-#include
-
-namespace {
-
-const auto MAX_WORD_BYTES =
- ((8 * 4) + 1) *
- 24; // ((8 characters per word * 4 potential octets per character) + 1 nul terminator) * maximum of 24 words
-}
-
-// Note: generate_mnemonic_valid_[lang] tests could be refactored to use a single helper function with a language
-// argument.
-// This causes problems with AUnit when building and testing IoT due to ASSERT macros not being available.
-TEST(mnemonic, generate_mnemonic_valid_en) {
- for (auto num_words = 12u; num_words <= 24u; num_words += 3) {
- auto passphrase = Ark::Crypto::Identities::Mnemonic::generate(num_words, Ark::Crypto::Identities::Language::en);
- // use a set to ensure no duplicate words can be added
- std::set words;
- char s[MAX_WORD_BYTES] = {};
- strncpy(s, passphrase.c_str(), sizeof(s));
- auto pch = strtok(s, " ");
- while (pch != nullptr) {
- ASSERT_TRUE(words.insert(pch).second);
- pch = strtok(nullptr, " ");
- }
-
- ASSERT_EQ(num_words, words.size());
- }
-}
-
-TEST(mnemonic, generate_mnemonic_valid_es) {
- for (auto num_words = 12u; num_words <= 24u; num_words += 3) {
- auto passphrase = Ark::Crypto::Identities::Mnemonic::generate(num_words, Ark::Crypto::Identities::Language::es);
- // use a set to ensure no duplicate words can be added
- std::set words;
- char s[MAX_WORD_BYTES] = {};
- strncpy(s, passphrase.c_str(), sizeof(s));
- auto pch = strtok(s, " ");
- while (pch != nullptr) {
- ASSERT_TRUE(words.insert(pch).second);
- pch = strtok(nullptr, " ");
- }
-
- ASSERT_EQ(num_words, words.size());
- }
-}
-
-TEST(mnemonic, generate_mnemonic_valid_ja) {
- for (auto num_words = 12u; num_words <= 24u; num_words += 3) {
- auto passphrase = Ark::Crypto::Identities::Mnemonic::generate(num_words, Ark::Crypto::Identities::Language::ja);
- // use a set to ensure no duplicate words can be added
- std::set words;
- char s[MAX_WORD_BYTES] = {};
- strncpy(s, passphrase.c_str(), sizeof(s));
- auto pch = strtok(s, " ");
- while (pch != nullptr) {
- ASSERT_TRUE(words.insert(pch).second);
- pch = strtok(nullptr, " ");
- }
-
- ASSERT_EQ(num_words, words.size());
- }
-}
-
-TEST(mnemonic, generate_mnemonic_valid_it) {
- for (auto num_words = 12u; num_words <= 24u; num_words += 3) {
- auto passphrase = Ark::Crypto::Identities::Mnemonic::generate(num_words, Ark::Crypto::Identities::Language::it);
- // use a set to ensure no duplicate words can be added
- std::set words;
- char s[MAX_WORD_BYTES] = {};
- strncpy(s, passphrase.c_str(), sizeof(s));
- auto pch = strtok(s, " ");
- while (pch != nullptr) {
- ASSERT_TRUE(words.insert(pch).second);
- pch = strtok(nullptr, " ");
- }
-
- ASSERT_EQ(num_words, words.size());
- }
-}
-
-TEST(mnemonic, generate_mnemonic_valid_fr) {
- for (auto num_words = 12u; num_words <= 24u; num_words += 3) {
- auto passphrase = Ark::Crypto::Identities::Mnemonic::generate(num_words, Ark::Crypto::Identities::Language::fr);
- // use a set to ensure no duplicate words can be added
- std::set words;
- char s[MAX_WORD_BYTES] = {};
- strncpy(s, passphrase.c_str(), sizeof(s));
- auto pch = strtok(s, " ");
- while (pch != nullptr) {
- ASSERT_TRUE(words.insert(pch).second);
- pch = strtok(nullptr, " ");
- }
-
- ASSERT_EQ(num_words, words.size());
- }
-}
-
-TEST(mnemonic, generate_mnemonic_valid_ko) {
- for (auto num_words = 12u; num_words <= 24u; num_words += 3) {
- auto passphrase = Ark::Crypto::Identities::Mnemonic::generate(num_words, Ark::Crypto::Identities::Language::ko);
- // use a set to ensure no duplicate words can be added
- std::set words;
- char s[MAX_WORD_BYTES] = {};
- strncpy(s, passphrase.c_str(), sizeof(s));
- auto pch = strtok(s, " ");
- while (pch != nullptr) {
- ASSERT_TRUE(words.insert(pch).second);
- pch = strtok(nullptr, " ");
- }
-
- ASSERT_EQ(num_words, words.size());
- }
-}
-
-TEST(mnemonic, generate_mnemonic_valid_zh_Hans) {
- for (auto num_words = 12u; num_words <= 24u; num_words += 3) {
- auto passphrase =
- Ark::Crypto::Identities::Mnemonic::generate(num_words, Ark::Crypto::Identities::Language::zh_Hans);
- // use a set to ensure no duplicate words can be added
- std::set words;
- char s[MAX_WORD_BYTES] = {};
- strncpy(s, passphrase.c_str(), sizeof(s));
- auto pch = strtok(s, " ");
- while (pch != nullptr) {
- ASSERT_TRUE(words.insert(pch).second);
- pch = strtok(nullptr, " ");
- }
-
- ASSERT_EQ(num_words, words.size());
- }
-}
-
-TEST(mnemonic, generate_mnemonic_valid_zh_Hant) {
- for (auto num_words = 12u; num_words <= 24u; num_words += 3) {
- auto passphrase =
- Ark::Crypto::Identities::Mnemonic::generate(num_words, Ark::Crypto::Identities::Language::zh_Hant);
- // use a set to ensure no duplicate words can be added
- std::set words;
- char s[MAX_WORD_BYTES] = {};
- strncpy(s, passphrase.c_str(), sizeof(s));
- auto pch = strtok(s, " ");
- while (pch != nullptr) {
- ASSERT_TRUE(words.insert(pch).second);
- pch = strtok(nullptr, " ");
- }
-
- ASSERT_EQ(num_words, words.size());
- }
-}
-
-// These tests depend on the library asserting, disable this test for Release builds
-#ifdef DEBUG
-TEST(mnemonic, generate_mnemonic_invalid) {
- for (auto num_words = 0u; num_words <= 100u; ++num_words) {
- // skip the valid word cases
- if (num_words == 12u || num_words == 15u || num_words == 18u || num_words == 21u || num_words == 24u) {
- continue;
- }
-
- ASSERT_DEATH(Ark::Crypto::Identities::Mnemonic::generate(num_words), "");
- }
-}
-#endif
diff --git a/test/platformio.ini b/test/platformio.ini
index bcfd048e..e510f98c 100644
--- a/test/platformio.ini
+++ b/test/platformio.ini
@@ -17,7 +17,7 @@ lib_dir = ..
lib_ldf_mode = off
lib_deps = micro-ecc, bip39@^1.1, AUnit, ArduinoJson@6.10.0, BIP66
build_flags = -I../test/iot/ -I../src -I../src/lib -I../src/include/cpp-crypto -DUNIT_TEST
-src_filter = +<*> -<.git/> - - - - -<_3rdParty> - - - - - - - -
+src_filter = +<*> -<.git/> - - - - -<_3rdParty> - - - - - - -
upload_speed = 921600
# esp8266 unit tests disabled until support is worked out