Skip to content

Commit

Permalink
fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sinev-valentine committed Mar 15, 2019
1 parent a2ec4de commit 2c392eb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
12 changes: 11 additions & 1 deletion keychain_cmd_app/cmd_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <boost/program_options.hpp>
#include <keychain_lib/keychain_logger.hpp>

#include <keychain_lib/keydata_singleton.hpp>

//#include <boost/program_options/options_description.hpp>
//#include <boost/program_options/option.hpp>

Expand Down Expand Up @@ -116,7 +118,15 @@ int cmd_parser::run(int argc, const char* const argv[])
auto& keyfiles = keyfile_singleton::instance();
auto it = keyfiles.begin();
if ( it==keyfiles.end() )
auto res = keychain_ref.entropy();
{
auto res = keychain_ref.entropy();
/* auto& key_data = keydata_singleton::instance();
dev::bytes ue;
auto mnemonics = std::move(key_data.seed(ue));
std::string pass("blank");
key_data.create_masterkey(mnemonics,pass);
key_data.create_privatekey();*/
}

keychain_invoke_f f = std::bind(&keychain_base::operator(), &keychain_ref, std::placeholders::_1);
pipeline_parser pipe_line_parser_(std::move(f), fileno(stdin), fileno(stdout));
Expand Down
2 changes: 1 addition & 1 deletion keychain_lib/include/keychain_lib/keydata_singleton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct keydata_singleton
{
static keydata_singleton& instance();
std::string seed(dev::bytes& );
void create_masterkey(std::string&);
void create_masterkey(std::string&, std::string&);
void create_privatekey();

private:
Expand Down
4 changes: 3 additions & 1 deletion keychain_lib/include/keychain_lib/keyfile_singleton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
#include <boost/multi_index/mem_fun.hpp>
#include <boost/multi_index/tag.hpp>
#include <boost/multi_index/identity.hpp>
#include <boost/filesystem.hpp>

#include <fc_light/exception/exception.hpp>

#include "keyfile_parser.hpp"
#include "secmod_protocol.hpp"

namespace keychain_app {

Expand Down Expand Up @@ -189,7 +191,7 @@ class keyfile_singleton

};

using get_password_create_f = std::function<byte_seq_t(const std::string&)>; //NOTE: may incapsulate call to sec module or just return password string
using get_password_create_f = std::function<keychain_app::byte_seq_t(const std::string&)>; //NOTE: may incapsulate call to sec module or just return password string

keyfile_format::keyfile_t create_new_keyfile(
const std::string& keyname,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
//
// Created by user on 3/15/19.
//
#include "keydata_singleton.hpp"
#include <cryptopp/osrng.h>
#include <cryptopp/hex.h>
#include <cryptopp/pwdbased.h>
#include "hdkeys.h"
#include "wordlist.hpp"
#include <wordlist.hpp>
#include <fc_light/crypto/sha256.hpp>
#include <keydata_singleton.hpp>
#include <keyfile_singleton.hpp>

using namespace keychain_app;

Expand Down Expand Up @@ -85,12 +86,22 @@ std::vector<char> keydata_singleton::pbkdf2(std::string const& _pass)
}


void keydata_singleton::create_masterkey(std::string& mnemonics)
void keydata_singleton::create_masterkey(std::string& mnemonics, std::string& pass)
{
std::vector<char> key = std::move(pbkdf2(mnemonics));
dev::Secret master_key(dev::FixedHash<32>((byte * const)key.data(), dev::FixedHash<32>::ConstructFromPointerType::ConstructFromPointer));
dev::Secret chain_code(dev::FixedHash<32>((byte * const)key.data()+32, dev::FixedHash<32>::ConstructFromPointerType::ConstructFromPointer));

auto & keyfiles = keyfile_singleton::instance();
keyfiles.create(std::bind(create_new_keyfile,
"master_key", "master_key", true, keyfile_format::cipher_etype::aes256,
keyfile_format::curve_etype::secp256k1,
[&pass](const std::string& keyname)->byte_seq_t{
byte_seq_t res;
std::copy(pass.begin(), pass.end(), std::back_inserter(res));
return res;
})
);
}


Expand Down

0 comments on commit 2c392eb

Please sign in to comment.