mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-23 11:23:26 +01:00
Updated MLSAG and CLSAG tests for consistency
This commit is contained in:
parent
5aa1575e91
commit
f964a92c57
@ -215,8 +215,18 @@ int main(int argc, char** argv)
|
|||||||
TEST_PERFORMANCE1(filter, p, test_cn_fast_hash, 32);
|
TEST_PERFORMANCE1(filter, p, test_cn_fast_hash, 32);
|
||||||
TEST_PERFORMANCE1(filter, p, test_cn_fast_hash, 16384);
|
TEST_PERFORMANCE1(filter, p, test_cn_fast_hash, 16384);
|
||||||
|
|
||||||
TEST_PERFORMANCE2(filter, p, test_sig_mlsag, 11, true); // MLSAG verification
|
TEST_PERFORMANCE2(filter, p, test_sig_mlsag, 8, 1); // MLSAG verification
|
||||||
TEST_PERFORMANCE2(filter, p, test_sig_clsag, 11, 1); // CLSAG verification (with commitment offset)
|
TEST_PERFORMANCE2(filter, p, test_sig_mlsag, 16, 1);
|
||||||
|
TEST_PERFORMANCE2(filter, p, test_sig_mlsag, 32, 1);
|
||||||
|
TEST_PERFORMANCE2(filter, p, test_sig_mlsag, 64, 1);
|
||||||
|
TEST_PERFORMANCE2(filter, p, test_sig_mlsag, 128, 1);
|
||||||
|
TEST_PERFORMANCE2(filter, p, test_sig_mlsag, 256, 1);
|
||||||
|
TEST_PERFORMANCE2(filter, p, test_sig_clsag, 8, 1); // CLSAG verification
|
||||||
|
TEST_PERFORMANCE2(filter, p, test_sig_clsag, 16, 1);
|
||||||
|
TEST_PERFORMANCE2(filter, p, test_sig_clsag, 32, 1);
|
||||||
|
TEST_PERFORMANCE2(filter, p, test_sig_clsag, 64, 1);
|
||||||
|
TEST_PERFORMANCE2(filter, p, test_sig_clsag, 128, 1);
|
||||||
|
TEST_PERFORMANCE2(filter, p, test_sig_clsag, 256, 1);
|
||||||
|
|
||||||
TEST_PERFORMANCE2(filter, p, test_ringct_mlsag, 11, false);
|
TEST_PERFORMANCE2(filter, p, test_ringct_mlsag, 11, false);
|
||||||
TEST_PERFORMANCE2(filter, p, test_ringct_mlsag, 11, true);
|
TEST_PERFORMANCE2(filter, p, test_ringct_mlsag, 11, true);
|
||||||
|
@ -51,8 +51,9 @@ public:
|
|||||||
if (!single_tx_test_base::init())
|
if (!single_tx_test_base::init())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
message = identity();
|
message = skGen();
|
||||||
|
|
||||||
|
// Random signing/commitment keys
|
||||||
pubs.reserve(N);
|
pubs.reserve(N);
|
||||||
for (size_t i = 0; i < N; i++)
|
for (size_t i = 0; i < N; i++)
|
||||||
{
|
{
|
||||||
@ -65,18 +66,22 @@ public:
|
|||||||
pubs.push_back(tmp);
|
pubs.push_back(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Signing key
|
||||||
key p;
|
key p;
|
||||||
skpkGen(p,pubs[l].dest);
|
skpkGen(p,pubs[l].dest);
|
||||||
|
|
||||||
|
// Commitment key
|
||||||
key t,u;
|
key t,u;
|
||||||
t = skGen();
|
t = skGen();
|
||||||
u = skGen();
|
u = skGen();
|
||||||
addKeys2(pubs[l].mask,t,u,H);
|
addKeys2(pubs[l].mask,t,u,H);
|
||||||
|
|
||||||
|
// Offset
|
||||||
key t2;
|
key t2;
|
||||||
t2 = skGen();
|
t2 = skGen();
|
||||||
addKeys2(C_offset,t2,u,H);
|
addKeys2(C_offset,t2,u,H);
|
||||||
|
|
||||||
|
// Final signing keys
|
||||||
ctkey insk;
|
ctkey insk;
|
||||||
insk.dest = p;
|
insk.dest = p;
|
||||||
insk.mask = t;
|
insk.mask = t;
|
||||||
|
@ -32,56 +32,73 @@
|
|||||||
|
|
||||||
#include "ringct/rctSigs.h"
|
#include "ringct/rctSigs.h"
|
||||||
#include "cryptonote_basic/cryptonote_basic.h"
|
#include "cryptonote_basic/cryptonote_basic.h"
|
||||||
|
#include "device/device.hpp"
|
||||||
|
|
||||||
#include "single_tx_test_base.h"
|
#include "single_tx_test_base.h"
|
||||||
|
|
||||||
template<size_t ring_size, bool ver>
|
using namespace rct;
|
||||||
|
|
||||||
|
template<size_t ring_size, size_t index>
|
||||||
class test_sig_mlsag : public single_tx_test_base
|
class test_sig_mlsag : public single_tx_test_base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const size_t cols = ring_size;
|
static const size_t N = ring_size;
|
||||||
static const size_t rows = 2; // 1 spend + 1 commitment
|
|
||||||
static const size_t loop_count = 1000;
|
static const size_t loop_count = 1000;
|
||||||
|
static const size_t l = index;
|
||||||
|
|
||||||
bool init()
|
bool init()
|
||||||
{
|
{
|
||||||
if (!single_tx_test_base::init())
|
if (!single_tx_test_base::init())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
rct::keyV xtmp = rct::skvGen(rows);
|
message = skGen();
|
||||||
rct::keyM xm = rct::keyMInit(rows, cols);// = [[None]*N] #just used to generate test public keys
|
|
||||||
sk = rct::skvGen(rows);
|
// Random signing/commitment keys
|
||||||
P = rct::keyMInit(rows, cols);// = keyM[[None]*N] #stores the public keys;
|
pubs.reserve(N);
|
||||||
ind = 0; // fixed spend index
|
for (size_t i = 0; i < N; i++)
|
||||||
for (size_t j = 0 ; j < rows ; j++)
|
|
||||||
{
|
{
|
||||||
for (size_t i = 0 ; i < cols ; i++)
|
key sk;
|
||||||
{
|
ctkey tmp;
|
||||||
xm[i][j] = rct::skGen();
|
|
||||||
P[i][j] = rct::scalarmultBase(xm[i][j]);
|
skpkGen(sk, tmp.dest);
|
||||||
}
|
skpkGen(sk, tmp.mask);
|
||||||
|
|
||||||
|
pubs.push_back(tmp);
|
||||||
}
|
}
|
||||||
for (size_t j = 0 ; j < rows ; j++)
|
|
||||||
{
|
// Signing key
|
||||||
sk[j] = xm[ind][j];
|
key p;
|
||||||
}
|
skpkGen(p,pubs[l].dest);
|
||||||
IIccss = MLSAG_Gen(rct::identity(), P, sk, NULL, NULL, ind, rows-1, hw::get_device("default"));
|
|
||||||
|
// Commitment key
|
||||||
|
key t,u;
|
||||||
|
t = skGen();
|
||||||
|
u = skGen();
|
||||||
|
addKeys2(pubs[l].mask,t,u,H);
|
||||||
|
|
||||||
|
// Offset
|
||||||
|
key t2;
|
||||||
|
t2 = skGen();
|
||||||
|
addKeys2(C_offset,t2,u,H);
|
||||||
|
|
||||||
|
// Final signing keys
|
||||||
|
ctkey insk;
|
||||||
|
insk.dest = p;
|
||||||
|
insk.mask = t;
|
||||||
|
|
||||||
|
sig = proveRctMGSimple(message,pubs,insk,t2,C_offset,NULL,NULL,l,hw::get_device("default"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool test()
|
bool test()
|
||||||
{
|
{
|
||||||
if (ver)
|
return verRctMGSimple(message,sig,pubs,C_offset);
|
||||||
return MLSAG_Ver(rct::identity(), P, IIccss, rows-1);
|
|
||||||
else
|
|
||||||
MLSAG_Gen(rct::identity(), P, sk, NULL, NULL, ind, rows-1, hw::get_device("default"));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
rct::keyV sk;
|
ctkeyV pubs;
|
||||||
rct::keyM P;
|
key C_offset;
|
||||||
size_t ind;
|
mgSig sig;
|
||||||
rct::mgSig IIccss;
|
key message;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user