Rename JSDescription's `serials` to `nullifiers`.

This commit is contained in:
Sean Bowe 2016-07-10 23:18:53 -06:00
parent 8675d94b63
commit bfeaf0049a
8 changed files with 42 additions and 42 deletions

View File

@ -396,7 +396,7 @@ bool CCoinsViewCache::HavePourRequirements(const CTransaction& tx) const
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) 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 (GetSerial(serial)) {
// If the serial is set, this transaction // If the serial is set, this transaction

View File

@ -966,17 +966,17 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
vInOutPoints.insert(txin.prevout); vInOutPoints.insert(txin.prevout);
} }
// Check for duplicate pour serials in this transaction // Check for duplicate pour nullifiers in this transaction
set<uint256> vPourSerials; set<uint256> vJoinSplitNullifiers;
BOOST_FOREACH(const JSDescription& pour, tx.vjoinsplit) 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)) if (vJoinSplitNullifiers.count(serial))
return state.DoS(100, error("CheckTransaction(): duplicate serials"), return state.DoS(100, error("CheckTransaction(): duplicate nullifiers"),
REJECT_INVALID, "bad-pours-serials-duplicate"); 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 JSDescription &pour, tx.vjoinsplit) {
BOOST_FOREACH(const uint256 &serial, pour.serials) { BOOST_FOREACH(const uint256 &serial, pour.nullifiers) {
if (pool.mapSerials.count(serial)) if (pool.mapSerials.count(serial))
{ {
return false; 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 JSDescription &pour, tx.vjoinsplit) {
BOOST_FOREACH(const uint256 &serial, pour.serials) { BOOST_FOREACH(const uint256 &serial, pour.nullifiers) {
inputs.SetSerial(serial, true); inputs.SetSerial(serial, true);
} }
} }
@ -1907,9 +1907,9 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
outs->Clear(); outs->Clear();
} }
// unspend serials // unspend nullifiers
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) { 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); view.SetSerial(serial, false);
} }
} }

View File

