Remove unused sprout test code that uses libsodium functions that we no longer use
This commit is contained in:
@@ -166,48 +166,6 @@ void static RandomTransaction(CMutableTransaction &tx, bool fSingle, uint32_t co
|
|||||||
tx.vShieldedOutput.push_back(odesc);
|
tx.vShieldedOutput.push_back(odesc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tx.nVersion >= 2) {
|
|
||||||
for (int js = 0; js < joinsplits; js++) {
|
|
||||||
JSDescription jsdesc;
|
|
||||||
if (insecure_rand() % 2 == 0) {
|
|
||||||
jsdesc.vpub_old = insecure_rand() % 100000000;
|
|
||||||
} else {
|
|
||||||
jsdesc.vpub_new = insecure_rand() % 100000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
jsdesc.anchor = GetRandHash();
|
|
||||||
jsdesc.nullifiers[0] = GetRandHash();
|
|
||||||
jsdesc.nullifiers[1] = GetRandHash();
|
|
||||||
jsdesc.ephemeralKey = GetRandHash();
|
|
||||||
jsdesc.randomSeed = GetRandHash();
|
|
||||||
randombytes_buf(jsdesc.ciphertexts[0].begin(), jsdesc.ciphertexts[0].size());
|
|
||||||
randombytes_buf(jsdesc.ciphertexts[1].begin(), jsdesc.ciphertexts[1].size());
|
|
||||||
if (tx.fOverwintered && tx.nVersion >= SAPLING_TX_VERSION) {
|
|
||||||
libzcash::GrothProof zkproof;
|
|
||||||
randombytes_buf(zkproof.begin(), zkproof.size());
|
|
||||||
jsdesc.proof = zkproof;
|
|
||||||
} else {
|
|
||||||
jsdesc.proof = libzcash::PHGRProof::random_invalid();
|
|
||||||
}
|
|
||||||
jsdesc.macs[0] = GetRandHash();
|
|
||||||
jsdesc.macs[1] = GetRandHash();
|
|
||||||
|
|
||||||
tx.vjoinsplit.push_back(jsdesc);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char joinSplitPrivKey[crypto_sign_SECRETKEYBYTES];
|
|
||||||
crypto_sign_keypair(tx.joinSplitPubKey.begin(), joinSplitPrivKey);
|
|
||||||
|
|
||||||
// Empty output script.
|
|
||||||
CScript scriptCode;
|
|
||||||
CTransaction signTx(tx);
|
|
||||||
uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId);
|
|
||||||
|
|
||||||
assert(crypto_sign_detached(&tx.joinSplitSig[0], NULL,
|
|
||||||
dataToBeSigned.begin(), 32,
|
|
||||||
joinSplitPrivKey
|
|
||||||
) == 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_SUITE(sighash_tests, JoinSplitTestingSetup)
|
BOOST_FIXTURE_TEST_SUITE(sighash_tests, JoinSplitTestingSetup)
|
||||||
|
|||||||
@@ -464,136 +464,6 @@ void test_simple_sapling_invalidity(uint32_t consensusBranchId, CMutableTransact
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_simple_joinsplit_invalidity(uint32_t consensusBranchId, CMutableTransaction tx)
|
|
||||||
{
|
|
||||||
auto verifier = libzcash::ProofVerifier::Strict();
|
|
||||||
{
|
|
||||||
// Ensure that empty vin/vout remain invalid without
|
|
||||||
// joinsplits.
|
|
||||||
CMutableTransaction newTx(tx);
|
|
||||||
CValidationState state;
|
|
||||||
|
|
||||||
unsigned char joinSplitPrivKey[crypto_sign_SECRETKEYBYTES];
|
|
||||||
crypto_sign_keypair(newTx.joinSplitPubKey.begin(), joinSplitPrivKey);
|
|
||||||
|
|
||||||
// No joinsplits, vin and vout, means it should be invalid.
|
|
||||||
BOOST_CHECK(!CheckTransactionWithoutProofVerification(newTx, state));
|
|
||||||
BOOST_CHECK(state.GetRejectReason() == "bad-txns-vin-empty");
|
|
||||||
|
|
||||||
newTx.vin.push_back(CTxIn(uint256S("0000000000000000000000000000000000000000000000000000000000000001"), 0));
|
|
||||||
|
|
||||||
BOOST_CHECK(!CheckTransactionWithoutProofVerification(newTx, state));
|
|
||||||
BOOST_CHECK(state.GetRejectReason() == "bad-txns-vout-empty");
|
|
||||||
|
|
||||||
newTx.vjoinsplit.push_back(JSDescription());
|
|
||||||
JSDescription *jsdesc = &newTx.vjoinsplit[0];
|
|
||||||
|
|
||||||
jsdesc->nullifiers[0] = GetRandHash();
|
|
||||||
jsdesc->nullifiers[1] = GetRandHash();
|
|
||||||
|
|
||||||
BOOST_CHECK(CheckTransactionWithoutProofVerification(newTx, state));
|
|
||||||
BOOST_CHECK(!ContextualCheckTransaction(0,newTx, state, 0, 100));
|
|
||||||
BOOST_CHECK(state.GetRejectReason() == "bad-txns-invalid-joinsplit-signature");
|
|
||||||
|
|
||||||
// Empty output script.
|
|
||||||
CScript scriptCode;
|
|
||||||
CTransaction signTx(newTx);
|
|
||||||
uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId);
|
|
||||||
|
|
||||||
assert(crypto_sign_detached(&newTx.joinSplitSig[0], NULL,
|
|
||||||
dataToBeSigned.begin(), 32,
|
|
||||||
joinSplitPrivKey
|
|
||||||
) == 0);
|
|
||||||
|
|
||||||
BOOST_CHECK(CheckTransactionWithoutProofVerification(newTx, state));
|
|
||||||
BOOST_CHECK(ContextualCheckTransaction(0,newTx, state, 0, 100));
|
|
||||||
}
|
|
||||||
{
|
|
||||||
// Ensure that values within the joinsplit are well-formed.
|
|
||||||
CMutableTransaction newTx(tx);
|
|
||||||
CValidationState state;
|
|
||||||
|
|
||||||
newTx.vjoinsplit.push_back(JSDescription());
|
|
||||||
|
|
||||||
JSDescription *jsdesc = &newTx.vjoinsplit[0];
|
|
||||||
jsdesc->vpub_old = -1;
|
|
||||||
|
|
||||||
BOOST_CHECK(!CheckTransaction(newTx, state, verifier));
|
|
||||||
BOOST_CHECK(state.GetRejectReason() == "bad-txns-vpub_old-negative");
|
|
||||||
|
|
||||||
jsdesc->vpub_old = MAX_MONEY + 1;
|
|
||||||
|
|
||||||
BOOST_CHECK(!CheckTransaction(newTx, state, verifier));
|
|
||||||
BOOST_CHECK(state.GetRejectReason() == "bad-txns-vpub_old-toolarge");
|
|
||||||
|
|
||||||
jsdesc->vpub_old = 0;
|
|
||||||
jsdesc->vpub_new = -1;
|
|
||||||
|
|
||||||
BOOST_CHECK(!CheckTransaction(newTx, state, verifier));
|
|
||||||
BOOST_CHECK(state.GetRejectReason() == "bad-txns-vpub_new-negative");
|
|
||||||
|
|
||||||
jsdesc->vpub_new = MAX_MONEY + 1;
|
|
||||||
|
|
||||||
BOOST_CHECK(!CheckTransaction(newTx, state, verifier));
|
|
||||||
BOOST_CHECK(state.GetRejectReason() == "bad-txns-vpub_new-toolarge");
|
|
||||||
|
|
||||||
jsdesc->vpub_new = (MAX_MONEY / 2) + 10;
|
|
||||||
|
|
||||||
newTx.vjoinsplit.push_back(JSDescription());
|
|
||||||
|
|
||||||
JSDescription *jsdesc2 = &newTx.vjoinsplit[1];
|
|
||||||
jsdesc2->vpub_new = (MAX_MONEY / 2) + 10;
|
|
||||||
|
|
||||||
BOOST_CHECK(!CheckTransaction(newTx, state, verifier));
|
|
||||||
BOOST_CHECK(state.GetRejectReason() == "bad-txns-txintotal-toolarge");
|
|
||||||
}
|
|
||||||
{
|
|
||||||
// Ensure that nullifiers are never duplicated within a transaction.
|
|
||||||
CMutableTransaction newTx(tx);
|
|
||||||
CValidationState state;
|
|
||||||
|
|
||||||
newTx.vjoinsplit.push_back(JSDescription());
|
|
||||||
JSDescription *jsdesc = &newTx.vjoinsplit[0];
|
|
||||||
|
|
||||||
jsdesc->nullifiers[0] = GetRandHash();
|
|
||||||
jsdesc->nullifiers[1] = jsdesc->nullifiers[0];
|
|
||||||
|
|
||||||
BOOST_CHECK(!CheckTransaction(newTx, state, verifier));
|
|
||||||
BOOST_CHECK(state.GetRejectReason() == "bad-joinsplits-nullifiers-duplicate");
|
|
||||||
|
|
||||||
jsdesc->nullifiers[1] = GetRandHash();
|
|
||||||
|
|
||||||
newTx.vjoinsplit.push_back(JSDescription());
|
|
||||||
jsdesc = &newTx.vjoinsplit[0]; // Fixes #2026. Related PR #2078.
|
|
||||||
JSDescription *jsdesc2 = &newTx.vjoinsplit[1];
|
|
||||||
|
|
||||||
jsdesc2->nullifiers[0] = GetRandHash();
|
|
||||||
jsdesc2->nullifiers[1] = jsdesc->nullifiers[0];
|
|
||||||
|
|
||||||
BOOST_CHECK(!CheckTransaction(newTx, state, verifier));
|
|
||||||
BOOST_CHECK(state.GetRejectReason() == "bad-joinsplits-nullifiers-duplicate");
|
|
||||||
}
|
|
||||||
{
|
|
||||||
// Ensure that coinbase transactions do not have joinsplits.
|
|
||||||
CMutableTransaction newTx(tx);
|
|
||||||
CValidationState state;
|
|
||||||
|
|
||||||
newTx.vjoinsplit.push_back(JSDescription());
|
|
||||||
JSDescription *jsdesc = &newTx.vjoinsplit[0];
|
|
||||||
jsdesc->nullifiers[0] = GetRandHash();
|
|
||||||
jsdesc->nullifiers[1] = GetRandHash();
|
|
||||||
|
|
||||||
newTx.vin.push_back(CTxIn(uint256(), -1));
|
|
||||||
|
|
||||||
{
|
|
||||||
CTransaction finalNewTx(newTx);
|
|
||||||
BOOST_CHECK(finalNewTx.IsCoinBase());
|
|
||||||
}
|
|
||||||
BOOST_CHECK(!CheckTransaction(newTx, state, verifier));
|
|
||||||
BOOST_CHECK(state.GetRejectReason() == "bad-cb-has-joinsplits");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_simple_joinsplit_invalidity_driver) {
|
BOOST_AUTO_TEST_CASE(test_simple_joinsplit_invalidity_driver) {
|
||||||
{
|
{
|
||||||
CMutableTransaction mtx;
|
CMutableTransaction mtx;
|
||||||
|
|||||||
Reference in New Issue
Block a user