Remove more remnants of JoinSplits

This commit is contained in:
Duke Leto
2020-12-08 19:49:42 -05:00
parent 689597a37b
commit a42c063b52
14 changed files with 62 additions and 167 deletions

View File

@@ -410,8 +410,8 @@ class ZCProof(object):
repr(self.g_K), repr(self.g_H)) repr(self.g_K), repr(self.g_H))
ZC_NUM_JS_INPUTS = 2 HUSH_NUM_JS_INPUTS = 2
ZC_NUM_JS_OUTPUTS = 2 HUSH_NUM_JS_OUTPUTS = 2
ZC_NOTEPLAINTEXT_LEADING = 1 ZC_NOTEPLAINTEXT_LEADING = 1
ZC_V_SIZE = 8 ZC_V_SIZE = 8
@@ -439,13 +439,13 @@ class JSDescription(object):
self.vpub_old = 0 self.vpub_old = 0
self.vpub_new = 0 self.vpub_new = 0
self.anchor = 0 self.anchor = 0
self.nullifiers = [0] * ZC_NUM_JS_INPUTS self.nullifiers = [0] * HUSH_NUM_JS_INPUTS
self.commitments = [0] * ZC_NUM_JS_OUTPUTS self.commitments = [0] * HUSH_NUM_JS_OUTPUTS
self.onetimePubKey = 0 self.onetimePubKey = 0
self.randomSeed = 0 self.randomSeed = 0
self.macs = [0] * ZC_NUM_JS_INPUTS self.macs = [0] * HUSH_NUM_JS_INPUTS
self.proof = None self.proof = None
self.ciphertexts = [None] * ZC_NUM_JS_OUTPUTS self.ciphertexts = [None] * HUSH_NUM_JS_OUTPUTS
def deserialize(self, f): def deserialize(self, f):
self.vpub_old = struct.unpack("<q", f.read(8))[0] self.vpub_old = struct.unpack("<q", f.read(8))[0]
@@ -453,25 +453,25 @@ class JSDescription(object):
self.anchor = deser_uint256(f) self.anchor = deser_uint256(f)
self.nullifiers = [] self.nullifiers = []
for i in range(ZC_NUM_JS_INPUTS): for i in range(HUSH_NUM_JS_INPUTS):
self.nullifiers.append(deser_uint256(f)) self.nullifiers.append(deser_uint256(f))
self.commitments = [] self.commitments = []
for i in range(ZC_NUM_JS_OUTPUTS): for i in range(HUSH_NUM_JS_OUTPUTS):
self.commitments.append(deser_uint256(f)) self.commitments.append(deser_uint256(f))
self.onetimePubKey = deser_uint256(f) self.onetimePubKey = deser_uint256(f)
self.randomSeed = deser_uint256(f) self.randomSeed = deser_uint256(f)
self.macs = [] self.macs = []
for i in range(ZC_NUM_JS_INPUTS): for i in range(HUSH_NUM_JS_INPUTS):
self.macs.append(deser_uint256(f)) self.macs.append(deser_uint256(f))
self.proof = ZCProof() self.proof = ZCProof()
self.proof.deserialize(f) self.proof.deserialize(f)
self.ciphertexts = [] self.ciphertexts = []
for i in range(ZC_NUM_JS_OUTPUTS): for i in range(HUSH_NUM_JS_OUTPUTS):
self.ciphertexts.append(f.read(ZC_NOTECIPHERTEXT_SIZE)) self.ciphertexts.append(f.read(ZC_NOTECIPHERTEXT_SIZE))
def serialize(self): def serialize(self):
@@ -479,16 +479,16 @@ class JSDescription(object):
r += struct.pack("<q", self.vpub_old) r += struct.pack("<q", self.vpub_old)
r += struct.pack("<q", self.vpub_new) r += struct.pack("<q", self.vpub_new)
r += ser_uint256(self.anchor) r += ser_uint256(self.anchor)
for i in range(ZC_NUM_JS_INPUTS): for i in range(HUSH_NUM_JS_INPUTS):
r += ser_uint256(self.nullifiers[i]) r += ser_uint256(self.nullifiers[i])
for i in range(ZC_NUM_JS_OUTPUTS): for i in range(HUSH_NUM_JS_OUTPUTS):
r += ser_uint256(self.commitments[i]) r += ser_uint256(self.commitments[i])
r += ser_uint256(self.onetimePubKey) r += ser_uint256(self.onetimePubKey)
r += ser_uint256(self.randomSeed) r += ser_uint256(self.randomSeed)
for i in range(ZC_NUM_JS_INPUTS): for i in range(HUSH_NUM_JS_INPUTS):
r += ser_uint256(self.macs[i]) r += ser_uint256(self.macs[i])
r += self.proof.serialize() r += self.proof.serialize()
for i in range(ZC_NUM_JS_OUTPUTS): for i in range(HUSH_NUM_JS_OUTPUTS):
r += ser_uint256(self.ciphertexts[i]) r += ser_uint256(self.ciphertexts[i])
return r return r