@ -29,7 +29,7 @@ JSDescription::JSDescription(ZCJoinSplit& params,
pubKeyHash, pubKeyHash,
randomSeed, randomSeed,
macs, macs,
serials, nullifiers,
commitments, commitments,
vpub_old, vpub_old,
vpub_new, vpub_new,
@ -46,7 +46,7 @@ bool JSDescription::Verify(
pubKeyHash, pubKeyHash,
randomSeed, randomSeed,
macs, macs,
serials, nullifiers,
commitments, commitments,
vpub_old, vpub_old,
vpub_new, vpub_new,
@ -56,7 +56,7 @@ bool JSDescription::Verify(
uint256 JSDescription::h_sig(ZCJoinSplit& params, const uint256& pubKeyHash) const 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 std::string COutPoint::ToString() const

View File

@ -31,11 +31,11 @@ public:
// transaction. // transaction.
uint256 anchor; 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 // are derived from the secrets placed in the bucket
// and the secret spend-authority key known by the // and the secret spend-authority key known by the
// spender. // spender.
boost::array<uint256, ZC_NUM_JS_INPUTS> serials; boost::array<uint256, ZC_NUM_JS_INPUTS> nullifiers;
// Bucket commitments are introduced into the commitment // Bucket commitments are introduced into the commitment
// tree, blinding the public about the values and // tree, blinding the public about the values and
@ -89,7 +89,7 @@ public:
READWRITE(vpub_old); READWRITE(vpub_old);
READWRITE(vpub_new); READWRITE(vpub_new);
READWRITE(anchor); READWRITE(anchor);
READWRITE(serials); READWRITE(nullifiers);
READWRITE(commitments); READWRITE(commitments);
READWRITE(ephemeralKey); READWRITE(ephemeralKey);
READWRITE(ciphertexts); READWRITE(ciphertexts);
@ -104,7 +104,7 @@ public:
a.vpub_old == b.vpub_old && a.vpub_old == b.vpub_old &&
a.vpub_new == b.vpub_new && a.vpub_new == b.vpub_new &&
a.anchor == b.anchor && a.anchor == b.anchor &&
a.serials == b.serials && a.nullifiers == b.nullifiers &&
a.commitments == b.commitments && a.commitments == b.commitments &&
a.ephemeralKey == b.ephemeralKey && a.ephemeralKey == b.ephemeralKey &&
a.ciphertexts == b.ciphertexts && a.ciphertexts == b.ciphertexts &&

View File

@ -98,11 +98,11 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
pour.push_back(Pair("anchor", pourtx.anchor.GetHex())); pour.push_back(Pair("anchor", pourtx.anchor.GetHex()));
{ {
Array serials; Array nullifiers;
BOOST_FOREACH(const uint256 serial, pourtx.serials) { BOOST_FOREACH(const uint256 serial, pourtx.nullifiers) {
serials.push_back(serial.GetHex()); nullifiers.push_back(serial.GetHex());
} }
pour.push_back(Pair("serials", serials)); pour.push_back(Pair("nullifiers", nullifiers));
} }
{ {

View File

@ -130,8 +130,8 @@ void static RandomTransaction(CMutableTransaction &tx, bool fSingle) {
} }
pourtx.anchor = GetRandHash(); pourtx.anchor = GetRandHash();
pourtx.serials[0] = GetRandHash(); pourtx.nullifiers[0] = GetRandHash();
pourtx.serials[1] = GetRandHash(); pourtx.nullifiers[1] = GetRandHash();
pourtx.ephemeralKey = GetRandHash(); pourtx.ephemeralKey = GetRandHash();
pourtx.randomSeed = GetRandHash(); pourtx.randomSeed = GetRandHash();
randombytes_buf(pourtx.ciphertexts[0].begin(), pourtx.ciphertexts[0].size()); randombytes_buf(pourtx.ciphertexts[0].begin(), pourtx.ciphertexts[0].size());

View File

@ -396,8 +396,8 @@ BOOST_AUTO_TEST_CASE(test_simple_pour_invalidity)
newTx.vjoinsplit.push_back(JSDescription()); newTx.vjoinsplit.push_back(JSDescription());
JSDescription *pourtx = &newTx.vjoinsplit[0]; JSDescription *pourtx = &newTx.vjoinsplit[0];
pourtx->serials[0] = GetRandHash(); pourtx->nullifiers[0] = GetRandHash();
pourtx->serials[1] = GetRandHash(); pourtx->nullifiers[1] = GetRandHash();
BOOST_CHECK(!CheckTransactionWithoutProofVerification(newTx, state)); BOOST_CHECK(!CheckTransactionWithoutProofVerification(newTx, state));
BOOST_CHECK(state.GetRejectReason() == "bad-txns-invalid-joinsplit-signature"); 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"); 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); CMutableTransaction newTx(tx);
CValidationState state; CValidationState state;
newTx.vjoinsplit.push_back(JSDescription()); newTx.vjoinsplit.push_back(JSDescription());
JSDescription *pourtx = &newTx.vjoinsplit[0]; JSDescription *pourtx = &newTx.vjoinsplit[0];
pourtx->serials[0] = GetRandHash(); pourtx->nullifiers[0] = GetRandHash();
pourtx->serials[1] = pourtx->serials[0]; pourtx->nullifiers[1] = pourtx->nullifiers[0];
BOOST_CHECK(!CheckTransaction(newTx, state)); 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()); newTx.vjoinsplit.push_back(JSDescription());
JSDescription *pourtx2 = &newTx.vjoinsplit[1]; JSDescription *pourtx2 = &newTx.vjoinsplit[1];
pourtx2->serials[0] = GetRandHash(); pourtx2->nullifiers[0] = GetRandHash();
pourtx2->serials[1] = pourtx->serials[0]; pourtx2->nullifiers[1] = pourtx->nullifiers[0];
BOOST_CHECK(!CheckTransaction(newTx, state)); 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. // 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()); newTx.vjoinsplit.push_back(JSDescription());
JSDescription *pourtx = &newTx.vjoinsplit[0]; JSDescription *pourtx = &newTx.vjoinsplit[0];
pourtx->serials[0] = GetRandHash(); pourtx->nullifiers[0] = GetRandHash();
pourtx->serials[1] = GetRandHash(); pourtx->nullifiers[1] = GetRandHash();
newTx.vin.push_back(CTxIn(uint256(), -1)); newTx.vin.push_back(CTxIn(uint256(), -1));

View File

@ -100,7 +100,7 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
for (unsigned int i = 0; i < tx.vin.size(); i++) for (unsigned int i = 0; i < tx.vin.size(); i++)
mapNextTx[tx.vin[i].prevout] = CInPoint(&tx, i); mapNextTx[tx.vin[i].prevout] = CInPoint(&tx, i);
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) { BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) {
BOOST_FOREACH(const uint256 &serial, pour.serials) { BOOST_FOREACH(const uint256 &serial, pour.nullifiers) {
mapSerials[serial] = &tx; mapSerials[serial] = &tx;
} }
} }
@ -149,7 +149,7 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list<CTransaction>& rem
BOOST_FOREACH(const CTxIn& txin, tx.vin) BOOST_FOREACH(const CTxIn& txin, tx.vin)
mapNextTx.erase(txin.prevout); mapNextTx.erase(txin.prevout);
BOOST_FOREACH(const JSDescription& pour, tx.vjoinsplit) { BOOST_FOREACH(const JSDescription& pour, tx.vjoinsplit) {
BOOST_FOREACH(const uint256& serial, pour.serials) { BOOST_FOREACH(const uint256& serial, pour.nullifiers) {
mapSerials.erase(serial); 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 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); std::map<uint256, const CTransaction*>::iterator it = mapSerials.find(serial);
if (it != mapSerials.end()) { if (it != mapSerials.end()) {
const CTransaction &txConflict = *it->second; const CTransaction &txConflict = *it->second;
@ -318,7 +318,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
boost::unordered_map<uint256, ZCIncrementalMerkleTree, CCoinsKeyHasher> intermediates; boost::unordered_map<uint256, ZCIncrementalMerkleTree, CCoinsKeyHasher> intermediates;
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) { 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)); assert(!pcoins->GetSerial(serial));
} }