Rename JSDescription's `serials` to `nullifiers`.
This commit is contained in:
parent
8675d94b63
commit
bfeaf0049a
|
@ -396,7 +396,7 @@ bool CCoinsViewCache::HavePourRequirements(const CTransaction& tx) const
|
|||
|
||||
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit)
|
||||
{
|
||||
BOOST_FOREACH(const uint256& serial, pour.serials)
|
||||
BOOST_FOREACH(const uint256& serial, pour.nullifiers)
|
||||
{
|
||||
if (GetSerial(serial)) {
|
||||
// If the serial is set, this transaction
|
||||
|
|
24
src/main.cpp
24
src/main.cpp
|
@ -966,17 +966,17 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
|
|||
vInOutPoints.insert(txin.prevout);
|
||||
}
|
||||
|
||||
// Check for duplicate pour serials in this transaction
|
||||
set<uint256> vPourSerials;
|
||||
// Check for duplicate pour nullifiers in this transaction
|
||||
set<uint256> vJoinSplitNullifiers;
|
||||
BOOST_FOREACH(const JSDescription& pour, tx.vjoinsplit)
|
||||
{
|
||||
BOOST_FOREACH(const uint256& serial, pour.serials)
|
||||
BOOST_FOREACH(const uint256& serial, pour.nullifiers)
|
||||
{
|
||||
if (vPourSerials.count(serial))
|
||||
return state.DoS(100, error("CheckTransaction(): duplicate serials"),
|
||||
REJECT_INVALID, "bad-pours-serials-duplicate");
|
||||
if (vJoinSplitNullifiers.count(serial))
|
||||
return state.DoS(100, error("CheckTransaction(): duplicate nullifiers"),
|
||||
REJECT_INVALID, "bad-pours-nullifiers-duplicate");
|
||||
|
||||
vPourSerials.insert(serial);
|
||||
vJoinSplitNullifiers.insert(serial);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1105,7 +1105,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
|||
}
|
||||
}
|
||||
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) {
|
||||
BOOST_FOREACH(const uint256 &serial, pour.serials) {
|
||||
BOOST_FOREACH(const uint256 &serial, pour.nullifiers) {
|
||||
if (pool.mapSerials.count(serial))
|
||||
{
|
||||
return false;
|
||||
|
@ -1585,9 +1585,9 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach
|
|||
}
|
||||
}
|
||||
|
||||
// spend serials
|
||||
// spend nullifiers
|
||||
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) {
|
||||
BOOST_FOREACH(const uint256 &serial, pour.serials) {
|
||||
BOOST_FOREACH(const uint256 &serial, pour.nullifiers) {
|
||||
inputs.SetSerial(serial, true);
|
||||
}
|
||||
}
|
||||
|
@ -1907,9 +1907,9 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
|
|||
outs->Clear();
|
||||
}
|
||||
|
||||
// unspend serials
|
||||
// unspend nullifiers
|
||||
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) {
|
||||
BOOST_FOREACH(const uint256 &serial, pour.serials) {
|
||||
BOOST_FOREACH(const uint256 &serial, pour.nullifiers) {
|
||||
view.SetSerial(serial, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ JSDescription::JSDescription(ZCJoinSplit& params,
|
|||
pubKeyHash,
|
||||
randomSeed,
|
||||
macs,
|
||||
serials,
|
||||
nullifiers,
|
||||
commitments,
|
||||
vpub_old,
|
||||
vpub_new,
|
||||
|
@ -46,7 +46,7 @@ bool JSDescription::Verify(
|
|||
pubKeyHash,
|
||||
randomSeed,
|
||||
macs,
|
||||
serials,
|
||||
nullifiers,
|
||||
commitments,
|
||||
vpub_old,
|
||||
vpub_new,
|
||||
|
@ -56,7 +56,7 @@ bool JSDescription::Verify(
|
|||
|
||||
uint256 JSDescription::h_sig(ZCJoinSplit& params, const uint256& pubKeyHash) const
|
||||
{
|
||||
return params.h_sig(randomSeed, serials, pubKeyHash);
|
||||
return params.h_sig(randomSeed, nullifiers, pubKeyHash);
|
||||
}
|
||||
|
||||
std::string COutPoint::ToString() const
|
||||
|
|
|
@ -31,11 +31,11 @@ public:
|
|||
// transaction.
|
||||
uint256 anchor;
|
||||
|
||||
// Serials are used to prevent double-spends. They
|
||||
// Nullifiers are used to prevent double-spends. They
|
||||
// are derived from the secrets placed in the bucket
|
||||
// and the secret spend-authority key known by the
|
||||
// spender.
|
||||
boost::array<uint256, ZC_NUM_JS_INPUTS> serials;
|
||||
boost::array<uint256, ZC_NUM_JS_INPUTS> nullifiers;
|
||||
|
||||
// Bucket commitments are introduced into the commitment
|
||||
// tree, blinding the public about the values and
|
||||
|
@ -89,7 +89,7 @@ public:
|
|||
READWRITE(vpub_old);
|
||||
READWRITE(vpub_new);
|
||||
READWRITE(anchor);
|
||||
READWRITE(serials);
|
||||
READWRITE(nullifiers);
|
||||
READWRITE(commitments);
|
||||
READWRITE(ephemeralKey);
|
||||
READWRITE(ciphertexts);
|
||||
|
@ -104,7 +104,7 @@ public:
|
|||
a.vpub_old == b.vpub_old &&
|
||||
a.vpub_new == b.vpub_new &&
|
||||
a.anchor == b.anchor &&
|
||||
a.serials == b.serials &&
|
||||
a.nullifiers == b.nullifiers &&
|
||||
a.commitments == b.commitments &&
|
||||
a.ephemeralKey == b.ephemeralKey &&
|
||||
a.ciphertexts == b.ciphertexts &&
|
||||
|
|
|
@ -98,11 +98,11 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
|
|||
pour.push_back(Pair("anchor", pourtx.anchor.GetHex()));
|
||||
|
||||
{
|
||||
Array serials;
|
||||
BOOST_FOREACH(const uint256 serial, pourtx.serials) {
|
||||
serials.push_back(serial.GetHex());
|
||||
Array nullifiers;
|
||||
BOOST_FOREACH(const uint256 serial, pourtx.nullifiers) {
|
||||
nullifiers.push_back(serial.GetHex());
|
||||
}
|
||||
pour.push_back(Pair("serials", serials));
|
||||
pour.push_back(Pair("nullifiers", nullifiers));
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -130,8 +130,8 @@ void static RandomTransaction(CMutableTransaction &tx, bool fSingle) {
|
|||
}
|
||||
|
||||
pourtx.anchor = GetRandHash();
|
||||
pourtx.serials[0] = GetRandHash();
|
||||
pourtx.serials[1] = GetRandHash();
|
||||
pourtx.nullifiers[0] = GetRandHash();
|
||||
pourtx.nullifiers[1] = GetRandHash();
|
||||
pourtx.ephemeralKey = GetRandHash();
|
||||
pourtx.randomSeed = GetRandHash();
|
||||
randombytes_buf(pourtx.ciphertexts[0].begin(), pourtx.ciphertexts[0].size());
|
||||
|
|
|
@ -396,8 +396,8 @@ BOOST_AUTO_TEST_CASE(test_simple_pour_invalidity)
|
|||
newTx.vjoinsplit.push_back(JSDescription());
|
||||
JSDescription *pourtx = &newTx.vjoinsplit[0];
|
||||
|
||||
pourtx->serials[0] = GetRandHash();
|
||||
pourtx->serials[1] = GetRandHash();
|
||||
pourtx->nullifiers[0] = GetRandHash();
|
||||
pourtx->nullifiers[1] = GetRandHash();
|
||||
|
||||
BOOST_CHECK(!CheckTransactionWithoutProofVerification(newTx, state));
|
||||
BOOST_CHECK(state.GetRejectReason() == "bad-txns-invalid-joinsplit-signature");
|
||||
|
@ -457,29 +457,29 @@ BOOST_AUTO_TEST_CASE(test_simple_pour_invalidity)
|
|||
BOOST_CHECK(state.GetRejectReason() == "bad-txns-txouttotal-toolarge");
|
||||
}
|
||||
{
|
||||
// Ensure that serials are never duplicated within a transaction.
|
||||
// Ensure that nullifiers are never duplicated within a transaction.
|
||||
CMutableTransaction newTx(tx);
|
||||
CValidationState state;
|
||||
|
||||
newTx.vjoinsplit.push_back(JSDescription());
|
||||
JSDescription *pourtx = &newTx.vjoinsplit[0];
|
||||
|
||||
pourtx->serials[0] = GetRandHash();
|
||||
pourtx->serials[1] = pourtx->serials[0];
|
||||
pourtx->nullifiers[0] = GetRandHash();
|
||||
pourtx->nullifiers[1] = pourtx->nullifiers[0];
|
||||
|
||||
BOOST_CHECK(!CheckTransaction(newTx, state));
|
||||
BOOST_CHECK(state.GetRejectReason() == "bad-pours-serials-duplicate");
|
||||
BOOST_CHECK(state.GetRejectReason() == "bad-pours-nullifiers-duplicate");
|
||||
|
||||
pourtx->serials[1] = GetRandHash();
|
||||
pourtx->nullifiers[1] = GetRandHash();
|
||||
|
||||
newTx.vjoinsplit.push_back(JSDescription());
|
||||
JSDescription *pourtx2 = &newTx.vjoinsplit[1];
|
||||
|
||||
pourtx2->serials[0] = GetRandHash();
|
||||
pourtx2->serials[1] = pourtx->serials[0];
|
||||
pourtx2->nullifiers[0] = GetRandHash();
|
||||
pourtx2->nullifiers[1] = pourtx->nullifiers[0];
|
||||
|
||||
BOOST_CHECK(!CheckTransaction(newTx, state));
|
||||
BOOST_CHECK(state.GetRejectReason() == "bad-pours-serials-duplicate");
|
||||
BOOST_CHECK(state.GetRejectReason() == "bad-pours-nullifiers-duplicate");
|
||||
}
|
||||
{
|
||||
// Ensure that coinbase transactions do not have pours.
|
||||
|
@ -488,8 +488,8 @@ BOOST_AUTO_TEST_CASE(test_simple_pour_invalidity)
|
|||
|
||||
newTx.vjoinsplit.push_back(JSDescription());
|
||||
JSDescription *pourtx = &newTx.vjoinsplit[0];
|
||||
pourtx->serials[0] = GetRandHash();
|
||||
pourtx->serials[1] = GetRandHash();
|
||||
pourtx->nullifiers[0] = GetRandHash();
|
||||
pourtx->nullifiers[1] = GetRandHash();
|
||||
|
||||
newTx.vin.push_back(CTxIn(uint256(), -1));
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
|
|||
for (unsigned int i = 0; i < tx.vin.size(); i++)
|
||||
mapNextTx[tx.vin[i].prevout] = CInPoint(&tx, i);
|
||||
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) {
|
||||
BOOST_FOREACH(const uint256 &serial, pour.serials) {
|
||||
BOOST_FOREACH(const uint256 &serial, pour.nullifiers) {
|
||||
mapSerials[serial] = &tx;
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list<CTransaction>& rem
|
|||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
||||
mapNextTx.erase(txin.prevout);
|
||||
BOOST_FOREACH(const JSDescription& pour, tx.vjoinsplit) {
|
||||
BOOST_FOREACH(const uint256& serial, pour.serials) {
|
||||
BOOST_FOREACH(const uint256& serial, pour.nullifiers) {
|
||||
mapSerials.erase(serial);
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx, std::list<CTransaction>
|
|||
}
|
||||
|
||||
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) {
|
||||
BOOST_FOREACH(const uint256 &serial, pour.serials) {
|
||||
BOOST_FOREACH(const uint256 &serial, pour.nullifiers) {
|
||||
std::map<uint256, const CTransaction*>::iterator it = mapSerials.find(serial);
|
||||
if (it != mapSerials.end()) {
|
||||
const CTransaction &txConflict = *it->second;
|
||||
|
@ -318,7 +318,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
|
|||
boost::unordered_map<uint256, ZCIncrementalMerkleTree, CCoinsKeyHasher> intermediates;
|
||||
|
||||
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) {
|
||||
BOOST_FOREACH(const uint256 &serial, pour.serials) {
|
||||
BOOST_FOREACH(const uint256 &serial, pour.nullifiers) {
|
||||
assert(!pcoins->GetSerial(serial));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue