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

Batch state blocks signatures verification #956

Merged
merged 60 commits into from
Oct 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
f2a09de
Batch signatures validation
SergiySW Jul 6, 2018
43a1eb3
Batch state blocks verification
SergiySW Jul 6, 2018
3cf25a0
Add valid_signature option to ledger_processor
SergiySW Jul 7, 2018
1e3ee88
Add valid_signature to process_receive_one
SergiySW Jul 7, 2018
8816f91
Simplify validate_blocks
SergiySW Jul 7, 2018
798a9cc
Test for batch block check
SergiySW Jul 7, 2018
d551bc5
Batch block_processor for state blocks
SergiySW Jul 7, 2018
ee9e144
Extra vector to prevent possible junk validation DDoS on node
SergiySW Jul 7, 2018
fbf8194
Typo
SergiySW Jul 7, 2018
9448c3d
Clang formatting
SergiySW Jul 8, 2018
d50d535
Merge remote-tracking branch 'upstream/master' into batch_signatures_2
SergiySW Jul 11, 2018
db7b505
Test debug_verify_profile_batch
SergiySW Jul 11, 2018
2da990c
Merge remote-tracking branch 'upstream/master' into batch_signatures_2
SergiySW Jul 15, 2018
b37da3c
Exception for epoch blocks
SergiySW Jul 15, 2018
9764412
Fix mutex.try_lock () issue
SergiySW Jul 15, 2018
952e6f5
Merge remote-tracking branch 'upstream/master' into batch_signatures_2
SergiySW Aug 1, 2018
187a61f
Simplify batch signature verification processor
SergiySW Aug 1, 2018
7278510
Validate epoch blocks
SergiySW Aug 1, 2018
fa56cae
Fix
SergiySW Aug 1, 2018
002665a
MSVC workaround
SergiySW Aug 2, 2018
cb345e1
block_processor_signatures test
SergiySW Aug 2, 2018
9116d53
Fix block_processor
SergiySW Aug 2, 2018
ce95b50
Formatting
SergiySW Aug 2, 2018
227b544
Fix MSVC
SergiySW Aug 2, 2018
2a83923
LMDB fix
SergiySW Aug 2, 2018
4dbf4ac
Formatting
SergiySW Aug 2, 2018
998371d
Completely disable batch signatures for MSVC
SergiySW Aug 2, 2018
f2058fb
Fix test
SergiySW Aug 2, 2018
29a3c65
Merge remote-tracking branch 'upstream/master' into batch_signatures_2
SergiySW Aug 6, 2018
8bc7d30
Batch verification for epoch blocks
SergiySW Aug 6, 2018
5430fb7
Merge remote-tracking branch 'upstream/master' into batch_signatures_2
SergiySW Aug 13, 2018
38174cc
More details to block_processor_signatures test
SergiySW Aug 13, 2018
60482af
Batch state blocks signatures verification
clemahieu Aug 13, 2018
0fd2285
Use C++ standard containers for processing bulk signature verification.
clemahieu Aug 13, 2018
78d094d
Formatting.
clemahieu Aug 13, 2018
a9d403a
Rebase --debug_verify_profile_batch
SergiySW Aug 14, 2018
387593a
Add validate_message_batch to rai_lib
SergiySW Aug 14, 2018
5aa2428
Formatting
SergiySW Aug 14, 2018
56174ab
Merge remote-tracking branch 'upstream/master' into batch_signatures_2
SergiySW Aug 17, 2018
0d961cc
Don't check signatures for unchecked state blocks
SergiySW Aug 19, 2018
b18596d
Remove _MSC_VER check
SergiySW Aug 19, 2018
0acc71b
Merge remote-tracking branch 'upstream/master' into batch_signatures_2
SergiySW Sep 6, 2018
6ef07bd
Updates
SergiySW Sep 6, 2018
6663bdc
Merge remote-tracking branch 'upstream/master' into batch_signatures_2
SergiySW Sep 6, 2018
82b52d0
Merge remote-tracking branch 'upstream/master' into batch_signatures_2
SergiySW Sep 8, 2018
b5fad43
Merge remote-tracking branch 'upstream/master' into batch_signatures_2
SergiySW Sep 9, 2018
b1b6ade
Merge remote-tracking branch 'upstream/master' into batch_signatures_2
SergiySW Sep 20, 2018
13a73c9
Merge remote-tracking branch 'upstream/master' into batch_signatures_2
SergiySW Oct 3, 2018
6118b53
Remove epoch blocks from batch verification
SergiySW Oct 3, 2018
62a7fde
Typo
SergiySW Oct 3, 2018
1fd2e35
Merge remote-tracking branch 'upstream/master' into batch_signatures_2
SergiySW Oct 4, 2018
4785938
Merge remote-tracking branch 'upstream/master' into batch_signatures_2
SergiySW Oct 4, 2018
7a7b194
Merge remote-tracking branch 'upstream/master' into batch_signatures_2
SergiySW Oct 6, 2018
2e83193
Merge remote-tracking branch 'upstream/master' into batch_signatures_2
SergiySW Oct 11, 2018
4bad6d3
Merge remote-tracking branch 'upstream/master' into batch_signatures_2
SergiySW Oct 12, 2018
0550cc5
Remove unchecked from block_processor::add
SergiySW Oct 12, 2018
c025a5e
Extent block_processor_signatures test with forced blocks & unchecked…
SergiySW Oct 12, 2018
797d560
Move force check
SergiySW Oct 12, 2018
7468154
Extra info
SergiySW Oct 12, 2018
d86047c
More clear validated_state_block value
SergiySW Oct 12, 2018
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
78 changes: 78 additions & 0 deletions rai/core_test/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1815,3 +1815,81 @@ TEST (node, fork_invalid_block_signature_vote_by_hash)
}
ASSERT_EQ (system.nodes[0]->block (send2.hash ())->block_signature (), send2.block_signature ());
}

