Remove the rest of libzerocash.

This commit is contained in:
Sean Bowe
2016-06-28 10:08:50 -06:00
parent 658cdb15f7
commit 2668a1bc13
21 changed files with 94 additions and 303 deletions

View File

@@ -1,7 +1,6 @@
#include <gtest/gtest.h>
#include "uint256.h"
#include "zerocash/utils/util.h"
#include "zcash/util.h"
#include <boost/foreach.hpp>
@@ -14,7 +13,6 @@
#include "libsnark/gadgetlib1/gadgets/merkle_tree/merkle_tree_check_read_gadget.hpp"
using namespace libsnark;
using namespace libzerocash;
#include "zcash/circuit/utils.tcc"

View File

@@ -0,0 +1,44 @@
#include <gtest/gtest.h>
#include "zcash/util.h"
TEST(libzcash_utils, convertBytesVectorToVector)
{
std::vector<unsigned char> bytes = {0x00, 0x01, 0x03, 0x12, 0xFF};
std::vector<bool> expected_bits = {
// 0x00
0, 0, 0, 0, 0, 0, 0, 0,
// 0x01
0, 0, 0, 0, 0, 0, 0, 1,
// 0x03
0, 0, 0, 0, 0, 0, 1, 1,
// 0x12
0, 0, 0, 1, 0, 0, 1, 0,
// 0xFF
1, 1, 1, 1, 1, 1, 1, 1
};
ASSERT_TRUE(convertBytesVectorToVector(bytes) == expected_bits);
}
TEST(libzcash_utils, convertVectorToInt)
{
ASSERT_TRUE(convertVectorToInt({0}) == 0);
ASSERT_TRUE(convertVectorToInt({1}) == 1);
ASSERT_TRUE(convertVectorToInt({0,1}) == 1);
ASSERT_TRUE(convertVectorToInt({1,0}) == 2);
ASSERT_TRUE(convertVectorToInt({1,1}) == 3);
ASSERT_TRUE(convertVectorToInt({1,0,0}) == 4);
ASSERT_TRUE(convertVectorToInt({1,0,1}) == 5);
ASSERT_TRUE(convertVectorToInt({1,1,0}) == 6);
ASSERT_THROW(convertVectorToInt(std::vector<bool>(100)), std::length_error);
{
std::vector<bool> v(63, 1);
ASSERT_TRUE(convertVectorToInt(v) == 0x7fffffffffffffff);
}
{
std::vector<bool> v(64, 1);
ASSERT_TRUE(convertVectorToInt(v) == 0xffffffffffffffff);
}
}

View File

@@ -15,6 +15,9 @@
#include "serialize.h"
#include "streams.h"
#include "zcash/IncrementalMerkleTree.hpp"
#include "zcash/util.h"
#include "libsnark/common/default_types/r1cs_ppzksnark_pp.hpp"
#include "libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.hpp"
#include "libsnark/gadgetlib1/gadgets/hashes/sha256/sha256_gadget.hpp"
@@ -40,13 +43,9 @@ read_json(const std::string& jsondata)
return v.get_array();
}
#include "zcash/IncrementalMerkleTree.hpp"
#include "zerocash/utils/util.h"
//#define PRINT_JSON 1
using namespace std;
using namespace libzerocash;
using namespace libsnark;
@@ -178,10 +177,10 @@ void test_tree(Array root_tests, Array ser_tests, Array witness_ser_tests, Array
std::vector<bool> commitment_bv;
{
std::vector<unsigned char> commitment_v(test_commitment.begin(), test_commitment.end());
convertBytesVectorToVector(commitment_v, commitment_bv);
commitment_bv = convertBytesVectorToVector(commitment_v);
}
size_t path_index = libzerocash::convertVectorToInt(path.index);
size_t path_index = convertVectorToInt(path.index);
commitment.bits.fill_with_bits(pb, bit_vector(commitment_bv));
positions.fill_with_bits_of_ulong(pb, path_index);
@@ -193,7 +192,7 @@ void test_tree(Array root_tests, Array ser_tests, Array witness_ser_tests, Array
{
uint256 witroot = wit.root();
std::vector<unsigned char> root_v(witroot.begin(), witroot.end());
convertBytesVectorToVector(root_v, root_bv);
root_bv = convertBytesVectorToVector(root_v);
}
root.bits.fill_with_bits(pb, bit_vector(root_bv));