Skip to content

Commit

Permalink
[zPIV[Unit Test] Possible redundant denomination validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
furszy committed May 23, 2019
1 parent 507f7c8 commit fdfd999
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/test/zerocoin_transactions_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ BOOST_AUTO_TEST_CASE(zerocoin_public_spend_test)
BOOST_CHECK_MESSAGE(publicSpendTest.HasValidSignature(), "Failed to validate public spend signature");
BOOST_CHECK_MESSAGE(spend->HasValidSignature(), "Failed to validate spend signature");

// Verify that fails with a different denomination
in.nSequence = 500;
PublicCoinSpend publicSpend2(ZCParams);
BOOST_CHECK_MESSAGE(!ZPIVModule::validateInput(in, out, tx, publicSpend2), "Different denomination");

}

BOOST_AUTO_TEST_SUITE_END()
7 changes: 5 additions & 2 deletions src/zpiv/zpivmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,13 @@ namespace ZPIVModule {
bool validateInput(const CTxIn &in, const CTxOut &prevOut, const CTransaction &tx, PublicCoinSpend &publicSpend) {
// Now prove that the commitment value opens to the input
if (!parseCoinSpend(in, tx, prevOut, publicSpend)) {
std::cout << "parse failed" << std::endl;
return false;
}
// TODO: Validate that the prev out has the same spend denom?
if (libzerocoin::ZerocoinDenominationToAmount(
libzerocoin::IntToZerocoinDenomination(in.nSequence)) != prevOut.nValue) {
return error("PublicCoinSpend validateInput :: input nSequence different to prevout value\n");
}

return publicSpend.validate();
}

Expand Down

0 comments on commit fdfd999

Please sign in to comment.