TEST (node, block_processor_signatures)
{
rai::system system0 (24000, 1);
auto & node1 (*system0.nodes[0]);
system0.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
rai::block_hash latest (system0.nodes[0]->latest (rai::test_genesis_key.pub));
rai::keypair key1;
auto send1 (std::make_shared<rai::state_block> (rai::test_genesis_key.pub, latest, rai::test_genesis_key.pub, rai::genesis_amount - rai::Gxrb_ratio, key1.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
node1.work_generate_blocking (*send1);
rai::keypair key2;
auto send2 (std::make_shared<rai::state_block> (rai::test_genesis_key.pub, send1->hash (), rai::test_genesis_key.pub, rai::genesis_amount - 2 * rai::Gxrb_ratio, key2.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
node1.work_generate_blocking (*send2);
rai::keypair key3;
auto send3 (std::make_shared<rai::state_block> (rai::test_genesis_key.pub, send2->hash (), rai::test_genesis_key.pub, rai::genesis_amount - 3 * rai::Gxrb_ratio, key3.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
node1.work_generate_blocking (*send3);
// Invalid signature bit
auto send4 (std::make_shared<rai::state_block> (rai::test_genesis_key.pub, send3->hash (), rai::test_genesis_key.pub, rai::genesis_amount - 4 * rai::Gxrb_ratio, key3.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
node1.work_generate_blocking (*send4);
send4->signature.bytes[32] ^= 0x1;
// Invalid signature bit (force)
auto send5 (std::make_shared<rai::state_block> (rai::test_genesis_key.pub, send3->hash (), rai::test_genesis_key.pub, rai::genesis_amount - 5 * rai::Gxrb_ratio, key3.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
node1.work_generate_blocking (*send5);
send5->signature.bytes[31] ^= 0x1;
// Invalid signature to unchecked
{
auto transaction (node1.store.tx_begin_write ());
node1.store.unchecked_put (transaction, send5->previous (), send5);
}
auto receive1 (std::make_shared<rai::state_block> (key1.pub, 0, rai::test_genesis_key.pub, rai::Gxrb_ratio, send1->hash (), key1.prv, key1.pub, 0));
node1.work_generate_blocking (*receive1);
auto receive2 (std::make_shared<rai::state_block> (key2.pub, 0, rai::test_genesis_key.pub, rai::Gxrb_ratio, send2->hash (), key2.prv, key2.pub, 0));
node1.work_generate_blocking (*receive2);
// Invalid private key
auto receive3 (std::make_shared<rai::state_block> (key3.pub, 0, rai::test_genesis_key.pub, rai::Gxrb_ratio, send3->hash (), key2.prv, key3.pub, 0));
node1.work_generate_blocking (*receive3);
node1.process_active (send1);
node1.process_active (send2);
node1.process_active (send3);
node1.process_active (send4);
node1.process_active (receive1);
node1.process_active (receive2);
node1.process_active (receive3);
node1.block_processor.flush ();
node1.block_processor.force (send5);
node1.block_processor.flush ();
auto transaction (node1.store.tx_begin_read ());
ASSERT_TRUE (node1.store.block_exists (transaction, send1->hash ()));
ASSERT_TRUE (node1.store.block_exists (transaction, send2->hash ()));
ASSERT_TRUE (node1.store.block_exists (transaction, send3->hash ()));
ASSERT_FALSE (node1.store.block_exists (transaction, send4->hash ()));
ASSERT_FALSE (node1.store.block_exists (transaction, send5->hash ()));
ASSERT_TRUE (node1.store.block_exists (transaction, receive1->hash ()));
ASSERT_TRUE (node1.store.block_exists (transaction, receive2->hash ()));
ASSERT_FALSE (node1.store.block_exists (transaction, receive3->hash ()));
}

/*
* State blocks go through a different signature path, ensure invalidly signed state blocks are rejected
*/
TEST (node, block_processor_reject_state)
{
rai::system system (24000, 1);
auto & node (*system.nodes[0]);
rai::genesis genesis;
auto send1 (std::make_shared<rai::state_block> (rai::test_genesis_key.pub, genesis.hash (), rai::test_genesis_key.pub, rai::genesis_amount - rai::Gxrb_ratio, rai::test_genesis_key.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
node.work_generate_blocking (*send1);
send1->signature.bytes[0] ^= 1;
ASSERT_FALSE (node.ledger.block_exists (send1->hash ()));
node.process_active (send1);
node.block_processor.flush ();
ASSERT_FALSE (node.ledger.block_exists (send1->hash ()));
auto send2 (std::make_shared<rai::state_block> (rai::test_genesis_key.pub, genesis.hash (), rai::test_genesis_key.pub, rai::genesis_amount - 2 * rai::Gxrb_ratio, rai::test_genesis_key.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0));
node.work_generate_blocking (*send2);
node.process_active (send2);
node.block_processor.flush ();
ASSERT_TRUE (node.ledger.block_exists (send2->hash ()));
}
25 changes: 25 additions & 0 deletions rai/lib/blocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ rai::block_hash rai::send_block::root () const
return hashables.previous;
}

rai::block_hash rai::send_block::link () const
{
return 0;
}

rai::account rai::send_block::representative () const
{
return 0;
Expand Down Expand Up @@ -575,6 +580,11 @@ rai::block_hash rai::open_block::root () const
return hashables.account;
}

rai::block_hash rai::open_block::link () const
{
return 0;
}

rai::account rai::open_block::representative () const
{
return hashables.representative;
Expand Down Expand Up @@ -811,6 +821,11 @@ rai::block_hash rai::change_block::root () const
return hashables.previous;
}

rai::block_hash rai::change_block::link () const
{
return 0;
}

rai::account rai::change_block::representative () const
{
return hashables.representative;
Expand Down Expand Up @@ -1110,6 +1125,11 @@ rai::block_hash rai::state_block::root () const
return !hashables.previous.is_zero () ? hashables.previous : hashables.account;
}

rai::block_hash rai::state_block::link () const
{
return hashables.link;
}

rai::account rai::state_block::representative () const
{
return hashables.representative;
Expand Down Expand Up @@ -1440,6 +1460,11 @@ rai::block_hash rai::receive_block::root () const
return hashables.previous;
}

rai::block_hash rai::receive_block::link () const
{
return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we assert(false) here (or just not implement this virtual function for non-state blocks) ? The receive block probably has the equivalent of a link

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's similar to source (), previous () & some other functions returning 0 for some block types. We can just not implement such functions when they return 0 I guess to save some lines in code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a case of using release_assert since we shouldn’t be looking for the link of non-state blocks?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either release_assert() or not declaring the virtual methods for these block types which should generate a fatal exception

}

rai::account rai::receive_block::representative () const
{
return 0;
Expand Down
7 changes: 7 additions & 0 deletions rai/lib/blocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class block
virtual rai::block_hash source () const = 0;
// Previous block or account number for open blocks
virtual rai::block_hash root () const = 0;
// Link field for state blocks, zero otherwise.
virtual rai::block_hash link () const = 0;
virtual rai::account representative () const = 0;
virtual void serialize (rai::stream &) const = 0;
virtual void serialize_json (std::string &) const = 0;
Expand Down Expand Up @@ -90,6 +92,7 @@ class send_block : public rai::block
rai::block_hash previous () const override;
rai::block_hash source () const override;
rai::block_hash root () const override;
rai::block_hash link () const override;
rai::account representative () const override;
void serialize (rai::stream &) const override;
void serialize_json (std::string &) const override;
Expand Down Expand Up @@ -131,6 +134,7 @@ class receive_block : public rai::block
rai::block_hash previous () const override;
rai::block_hash source () const override;
rai::block_hash root () const override;
rai::block_hash link () const override;
rai::account representative () const override;
void serialize (rai::stream &) const override;
void serialize_json (std::string &) const override;
Expand Down Expand Up @@ -174,6 +178,7 @@ class open_block : public rai::block
rai::block_hash previous () const override;
rai::block_hash source () const override;
rai::block_hash root () const override;
rai::block_hash link () const override;
rai::account representative () const override;
void serialize (rai::stream &) const override;
void serialize_json (std::string &) const override;
Expand Down Expand Up @@ -215,6 +220,7 @@ class change_block : public rai::block
rai::block_hash previous () const override;
rai::block_hash source () const override;
rai::block_hash root () const override;
rai::block_hash link () const override;
rai::account representative () const override;
void serialize (rai::stream &) const override;
void serialize_json (std::string &) const override;
Expand Down Expand Up @@ -268,6 +274,7 @@ class state_block : public rai::block
rai::block_hash previous () const override;
rai::block_hash source () const override;
rai::block_hash root () const override;
rai::block_hash link () const override;
rai::account representative () const override;
void serialize (rai::stream &) const override;
void serialize_json (std::string &) const override;
Expand Down
6 changes: 6 additions & 0 deletions rai/lib/numbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,12 @@ bool rai::validate_message (rai::public_key const & public_key, rai::uint256_uni
return result;
}

bool rai::validate_message_batch (const unsigned char ** m, size_t * mlen, const unsigned char ** pk, const unsigned char ** RS, size_t num, int * valid)
{
bool result (0 == ed25519_sign_open_batch (m, mlen, pk, RS, num, valid));
return result;
}

rai::uint128_union::uint128_union (std::string const & string_a)
{
auto error (decode_hex (string_a));
Expand Down
1 change: 1 addition & 0 deletions rai/lib/numbers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ using signature = uint512_union;

rai::uint512_union sign_message (rai::raw_key const &, rai::public_key const &, rai::uint256_union const &);
bool validate_message (rai::public_key const &, rai::uint256_union const &, rai::uint512_union const &);
bool validate_message_batch (const unsigned char **, size_t *, const unsigned char **, const unsigned char **, size_t, int *);
void deterministic_key (rai::uint256_union const &, uint32_t, rai::uint256_union &);
rai::public_key pub_key (rai::private_key const &);
}
Expand Down
72 changes: 64 additions & 8 deletions rai/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ void rai::block_processor::stop ()
void rai::block_processor::flush ()
{
std::unique_lock<std::mutex> lock (mutex);
while (!stopped && (!blocks.empty () || active))
while (!stopped && (have_blocks () || active))
{
condition.wait (lock);
}
Expand All @@ -955,8 +955,14 @@ void rai::block_processor::add (std::shared_ptr<rai::block> block_a, std::chrono
std::lock_guard<std::mutex> lock (mutex);
if (blocks_hashes.find (block_a->hash ()) == blocks_hashes.end ())
{
blocks.push_back (std::make_pair (block_a, origination));
blocks_hashes.insert (block_a->hash ());
if (block_a->type () == rai::block_type::state && block_a->link () != node.ledger.epoch_link)
{
state_blocks.push_back (std::make_pair (block_a, origination));
}
else
{
blocks.push_back (std::make_pair (block_a, origination));
}
condition.notify_all ();
}
}
Expand Down Expand Up @@ -1010,16 +1016,63 @@ bool rai::block_processor::should_log ()
bool rai::block_processor::have_blocks ()
{
assert (!mutex.try_lock ());
return !blocks.empty () || !forced.empty ();
return !blocks.empty () || !forced.empty () || !state_blocks.empty ();
}

void rai::block_processor::verify_state_blocks (std::unique_lock<std::mutex> & lock_a)
{
lock_a.lock ();
std::deque<std::pair<std::shared_ptr<rai::block>, std::chrono::steady_clock::time_point>> items;
items.swap (state_blocks);
lock_a.unlock ();
auto size (items.size ());
cryptocode marked this conversation as resolved.
Show resolved Hide resolved
std::vector<rai::uint256_union> hashes;
hashes.reserve (size);
std::vector<unsigned char const *> messages;
messages.reserve (size);
std::vector<size_t> lengths;
lengths.reserve (size);
std::vector<unsigned char const *> pub_keys;
pub_keys.reserve (size);
std::vector<unsigned char const *> signatures;
signatures.reserve (size);
std::vector<int> verifications;
verifications.resize (size);
for (auto i (0); i < size; ++i)
{
auto & block (static_cast<rai::state_block &> (*items[i].first));
hashes.push_back (block.hash ());
messages.push_back (hashes.back ().bytes.data ());
lengths.push_back (sizeof (decltype (hashes)::value_type));
pub_keys.push_back (block.hashables.account.bytes.data ());
signatures.push_back (block.signature.bytes.data ());
}
/* Verifications is vector if signatures check results
validate_message_batch returing "true" if there are at least 1 invalid signature */
auto code (rai::validate_message_batch (messages.data (), lengths.data (), pub_keys.data (), signatures.data (), size, verifications.data ()));
(void)code;
rkeene marked this conversation as resolved.
Show resolved Hide resolved
lock_a.lock ();
for (auto i (0); i < size; ++i)
{
assert (verifications[i] == 1 || verifications[i] == 0);
if (verifications[i] == 1)
{
blocks.push_back (items.front ());
}
items.pop_front ();
}
lock_a.unlock ();
}

void rai::block_processor::process_receive_many (std::unique_lock<std::mutex> & lock_a)
{
verify_state_blocks (lock_a);
{
auto transaction (node.store.tx_begin_write ());
auto start_time (std::chrono::steady_clock::now ());
lock_a.lock ();
while (have_blocks () && std::chrono::steady_clock::now () - start_time < node.config.block_processor_batch_max_time)
// Processing blocks
while ((!blocks.empty () || !forced.empty ()) && std::chrono::steady_clock::now () - start_time < node.config.block_processor_batch_max_time)
{
if (blocks.size () > 64 && should_log ())
{
Expand Down Expand Up @@ -1051,7 +1104,10 @@ void rai::block_processor::process_receive_many (std::unique_lock<std::mutex> &
node.ledger.rollback (transaction, successor->hash ());
}
}
auto process_result (process_receive_one (transaction, block.first, block.second));
/* Forced state blocks are not validated in verify_state_blocks () function
Because of that we should set set validated_state_block as "false" for forced state blocks (!force) */
bool validated_state_block (!force && block.first->type () == rai::block_type::state);
auto process_result (process_receive_one (transaction, block.first, block.second, validated_state_block));
(void)process_result;
lock_a.lock ();
}
Expand All @@ -1073,11 +1129,11 @@ void rai::block_processor::process_receive_many (std::unique_lock<std::mutex> &
}
}

rai::process_return rai::block_processor::process_receive_one (rai::transaction const & transaction_a, std::shared_ptr<rai::block> block_a, std::chrono::steady_clock::time_point origination)
rai::process_return rai::block_processor::process_receive_one (rai::transaction const & transaction_a, std::shared_ptr<rai::block> block_a, std::chrono::steady_clock::time_point origination, bool validated_state_block)
{
rai::process_return result;
auto hash (block_a->hash ());
result = node.ledger.process (transaction_a, *block_a);
result = node.ledger.process (transaction_a, *block_a, validated_state_block);
switch (result.code)
{
case rai::process_result::progress:
Expand Down
4 changes: 3 additions & 1 deletion rai/node/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,15 +503,17 @@ class block_processor
bool should_log ();
bool have_blocks ();
void process_blocks ();
rai::process_return process_receive_one (rai::transaction const &, std::shared_ptr<rai::block>, std::chrono::steady_clock::time_point = std::chrono::steady_clock::now ());
rai::process_return process_receive_one (rai::transaction const &, std::shared_ptr<rai::block>, std::chrono::steady_clock::time_point = std::chrono::steady_clock::now (), bool = false);

private:
void queue_unchecked (rai::transaction const &, rai::block_hash const &);
void process_receive_many (std::unique_lock<std::mutex> &);
void verify_state_blocks (std::unique_lock<std::mutex> &);
bool stopped;
bool active;
std::chrono::steady_clock::time_point next_log;
std::deque<std::pair<std::shared_ptr<rai::block>, std::chrono::steady_clock::time_point>> blocks;
std::deque<std::pair<std::shared_ptr<rai::block>, std::chrono::steady_clock::time_point>> state_blocks;
std::unordered_set<rai::block_hash> blocks_hashes;
std::deque<std::shared_ptr<rai::block>> forced;
std::deque<std::shared_ptr<rai::block>> processed_active;
Expand Down
18 changes: 18 additions & 0 deletions rai/rai_node/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ int main (int argc, char * const * argv)
("debug_profile_verify", "Profile work verification")
("debug_profile_kdf", "Profile kdf function")
("debug_verify_profile", "Profile signature verification")
("debug_verify_profile_batch", "Profile batch signature verification")
("debug_profile_sign", "Profile signature generation")
("debug_profile_process", "Profile active blocks processing (only for rai_test_network)")
("debug_validate_blocks", "Check all blocks for correct hash, signature, work value")
Expand Down Expand Up @@ -311,6 +312,23 @@ int main (int argc, char * const * argv)
auto end (std::chrono::high_resolution_clock::now ());
std::cerr << "Signature verifications " << std::chrono::duration_cast<std::chrono::microseconds> (end - begin).count () << std::endl;
}
else if (vm.count ("debug_verify_profile_batch"))
{
rai::keypair key;
size_t batch_count (1000);
rai::uint256_union message;
rai::uint512_union signature (rai::sign_message (key.prv, key.pub, message));
std::vector<unsigned char const *> messages (batch_count, message.bytes.data ());
std::vector<size_t> lengths (batch_count, sizeof (message));
std::vector<unsigned char const *> pub_keys (batch_count, key.pub.bytes.data ());
std::vector<unsigned char const *> signatures (batch_count, signature.bytes.data ());
std::vector<int> verifications;
verifications.resize (batch_count);
auto begin (std::chrono::high_resolution_clock::now ());
rai::validate_message_batch (messages.data (), lengths.data (), pub_keys.data (), signatures.data (), batch_count, verifications.data ());
auto end (std::chrono::high_resolution_clock::now ());
std::cerr << "Batch signature verifications " << std::chrono::duration_cast<std::chrono::microseconds> (end - begin).count () << std::endl;
}
else if (vm.count ("debug_profile_sign"))
{
std::cerr << "Starting blocks signing profiling\n";
Expand Down
Loading