Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rai::pub_key instead of ed25519_publickey #1059

Merged
merged 2 commits into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions rai/core_test/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
TEST (ed25519, signing)
{
rai::uint256_union prv (0);
rai::uint256_union pub;
ed25519_publickey (prv.bytes.data (), pub.bytes.data ());
rai::uint256_union pub (rai::pub_key (prv));
rai::uint256_union message (0);
rai::uint512_union signature;
ed25519_sign (message.bytes.data (), sizeof (message.bytes), prv.bytes.data (), pub.bytes.data (), signature.bytes.data ());
Expand Down
5 changes: 1 addition & 4 deletions rai/core_test/uint256_union.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include <rai/lib/interface.h>
#include <rai/secure/common.hpp>

#include <ed25519-donna/ed25519.h>

TEST (uint128_union, decode_dec)
{
rai::uint128_union value;
Expand Down Expand Up @@ -115,8 +113,7 @@ TEST (uint256_union, key_encryption)
rai::raw_key key4;
key4.decrypt (encrypted, secret_key, key1.pub.owords[0]);
ASSERT_EQ (key1.prv, key4);
rai::public_key pub;
ed25519_publickey (key4.data.bytes.data (), pub.bytes.data ());
rai::public_key pub (rai::pub_key (key4.data));
ASSERT_EQ (key1.pub, pub);
}

Expand Down
4 changes: 1 addition & 3 deletions rai/node/cli.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <ed25519-donna/ed25519.h>
#include <rai/lib/interface.h>
#include <rai/node/cli.hpp>
#include <rai/node/common.hpp>
Expand Down Expand Up @@ -280,8 +279,7 @@ std::error_code rai::handle_node_options (boost::program_options::variables_map
{
rai::uint256_union prv;
prv.decode_hex (vm["key"].as<std::string> ());
rai::uint256_union pub;
ed25519_publickey (prv.bytes.data (), pub.bytes.data ());
rai::uint256_union pub (rai::pub_key (prv));
std::cout << "Private: " << prv.to_string () << std::endl
<< "Public: " << pub.to_string () << std::endl
<< "Account: " << pub.to_account () << std::endl;
Expand Down
2 changes: 0 additions & 2 deletions rai/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

#include <upnpcommands.h>

#include <ed25519-donna/ed25519.h>

double constexpr rai::node::price_max;
double constexpr rai::node::free_cutoff;
std::chrono::seconds constexpr rai::node::period;
Expand Down
19 changes: 6 additions & 13 deletions rai/node/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

#include <future>

#include <ed25519-donna/ed25519.h>

rai::uint256_union rai::wallet_store::check (MDB_txn * transaction_a)
{
rai::wallet_value value (entry_get_raw (transaction_a, rai::wallet_store::check_special));
Expand Down Expand Up @@ -59,13 +57,12 @@ rai::public_key rai::wallet_store::deterministic_insert (MDB_txn * transaction_a
auto index (deterministic_index_get (transaction_a));
rai::raw_key prv;
deterministic_key (prv, transaction_a, index);
rai::public_key result;
ed25519_publickey (prv.data.bytes.data (), result.bytes.data ());
rai::public_key result (rai::pub_key (prv.data));
while (exists (transaction_a, result))
{
++index;
deterministic_key (prv, transaction_a, index);
ed25519_publickey (prv.data.bytes.data (), result.bytes.data ());
result = rai::pub_key (prv.data);
}
uint64_t marker (1);
marker <<= 32;
Expand Down Expand Up @@ -411,8 +408,7 @@ rai::account rai::wallet_store::representative (MDB_txn * transaction_a)
rai::public_key rai::wallet_store::insert_adhoc (MDB_txn * transaction_a, rai::raw_key const & prv)
{
assert (valid_password (transaction_a));
rai::public_key pub;
ed25519_publickey (prv.data.bytes.data (), pub.bytes.data ());
rai::public_key pub (rai::pub_key (prv.data));
rai::raw_key password_l;
wallet_key (password_l, transaction_a);
rai::uint256_union ciphertext;
Expand Down Expand Up @@ -522,8 +518,7 @@ bool rai::wallet_store::fetch (MDB_txn * transaction_a, rai::public_key const &
}
if (!result)
{
rai::public_key compare;
ed25519_publickey (prv.data.bytes.data (), compare.bytes.data ());
rai::public_key compare (rai::pub_key (prv.data));
if (!(pub == compare))
{
result = true;
Expand Down Expand Up @@ -661,8 +656,7 @@ void rai::wallet_store::upgrade_v1_v2 ()
// Key failed to decrypt despite valid password
rai::wallet_value data (entry_get_raw (transaction, key));
prv.decrypt (data.key, zero_password, salt (transaction).owords[0]);
rai::public_key compare;
ed25519_publickey (prv.data.bytes.data (), compare.bytes.data ());
rai::public_key compare (rai::pub_key (prv.data));
if (compare == key)
{
// If we successfully decrypted it, rewrite the key back with the correct wallet key
Expand All @@ -673,8 +667,7 @@ void rai::wallet_store::upgrade_v1_v2 ()
// Also try the empty password
rai::wallet_value data (entry_get_raw (transaction, key));
prv.decrypt (data.key, empty_password, salt (transaction).owords[0]);
rai::public_key compare;
ed25519_publickey (prv.data.bytes.data (), compare.bytes.data ());
rai::public_key compare (rai::pub_key (prv.data));
if (compare == key)
{
// If we successfully decrypted it, rewrite the key back with the correct wallet key
Expand Down
2 changes: 0 additions & 2 deletions rai/secure/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include <rai/lib/interface.h>
#include <rai/node/working.hpp>

#include <ed25519-donna/ed25519.h>

static std::vector<boost::filesystem::path> all_unique_paths;

boost::filesystem::path rai::working_path ()
Expand Down