View File

@@ -7,7 +7,6 @@
#include "pubkey.h" #include "pubkey.h"
#include "zcash/JoinSplit.hpp" #include "zcash/JoinSplit.hpp"
#include "util.h" #include "util.h"
#include "librustzcash.h" #include "librustzcash.h"
struct ECCryptoClosure struct ECCryptoClosure
@@ -17,21 +16,17 @@ struct ECCryptoClosure
ECCryptoClosure instance_of_eccryptoclosure; ECCryptoClosure instance_of_eccryptoclosure;
ZCJoinSplit* params;
int main(int argc, char **argv) { int main(int argc, char **argv) {
assert(init_and_check_sodium() != -1); assert(init_and_check_sodium() != -1);
ECC_Start(); ECC_Start();
params = ZCJoinSplit::Prepared();
boost::filesystem::path sapling_spend = ZC_GetParamsDir() / "sapling-spend.params"; boost::filesystem::path sapling_spend = ZC_GetParamsDir() / "sapling-spend.params";
boost::filesystem::path sapling_output = ZC_GetParamsDir() / "sapling-output.params"; boost::filesystem::path sapling_output = ZC_GetParamsDir() / "sapling-output.params";
static_assert( static_assert(
sizeof(boost::filesystem::path::value_type) == sizeof(codeunit), sizeof(boost::filesystem::path::value_type) == sizeof(codeunit),
"librustzcash not configured correctly"); "librustzcash not configured correctly");
auto sapling_spend_str = sapling_spend.native(); auto sapling_spend_str = sapling_spend.native();
auto sapling_output_str = sapling_output.native(); auto sapling_output_str = sapling_output.native();
librustzcash_init_zksnark_params( librustzcash_init_zksnark_params(

View File

@@ -4,13 +4,12 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <sodium.h> #include <sodium.h>
#include "main.h" #include "main.h"
#include "primitives/transaction.h" #include "primitives/transaction.h"
#include "consensus/validation.h" #include "consensus/validation.h"
extern ZCJoinSplit* params; //TODO: Update these tests for Sapling
/*
TEST(checktransaction_tests, check_vpub_not_both_nonzero) { TEST(checktransaction_tests, check_vpub_not_both_nonzero) {
CMutableTransaction tx; CMutableTransaction tx;
tx.nVersion = 2; tx.nVersion = 2;
@@ -733,16 +732,16 @@ TEST(checktransaction_tests, SaplingSproutInputSumsTooLarge) {
// create JSDescription // create JSDescription
uint256 rt; uint256 rt;
uint256 joinSplitPubKey; uint256 joinSplitPubKey;
std::array<libzcash::JSInput, ZC_NUM_JS_INPUTS> inputs = { std::array<libzcash::JSInput, HUSH_NUM_JS_INPUTS> inputs = {
libzcash::JSInput(), libzcash::JSInput(),
libzcash::JSInput() libzcash::JSInput()
}; };
std::array<libzcash::JSOutput, ZC_NUM_JS_OUTPUTS> outputs = { std::array<libzcash::JSOutput, HUSH_NUM_JS_OUTPUTS> outputs = {
libzcash::JSOutput(), libzcash::JSOutput(),
libzcash::JSOutput() libzcash::JSOutput()
}; };
std::array<size_t, ZC_NUM_JS_INPUTS> inputMap; std::array<size_t, HUSH_NUM_JS_INPUTS> inputMap;
std::array<size_t, ZC_NUM_JS_OUTPUTS> outputMap; std::array<size_t, HUSH_NUM_JS_OUTPUTS> outputMap;
auto jsdesc = JSDescription::Randomized( auto jsdesc = JSDescription::Randomized(
true, true,
@@ -1037,3 +1036,4 @@ TEST(checktransaction_tests, BadTxReceivedOverNetwork)
} }
} }
} }
*/

View File

@@ -2,14 +2,11 @@
// Distributed under the GPLv3 software license, see the accompanying // Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "consensus/upgrades.h" #include "consensus/upgrades.h"
#include "consensus/validation.h" #include "consensus/validation.h"
#include "main.h" #include "main.h"
#include "utiltest.h" #include "utiltest.h"
extern ZCJoinSplit* params;
extern bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos); extern bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos);
void ExpectOptionalAmount(CAmount expected, boost::optional<CAmount> actual) { void ExpectOptionalAmount(CAmount expected, boost::optional<CAmount> actual) {
@@ -88,77 +85,3 @@ TEST(Validation, ContextualCheckInputsPassesWithCoinbase) {
EXPECT_TRUE(ContextualCheckInputs(tx, state, view, false, 0, false, txdata, Params(CBaseChainParams::MAIN).GetConsensus(), consensusBranchId)); EXPECT_TRUE(ContextualCheckInputs(tx, state, view, false, 0, false, txdata, Params(CBaseChainParams::MAIN).GetConsensus(), consensusBranchId));
} }
} }
TEST(Validation, ReceivedBlockTransactions) {
auto sk = libzcash::SproutSpendingKey::random();
// Create a fake genesis block
CBlock block1;
block1.vtx.push_back(GetValidReceive(*params, sk, 5, true));
block1.hashMerkleRoot = block1.BuildMerkleTree();
CBlockIndex fakeIndex1 {block1};
// Create a fake child block
CBlock block2;
block2.hashPrevBlock = block1.GetHash();
block2.vtx.push_back(GetValidReceive(*params, sk, 10, true));
block2.hashMerkleRoot = block2.BuildMerkleTree();
CBlockIndex fakeIndex2 {block2};
fakeIndex2.pprev = &fakeIndex1;
CDiskBlockPos pos1;
CDiskBlockPos pos2;
// Set initial state of indices
ASSERT_TRUE(fakeIndex1.RaiseValidity(BLOCK_VALID_TREE));
ASSERT_TRUE(fakeIndex2.RaiseValidity(BLOCK_VALID_TREE));
EXPECT_TRUE(fakeIndex1.IsValid(BLOCK_VALID_TREE));
EXPECT_TRUE(fakeIndex2.IsValid(BLOCK_VALID_TREE));
EXPECT_FALSE(fakeIndex1.IsValid(BLOCK_VALID_TRANSACTIONS));
EXPECT_FALSE(fakeIndex2.IsValid(BLOCK_VALID_TRANSACTIONS));
// Sprout pool values should not be set
EXPECT_FALSE((bool)fakeIndex1.nSproutValue);
EXPECT_FALSE((bool)fakeIndex1.nChainSproutValue);
EXPECT_FALSE((bool)fakeIndex2.nSproutValue);
EXPECT_FALSE((bool)fakeIndex2.nChainSproutValue);
// Mark the second block's transactions as received first
CValidationState state;
EXPECT_TRUE(ReceivedBlockTransactions(block2, state, &fakeIndex2, pos2));
EXPECT_FALSE(fakeIndex1.IsValid(BLOCK_VALID_TRANSACTIONS));
EXPECT_TRUE(fakeIndex2.IsValid(BLOCK_VALID_TRANSACTIONS));
// Sprout pool value delta should now be set for the second block,
// but not any chain totals
EXPECT_FALSE((bool)fakeIndex1.nSproutValue);
EXPECT_FALSE((bool)fakeIndex1.nChainSproutValue);
{
SCOPED_TRACE("ExpectOptionalAmount call");
ExpectOptionalAmount(20, fakeIndex2.nSproutValue);
}
EXPECT_FALSE((bool)fakeIndex2.nChainSproutValue);
// Now mark the first block's transactions as received
EXPECT_TRUE(ReceivedBlockTransactions(block1, state, &fakeIndex1, pos1));
EXPECT_TRUE(fakeIndex1.IsValid(BLOCK_VALID_TRANSACTIONS));
EXPECT_TRUE(fakeIndex2.IsValid(BLOCK_VALID_TRANSACTIONS));
// Sprout pool values should now be set for both blocks
{
SCOPED_TRACE("ExpectOptionalAmount call");
ExpectOptionalAmount(10, fakeIndex1.nSproutValue);
}
{
SCOPED_TRACE("ExpectOptionalAmount call");
ExpectOptionalAmount(10, fakeIndex1.nChainSproutValue);
}
{
SCOPED_TRACE("ExpectOptionalAmount call");
ExpectOptionalAmount(20, fakeIndex2.nSproutValue);
}
{
SCOPED_TRACE("ExpectOptionalAmount call");
ExpectOptionalAmount(30, fakeIndex2.nChainSproutValue);
}
}

View File

@@ -93,11 +93,8 @@ extern bool komodo_dailysnapshot(int32_t height);
extern int32_t KOMODO_LOADINGBLOCKS; extern int32_t KOMODO_LOADINGBLOCKS;
extern char SMART_CHAIN_SYMBOL[]; extern char SMART_CHAIN_SYMBOL[];
extern int32_t KOMODO_SNAPSHOT_INTERVAL; extern int32_t KOMODO_SNAPSHOT_INTERVAL;
extern void komodo_init(int32_t height); extern void komodo_init(int32_t height);
//ZCJoinSplit* pzcashParams = NULL;
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
CWallet* pwalletMain = NULL; CWallet* pwalletMain = NULL;
#endif #endif

View File

@@ -37,9 +37,7 @@
#endif #endif
#include <array> #include <array>
#include <boost/variant.hpp> #include <boost/variant.hpp>
#include "zcash/NoteEncryption.hpp" #include "zcash/NoteEncryption.hpp"
#include "zcash/Zcash.h" #include "zcash/Zcash.h"
#include "zcash/JoinSplit.hpp" #include "zcash/JoinSplit.hpp"
@@ -53,20 +51,15 @@ extern std::string ASSETCHAINS_SELFIMPORT;
#define OUTPUTDESCRIPTION_SIZE GetSerializeSize(OutputDescription(), SER_NETWORK, PROTOCOL_VERSION) #define OUTPUTDESCRIPTION_SIZE GetSerializeSize(OutputDescription(), SER_NETWORK, PROTOCOL_VERSION)
#define SPENDDESCRIPTION_SIZE GetSerializeSize(SpendDescription(), SER_NETWORK, PROTOCOL_VERSION) #define SPENDDESCRIPTION_SIZE GetSerializeSize(SpendDescription(), SER_NETWORK, PROTOCOL_VERSION)
// Overwinter transaction version // Overwinter transaction version
static const int32_t OVERWINTER_TX_VERSION = 3; static const int32_t OVERWINTER_TX_VERSION = 3;
static_assert(OVERWINTER_TX_VERSION >= OVERWINTER_MIN_TX_VERSION, static_assert(OVERWINTER_TX_VERSION >= OVERWINTER_MIN_TX_VERSION, "Overwinter tx version must not be lower than minimum");
"Overwinter tx version must not be lower than minimum"); static_assert(OVERWINTER_TX_VERSION <= OVERWINTER_MAX_TX_VERSION, "Overwinter tx version must not be higher than maximum");
static_assert(OVERWINTER_TX_VERSION <= OVERWINTER_MAX_TX_VERSION,
"Overwinter tx version must not be higher than maximum");
// Sapling transaction version // Sapling transaction version
static const int32_t SAPLING_TX_VERSION = 4; static const int32_t SAPLING_TX_VERSION = 4;
static_assert(SAPLING_TX_VERSION >= SAPLING_MIN_TX_VERSION, static_assert(SAPLING_TX_VERSION >= SAPLING_MIN_TX_VERSION, "Sapling tx version must not be lower than minimum");
"Sapling tx version must not be lower than minimum"); static_assert(SAPLING_TX_VERSION <= SAPLING_MAX_TX_VERSION, "Sapling tx version must not be higher than maximum");
static_assert(SAPLING_TX_VERSION <= SAPLING_MAX_TX_VERSION,
"Sapling tx version must not be higher than maximum");
/** /**
* A shielded input to a transaction. It contains data that describes a Spend transfer. * A shielded input to a transaction. It contains data that describes a Spend transfer.
@@ -225,14 +218,14 @@ public:
// are derived from the secrets placed in the note // are derived from the secrets placed in the note
// and the secret spend-authority key known by the // and the secret spend-authority key known by the
// spender. // spender.
std::array<uint256, ZC_NUM_JS_INPUTS> nullifiers; std::array<uint256, HUSH_NUM_JS_INPUTS> nullifiers;
// Note commitments are introduced into the commitment // Note commitments are introduced into the commitment
// tree, blinding the public about the values and // tree, blinding the public about the values and
// destinations involved in the JoinSplit. The presence of // destinations involved in the JoinSplit. The presence of
// a commitment in the note commitment tree is required // a commitment in the note commitment tree is required
// to spend it. // to spend it.
std::array<uint256, ZC_NUM_JS_OUTPUTS> commitments; std::array<uint256, HUSH_NUM_JS_OUTPUTS> commitments;
// Ephemeral key // Ephemeral key
uint256 ephemeralKey; uint256 ephemeralKey;
@@ -241,7 +234,7 @@ public:
// These contain trapdoors, values and other information // These contain trapdoors, values and other information
// that the recipient needs, including a memo field. It // that the recipient needs, including a memo field. It
// is encrypted using the scheme implemented in crypto/NoteEncryption.cpp // is encrypted using the scheme implemented in crypto/NoteEncryption.cpp
std::array<ZCNoteEncryption::Ciphertext, ZC_NUM_JS_OUTPUTS> ciphertexts = {{ {{0}} }}; std::array<ZCNoteEncryption::Ciphertext, HUSH_NUM_JS_OUTPUTS> ciphertexts = {{ {{0}} }};
// Random seed // Random seed
uint256 randomSeed; uint256 randomSeed;
@@ -249,7 +242,7 @@ public:
// MACs // MACs
// The verification of the JoinSplit requires these MACs // The verification of the JoinSplit requires these MACs
// to be provided as an input. // to be provided as an input.
std::array<uint256, ZC_NUM_JS_INPUTS> macs; std::array<uint256, HUSH_NUM_JS_INPUTS> macs;
// JoinSplit proof // JoinSplit proof
// This is a zk-SNARK which ensures that this JoinSplit is valid. // This is a zk-SNARK which ensures that this JoinSplit is valid.
@@ -261,8 +254,8 @@ public:
ZCJoinSplit& params, ZCJoinSplit& params,
const uint256& joinSplitPubKey, const uint256& joinSplitPubKey,
const uint256& rt, const uint256& rt,
const std::array<libzcash::JSInput, ZC_NUM_JS_INPUTS>& inputs, const std::array<libzcash::JSInput, HUSH_NUM_JS_INPUTS>& inputs,
const std::array<libzcash::JSOutput, ZC_NUM_JS_OUTPUTS>& outputs, const std::array<libzcash::JSOutput, HUSH_NUM_JS_OUTPUTS>& outputs,
CAmount vpub_old, CAmount vpub_old,
CAmount vpub_new, CAmount vpub_new,
bool computeProof = true, // Set to false in some tests bool computeProof = true, // Set to false in some tests
@@ -273,10 +266,10 @@ public:
ZCJoinSplit& params, ZCJoinSplit& params,
const uint256& joinSplitPubKey, const uint256& joinSplitPubKey,
const uint256& rt, const uint256& rt,
std::array<libzcash::JSInput, ZC_NUM_JS_INPUTS>& inputs, std::array<libzcash::JSInput, HUSH_NUM_JS_INPUTS>& inputs,
std::array<libzcash::JSOutput, ZC_NUM_JS_OUTPUTS>& outputs, std::array<libzcash::JSOutput, HUSH_NUM_JS_OUTPUTS>& outputs,
std::array<size_t, ZC_NUM_JS_INPUTS>& inputMap, std::array<size_t, HUSH_NUM_JS_INPUTS>& inputMap,
std::array<size_t, ZC_NUM_JS_OUTPUTS>& outputMap, std::array<size_t, HUSH_NUM_JS_OUTPUTS>& outputMap,
CAmount vpub_old, CAmount vpub_old,
CAmount vpub_new, CAmount vpub_new,
bool computeProof = true, // Set to false in some tests bool computeProof = true, // Set to false in some tests

View File

@@ -3,12 +3,10 @@
// Distributed under the GPLv3 software license, see the accompanying // Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
#define BOOST_TEST_MODULE Bitcoin Test Suite #define BOOST_TEST_MODULE Hush Test Suite
#include "test_bitcoin.h" #include "test_bitcoin.h"
#include "crypto/common.h" #include "crypto/common.h"
#include "key.h" #include "key.h"
#include "main.h" #include "main.h"
#include "random.h" #include "random.h"
@@ -27,29 +25,24 @@
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include "librustzcash.h" #include "librustzcash.h"
CClientUIInterface uiInterface; // Declared but not defined in ui_interface.h CClientUIInterface uiInterface; // Declared but not defined in ui_interface.h
CWallet* pwalletMain; CWallet* pwalletMain;
ZCJoinSplit *pzcashParams;
extern bool fPrintToConsole; extern bool fPrintToConsole;
extern void noui_connect(); extern void noui_connect();
JoinSplitTestingSetup::JoinSplitTestingSetup() JoinSplitTestingSetup::JoinSplitTestingSetup()
{ {
boost::filesystem::path pk_path = ZC_GetParamsDir() / "sprout-proving.key";
boost::filesystem::path vk_path = ZC_GetParamsDir() / "sprout-verifying.key";
pzcashParams = ZCJoinSplit::Prepared(vk_path.string(), pk_path.string());
boost::filesystem::path sapling_spend = ZC_GetParamsDir() / "sapling-spend.params"; boost::filesystem::path sapling_spend = ZC_GetParamsDir() / "sapling-spend.params";
boost::filesystem::path sapling_output = ZC_GetParamsDir() / "sapling-output.params"; boost::filesystem::path sapling_output = ZC_GetParamsDir() / "sapling-output.params";
static_assert( static_assert(
sizeof(boost::filesystem::path::value_type) == sizeof(codeunit), sizeof(boost::filesystem::path::value_type) == sizeof(codeunit),
"librustzcash not configured correctly"); "librustzcash not configured correctly");
auto sapling_spend_str = sapling_spend.native(); auto sapling_spend_str = sapling_spend.native();
auto sapling_output_str = sapling_output.native(); auto sapling_output_str = sapling_output.native();
librustzcash_init_zksnark_params( librustzcash_init_zksnark_params(
@@ -67,7 +60,6 @@ JoinSplitTestingSetup::JoinSplitTestingSetup()
JoinSplitTestingSetup::~JoinSplitTestingSetup() JoinSplitTestingSetup::~JoinSplitTestingSetup()
{ {
delete pzcashParams;
} }
BasicTestingSetup::BasicTestingSetup() BasicTestingSetup::BasicTestingSetup()
@@ -94,12 +86,12 @@ TestingSetup::TestingSetup()
RegisterWalletRPCCommands(tableRPC); RegisterWalletRPCCommands(tableRPC);
#endif #endif
ClearDatadirCache(); ClearDatadirCache();
pathTemp = GetTempPath() / strprintf("test_bitcoin_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000))); pathTemp = GetTempPath() / strprintf("test_hush_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
boost::filesystem::create_directories(pathTemp); boost::filesystem::create_directories(pathTemp);
mapArgs["-datadir"] = pathTemp.string(); mapArgs["-datadir"] = pathTemp.string();
pblocktree = new CBlockTreeDB(1 << 20, true); pblocktree = new CBlockTreeDB(1 << 20, true);
pcoinsdbview = new CCoinsViewDB(1 << 23, true); pcoinsdbview = new CCoinsViewDB(1 << 23, true);
pcoinsTip = new CCoinsViewCache(pcoinsdbview); pcoinsTip = new CCoinsViewCache(pcoinsdbview);
InitBlockIndex(); InitBlockIndex();
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
bool fFirstRun; bool fFirstRun;
@@ -134,7 +126,6 @@ TestingSetup::~TestingSetup()
boost::filesystem::remove_all(pathTemp); boost::filesystem::remove_all(pathTemp);
} }
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(CMutableTransaction &tx, CTxMemPool *pool) { CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(CMutableTransaction &tx, CTxMemPool *pool) {
return CTxMemPoolEntry(tx, nFee, nTime, dPriority, nHeight, return CTxMemPoolEntry(tx, nFee, nTime, dPriority, nHeight,
pool ? pool->HasNoInputsOf(tx) : hadNoDependencies, pool ? pool->HasNoInputsOf(tx) : hadNoDependencies,

View File

@@ -362,11 +362,11 @@ BOOST_AUTO_TEST_CASE(test_basic_joinsplit_verification)
// create JSDescription // create JSDescription
uint256 joinSplitPubKey; uint256 joinSplitPubKey;
std::array<libzcash::JSInput, ZC_NUM_JS_INPUTS> inputs = { std::array<libzcash::JSInput, HUSH_NUM_JS_INPUTS> inputs = {
libzcash::JSInput(witness, note, k), libzcash::JSInput(witness, note, k),
libzcash::JSInput() // dummy input of zero value libzcash::JSInput() // dummy input of zero value
}; };
std::array<libzcash::JSOutput, ZC_NUM_JS_OUTPUTS> outputs = { std::array<libzcash::JSOutput, HUSH_NUM_JS_OUTPUTS> outputs = {
libzcash::JSOutput(addr, 50), libzcash::JSOutput(addr, 50),
libzcash::JSOutput(addr, 50) libzcash::JSOutput(addr, 50)
}; };

View File

@@ -60,7 +60,7 @@ int mta_find_output(UniValue obj, int n)
} }
UniValue outputMap = outputMapValue.get_array(); UniValue outputMap = outputMapValue.get_array();
assert(outputMap.size() == ZC_NUM_JS_OUTPUTS); assert(outputMap.size() == HUSH_NUM_JS_OUTPUTS);
for (size_t i = 0; i < outputMap.size(); i++) { for (size_t i = 0; i < outputMap.size(); i++) {
if (outputMap[i].get_int() == n) { if (outputMap[i].get_int() == n) {
return i; return i;

View File

@@ -34,16 +34,16 @@ TEST(Transaction, JSDescriptionRandomized) {
// create JSDescription // create JSDescription
uint256 pubKeyHash; uint256 pubKeyHash;
boost::array<libzcash::JSInput, ZC_NUM_JS_INPUTS> inputs = { boost::array<libzcash::JSInput, HUSH_NUM_JS_INPUTS> inputs = {
libzcash::JSInput(witness, note, k), libzcash::JSInput(witness, note, k),
libzcash::JSInput() // dummy input of zero value libzcash::JSInput() // dummy input of zero value
}; };
boost::array<libzcash::JSOutput, ZC_NUM_JS_OUTPUTS> outputs = { boost::array<libzcash::JSOutput, HUSH_NUM_JS_OUTPUTS> outputs = {
libzcash::JSOutput(addr, 50), libzcash::JSOutput(addr, 50),
libzcash::JSOutput(addr, 50) libzcash::JSOutput(addr, 50)
}; };
std::array<size_t, ZC_NUM_JS_INPUTS> inputMap; std::array<size_t, HUSH_NUM_JS_INPUTS> inputMap;
std::array<size_t, ZC_NUM_JS_OUTPUTS> outputMap; std::array<size_t, HUSH_NUM_JS_OUTPUTS> outputMap;
{ {
auto jsdesc = JSDescription::Randomized( auto jsdesc = JSDescription::Randomized(
@@ -73,8 +73,8 @@ TEST(Transaction, JSDescriptionRandomized) {
inputMap, outputMap, inputMap, outputMap,
0, 0, false, GenZero); 0, 0, false, GenZero);
std::array<size_t, ZC_NUM_JS_INPUTS> expectedInputMap {1, 0}; std::array<size_t, HUSH_NUM_JS_INPUTS> expectedInputMap {1, 0};
std::array<size_t, ZC_NUM_JS_OUTPUTS> expectedOutputMap {1, 0}; std::array<size_t, HUSH_NUM_JS_OUTPUTS> expectedOutputMap {1, 0};
EXPECT_EQ(expectedInputMap, inputMap); EXPECT_EQ(expectedInputMap, inputMap);
EXPECT_EQ(expectedOutputMap, outputMap); EXPECT_EQ(expectedOutputMap, outputMap);
} }
@@ -86,8 +86,8 @@ TEST(Transaction, JSDescriptionRandomized) {
inputMap, outputMap, inputMap, outputMap,
0, 0, false, GenMax); 0, 0, false, GenMax);
boost::array<size_t, ZC_NUM_JS_INPUTS> expectedInputMap {0, 1}; boost::array<size_t, HUSH_NUM_JS_INPUTS> expectedInputMap {0, 1};
boost::array<size_t, ZC_NUM_JS_OUTPUTS> expectedOutputMap {0, 1}; boost::array<size_t, HUSH_NUM_JS_OUTPUTS> expectedOutputMap {0, 1};
EXPECT_EQ(expectedInputMap, inputMap); EXPECT_EQ(expectedInputMap, inputMap);
EXPECT_EQ(expectedOutputMap, outputMap); EXPECT_EQ(expectedOutputMap, outputMap);
} }

View File

@@ -203,7 +203,7 @@ public:
uint256 hash; uint256 hash;
// Index into CTransaction.vjoinsplit // Index into CTransaction.vjoinsplit
uint64_t js; uint64_t js;
// Index into JSDescription fields of length ZC_NUM_JS_OUTPUTS // Index into JSDescription fields of length HUSH_NUM_JS_OUTPUTS
uint8_t n; uint8_t n;
JSOutPoint() { SetNull(); } JSOutPoint() { SetNull(); }

View File

@@ -2,8 +2,8 @@
// Distributed under the GPLv3 software license, see the accompanying // Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
#ifndef ZC_JOINSPLIT_H_ #ifndef HUSH_JOINSPLIT_H_
#define ZC_JOINSPLIT_H_ #define HUSH_JOINSPLIT_H_
#include "Zcash.h" #include "Zcash.h"
#include "Proof.hpp" #include "Proof.hpp"
@@ -13,7 +13,6 @@
#include "NoteEncryption.hpp" #include "NoteEncryption.hpp"
#include "uint256.h" #include "uint256.h"
#include "uint252.h" #include "uint252.h"
#include <array> #include <array>
namespace libzcash { namespace libzcash {
@@ -25,16 +24,13 @@ static constexpr size_t GROTH_PROOF_SIZE = (
typedef std::array<unsigned char, GROTH_PROOF_SIZE> GrothProof; typedef std::array<unsigned char, GROTH_PROOF_SIZE> GrothProof;
typedef boost::variant<PHGRProof, GrothProof> SproutProof; typedef boost::variant<PHGRProof, GrothProof> SproutProof;
class JSInput { }; class JSInput { };
class JSOutput { }; class JSOutput { };
template<size_t NumInputs, size_t NumOutputs> template<size_t NumInputs, size_t NumOutputs>
class JoinSplit { }; class JoinSplit { };
} }
typedef libzcash::JoinSplit<ZC_NUM_JS_INPUTS, ZC_NUM_JS_OUTPUTS> ZCJoinSplit; typedef libzcash::JoinSplit<HUSH_NUM_JS_INPUTS, HUSH_NUM_JS_OUTPUTS> ZCJoinSplit;
#endif // ZC_JOINSPLIT_H_ #endif // HUSH_JOINSPLIT_H_

View File

@@ -117,7 +117,7 @@ public:
} }
// Encrypts `message` with `pk_enc` and returns the ciphertext. // Encrypts `message` with `pk_enc` and returns the ciphertext.
// This is only called ZC_NUM_JS_OUTPUTS times for a given instantiation; // This is only called HUSH_NUM_JS_OUTPUTS times for a given instantiation;
// but can be called 255 times before the nonce-space runs out. // but can be called 255 times before the nonce-space runs out.
Ciphertext encrypt(const uint256 &pk_enc, Ciphertext encrypt(const uint256 &pk_enc,
const Plaintext &message const Plaintext &message

View File

@@ -4,8 +4,8 @@
#ifndef ZC_ZCASH_H_ #ifndef ZC_ZCASH_H_
#define ZC_ZCASH_H_ #define ZC_ZCASH_H_
#define ZC_NUM_JS_INPUTS 2 #define HUSH_NUM_JS_INPUTS 2
#define ZC_NUM_JS_OUTPUTS 2 #define HUSH_NUM_JS_OUTPUTS 2
#define INCREMENTAL_MERKLE_TREE_DEPTH 29 #define INCREMENTAL_MERKLE_TREE_DEPTH 29
#define INCREMENTAL_MERKLE_TREE_DEPTH_TESTING 4 #define INCREMENTAL_MERKLE_TREE_DEPTH_TESTING 4