Skip to content

Commit

Permalink
Merge pull request #2 from zcoinofficial/test_porting
Browse files Browse the repository at this point in the history
Test porting
  • Loading branch information
martun authored Dec 3, 2018
2 parents 2404b41 + 991dcdf commit 085e7b1
Show file tree
Hide file tree
Showing 29 changed files with 116 additions and 215 deletions.
Empty file modified depends/config.guess
100644 → 100755
Empty file.
Empty file modified depends/config.sub
100644 → 100755
Empty file.
61 changes: 0 additions & 61 deletions src/Makefile.gtest.include

This file was deleted.

7 changes: 6 additions & 1 deletion src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ RAW_TEST_FILES =
GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.raw.h)

BITCOIN_TESTS =\
libzerocoin/sigma/test/coin_tests.cpp \
libzerocoin/sigma/test/protocol_tests.cpp \
libzerocoin/sigma/test/unit_tests.cpp \
libzerocoin/sigma/test/R1_test.cpp \
libzerocoin/sigma/test/serialize_test.cpp \
test/zerocoin_tests.cpp \
test/zerocoin_tests2.cpp \
test/zerocoin_tests3.cpp \
Expand Down Expand Up @@ -118,7 +123,7 @@ test_test_bitcoin_LDADD = $(LIBBITCOIN_SERVER) tor/src/or/libtor.a \
tor/src/common/libcurve25519_donna.a \
tor/src/ext/ed25519/donna/libed25519_donna.a \
tor/src/ext/ed25519/ref10/libed25519_ref10.a \
tor/src/ext/keccak-tiny/libkeccak-tiny.a $(ZLIB_LIBS) -lz
tor/src/ext/keccak-tiny/libkeccak-tiny.a $(LIBSIGMA) $(ZLIB_LIBS) -lz

test_test_bitcoin_SOURCES = $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES)
test_test_bitcoin_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -I$(builddir)/test/ $(TESTDEFS)
Expand Down
8 changes: 0 additions & 8 deletions src/gtest/main.cpp

This file was deleted.

28 changes: 0 additions & 28 deletions src/gtest/sigma_PublicPrivateCoin_test.cpp

This file was deleted.

63 changes: 0 additions & 63 deletions src/gtest/sigma_perform_test.cpp

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <gtest/gtest.h>
#include <boost/test/unit_test.hpp>

#include <libzerocoin/sigma/R1Proof.h>
#include <libzerocoin/sigma/R1ProofGenerator.h>
#include <libzerocoin/sigma/R1ProofVerifier.h>
Expand All @@ -17,8 +18,9 @@ bool test(secp_primitives::GroupElement& g, std::vector<secp_primitives::GroupEl
return verifier.verify(proof);
}

BOOST_AUTO_TEST_SUITE(sigma_R1_test)

TEST(sigma_R1_test, fixed_size_test)
BOOST_AUTO_TEST_CASE(fixed_size_test)
{
int n = 4;
int m = 16;
Expand All @@ -39,10 +41,10 @@ TEST(sigma_R1_test, fixed_size_test)
}
}

EXPECT_TRUE(test(g, h_, b, n, m));
BOOST_CHECK(test(g, h_, b, n, m));
}

TEST(sigma_R1_test, random_size_test)
BOOST_AUTO_TEST_CASE(random_size_test)
{
int n = rand() % 64 + 16;
int m = rand() % 32 + 16;
Expand All @@ -61,11 +63,11 @@ TEST(sigma_R1_test, random_size_test)
}
}

EXPECT_TRUE(test(g, h_, b, n, m));
BOOST_CHECK(test(g, h_, b, n, m));
}


TEST(sigma_R1_test, all_positions)
BOOST_AUTO_TEST_CASE(all_positions)
{
int n = 32;
int m = 16;
Expand All @@ -85,13 +87,13 @@ TEST(sigma_R1_test, all_positions)
b.push_back(secp_primitives::Scalar(uint64_t(0)));
}
}
EXPECT_TRUE(test(g, h_, b, n, m));
BOOST_CHECK(test(g, h_, b, n, m));
h_.clear();
b.clear();
}
}

TEST(sigma_R1_test, one_in_random_position)
BOOST_AUTO_TEST_CASE(one_in_random_position)
{
int n = 32;
int m = 16;
Expand All @@ -112,11 +114,11 @@ TEST(sigma_R1_test, one_in_random_position)
b.push_back(secp_primitives::Scalar(uint64_t(0)));
}
}
EXPECT_TRUE(test(g, h_, b, n, m));
BOOST_CHECK(test(g, h_, b, n, m));
}


TEST(sigma_R1_test, all_0s_in_random_row)
BOOST_AUTO_TEST_CASE(all_0s_in_random_row)
{
int n = 32;
int m = 16;
Expand All @@ -136,10 +138,10 @@ TEST(sigma_R1_test, all_0s_in_random_row)
b.push_back(secp_primitives::Scalar(uint64_t(0)));
}
}
EXPECT_FALSE(test(g, h_, b, n, m));
BOOST_CHECK(!test(g, h_, b, n, m)); // expect false
}

TEST(sigma_R1_test, all_1s_in_random_row)
BOOST_AUTO_TEST_CASE(all_1s_in_random_row)
{
int n = 32;
int m = 16;
Expand All @@ -159,11 +161,11 @@ TEST(sigma_R1_test, all_1s_in_random_row)
b.push_back(secp_primitives::Scalar(uint64_t(0)));
}
}
EXPECT_FALSE(test(g, h_, b, n, m));
BOOST_CHECK(!test(g, h_, b, n, m)); // expect false
}


TEST(sigma_R1_test, two_1s_in_random_row)
BOOST_AUTO_TEST_CASE(two_1s_in_random_row)
{
int n = 32;
int m = 16;
Expand All @@ -186,5 +188,7 @@ TEST(sigma_R1_test, two_1s_in_random_row)
b.push_back(secp_primitives::Scalar(uint64_t(0)));
}
}
EXPECT_FALSE(test(g, h_, b, n, m));
}
BOOST_CHECK(!test(g, h_, b, n, m)); // expect false
}

BOOST_AUTO_TEST_SUITE_END()
35 changes: 35 additions & 0 deletions src/libzerocoin/sigma/test/coin_tests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "../Coin.h"
#include "../Params.h"
#include "../../../streams.h"

#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(sigma_coin_tests)

BOOST_AUTO_TEST_CASE(pubcoin_serialization)
{
secp_primitives::GroupElement coin;
coin.randomize();

sigma::PublicCoinV3 pubcoin(coin, sigma::ZQ_GOLDWASSER);

CDataStream serialized(SER_NETWORK, PROTOCOL_VERSION);
serialized << pubcoin;

sigma::PublicCoinV3 deserialized;
serialized >> deserialized;

BOOST_CHECK(pubcoin == deserialized);
}

BOOST_AUTO_TEST_CASE(pubcoin_validate)
{
auto params = sigma::ParamsV3::get_default();

sigma::PrivateCoinV3 privcoin(params);
auto& pubcoin = privcoin.getPublicCoin();

BOOST_CHECK(pubcoin.validate());
}

BOOST_AUTO_TEST_SUITE_END()
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#include <gtest/gtest.h>
#include <libzerocoin/sigma/SigmaPlusProver.h>
#include <libzerocoin/sigma/SigmaPlusVerifier.h>
#include "../SigmaPlusProver.h"
#include "../SigmaPlusVerifier.h"

TEST(test_1_out_of_N, EC_group)
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(sigma_protocol_tests)

BOOST_AUTO_TEST_CASE(one_out_of_n)
{
int N = 16;
int n = 4;
int index = 0;

int m = (int)(log(N) / log(n));;
int m = (int)(log(N) / log(n));

secp_primitives::GroupElement g;
g.randomize();
Expand Down Expand Up @@ -41,6 +44,8 @@ TEST(test_1_out_of_N, EC_group)
prover.proof(commits, index, r, proof);

sigma::SigmaPlusVerifier<secp_primitives::Scalar,secp_primitives::GroupElement> verifier(g, h_gens, n, m);
EXPECT_TRUE(verifier.verify(commits, proof));

}
BOOST_CHECK(verifier.verify(commits, proof));
}

BOOST_AUTO_TEST_SUITE_END()
Loading

0 comments on commit 085e7b1

Please sign in to comment.