Merge pull request #5707

3a0451a MLSAG speedup and additional checks (SarangNoether)
This commit is contained in:
luigi1111 2019-08-28 02:22:00 -05:00
commit 85014813cf
No known key found for this signature in database
GPG key ID: F4ACA0183641E010
7 changed files with 75 additions and 101 deletions

View file

@ -57,7 +57,6 @@
#include "rct_mlsag.h"
#include "equality.h"
#include "range_proof.h"
#include "rct_mlsag.h"
#include "bulletproof.h"
#include "crypto_ops.h"
#include "multiexp.h"
@ -214,14 +213,8 @@ int main(int argc, char** argv)
TEST_PERFORMANCE1(filter, p, test_cn_fast_hash, 32);
TEST_PERFORMANCE1(filter, p, test_cn_fast_hash, 16384);
TEST_PERFORMANCE3(filter, p, test_ringct_mlsag, 1, 3, false);
TEST_PERFORMANCE3(filter, p, test_ringct_mlsag, 1, 5, false);
TEST_PERFORMANCE3(filter, p, test_ringct_mlsag, 1, 10, false);
TEST_PERFORMANCE3(filter, p, test_ringct_mlsag, 1, 100, false);
TEST_PERFORMANCE3(filter, p, test_ringct_mlsag, 1, 3, true);
TEST_PERFORMANCE3(filter, p, test_ringct_mlsag, 1, 5, true);
TEST_PERFORMANCE3(filter, p, test_ringct_mlsag, 1, 10, true);
TEST_PERFORMANCE3(filter, p, test_ringct_mlsag, 1, 100, true);
TEST_PERFORMANCE2(filter, p, test_ringct_mlsag, 11, false);
TEST_PERFORMANCE2(filter, p, test_ringct_mlsag, 11, true);
TEST_PERFORMANCE2(filter, p, test_equality, memcmp32, true);
TEST_PERFORMANCE2(filter, p, test_equality, memcmp32, false);
@ -251,15 +244,6 @@ int main(int argc, char** argv)
TEST_PERFORMANCE6(filter, p, test_aggregated_bulletproof, false, 2, 1, 1, 0, 64);
TEST_PERFORMANCE6(filter, p, test_aggregated_bulletproof, true, 2, 1, 1, 0, 64); // 64 proof, each with 2 amounts
TEST_PERFORMANCE3(filter, p, test_ringct_mlsag, 1, 3, false);
TEST_PERFORMANCE3(filter, p, test_ringct_mlsag, 1, 5, false);
TEST_PERFORMANCE3(filter, p, test_ringct_mlsag, 1, 10, false);
TEST_PERFORMANCE3(filter, p, test_ringct_mlsag, 1, 100, false);
TEST_PERFORMANCE3(filter, p, test_ringct_mlsag, 1, 3, true);
TEST_PERFORMANCE3(filter, p, test_ringct_mlsag, 1, 5, true);
TEST_PERFORMANCE3(filter, p, test_ringct_mlsag, 1, 10, true);
TEST_PERFORMANCE3(filter, p, test_ringct_mlsag, 1, 100, true);
TEST_PERFORMANCE1(filter, p, test_crypto_ops, op_sc_add);
TEST_PERFORMANCE1(filter, p, test_crypto_ops, op_sc_sub);
TEST_PERFORMANCE1(filter, p, test_crypto_ops, op_sc_mul);

View file

@ -35,13 +35,13 @@
#include "single_tx_test_base.h"
template<size_t inputs, size_t ring_size, bool ver>
template<size_t ring_size, bool ver>
class test_ringct_mlsag : public single_tx_test_base
{
public:
static const size_t cols = ring_size;
static const size_t rows = inputs;
static const size_t loop_count = 100;
static const size_t rows = 2; // single spend and commitment data
static const size_t loop_count = 1000;
bool init()
{
@ -65,7 +65,7 @@ public:
{
sk[j] = xm[ind][j];
}
IIccss = MLSAG_Gen(rct::identity(), P, sk, NULL, NULL, ind, rows, hw::get_device("default"));
IIccss = MLSAG_Gen(rct::identity(), P, sk, NULL, NULL, ind, rows-1, hw::get_device("default"));
return true;
}
@ -73,9 +73,9 @@ public:
bool test()
{
if (ver)
MLSAG_Ver(rct::identity(), P, IIccss, rows);
MLSAG_Ver(rct::identity(), P, IIccss, rows-1);
else
MLSAG_Gen(rct::identity(), P, sk, NULL, NULL, ind, rows, hw::get_device("default"));
MLSAG_Gen(rct::identity(), P, sk, NULL, NULL, ind, rows-1, hw::get_device("default"));
return true;
}

View file

@ -788,7 +788,20 @@ TEST(ringct, HPow2)
{
key G = scalarmultBase(d2h(1));
key H = hashToPointSimple(G);
// Note that H is computed differently than standard hashing
// This method is not guaranteed to return a curvepoint for all inputs
// Don't use it elsewhere
key H = cn_fast_hash(G);
ge_p3 H_p3;
int decode = ge_frombytes_vartime(&H_p3, H.bytes);
ASSERT_EQ(decode, 0); // this is known to pass for the particular value G
ge_p2 H_p2;
ge_p3_to_p2(&H_p2, &H_p3);
ge_p1p1 H8_p1p1;
ge_mul8(&H8_p1p1, &H_p2);
ge_p1p1_to_p3(&H_p3, &H8_p1p1);
ge_p3_tobytes(H.bytes, &H_p3);
for (int j = 0 ; j < ATOMS ; j++) {
ASSERT_TRUE(equalKeys(H, H2[j]));
addKeys(H, H, H);