rct: log why verification fails

and remove some unnecessary variables in the checking code
This commit is contained in:
moneromooo-monero 2016-08-12 18:30:16 +01:00
parent d4b8991e44
commit 6f526cdff8
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3

View file

@ -741,21 +741,27 @@ namespace rct {
try try
{ {
size_t i = 0; size_t i = 0;
bool rvb = true;
bool tmp; bool tmp;
DP("range proofs verified?"); DP("range proofs verified?");
for (i = 0; i < rv.outPk.size(); i++) { for (i = 0; i < rv.outPk.size(); i++) {
tmp = verRange(rv.outPk[i].mask, rv.p.rangeSigs[i]); tmp = verRange(rv.outPk[i].mask, rv.p.rangeSigs[i]);
DP(tmp); DP(tmp);
rvb = (rvb && tmp); if (!tmp) {
LOG_ERROR("Range proof verification failed for input " << i);
return false;
}
} }
//compute txn fee //compute txn fee
key txnFeeKey = scalarmultH(d2h(rv.txnFee)); key txnFeeKey = scalarmultH(d2h(rv.txnFee));
bool mgVerd = verRctMG(rv.p.MGs[0], rv.mixRing, rv.outPk, txnFeeKey, get_pre_mlsag_hash(rv)); bool mgVerd = verRctMG(rv.p.MGs[0], rv.mixRing, rv.outPk, txnFeeKey, get_pre_mlsag_hash(rv));
DP("mg sig verified?"); DP("mg sig verified?");
DP(mgVerd); DP(mgVerd);
if (!mgVerd) {
LOG_ERROR("MG signature verification failed");
return false;
}
return (rvb && mgVerd); return true;
} }
catch(...) catch(...)
{ {
@ -767,7 +773,6 @@ namespace rct {
//assumes only post-rct style inputs (at least for max anonymity) //assumes only post-rct style inputs (at least for max anonymity)
bool verRctSimple(const rctSig & rv) { bool verRctSimple(const rctSig & rv) {
size_t i = 0; size_t i = 0;
bool rvb = true;
CHECK_AND_ASSERT_MES(rv.type == RCTTypeSimple, false, "verRctSimple called on non simple rctSig"); CHECK_AND_ASSERT_MES(rv.type == RCTTypeSimple, false, "verRctSimple called on non simple rctSig");
CHECK_AND_ASSERT_MES(rv.outPk.size() == rv.p.rangeSigs.size(), false, "Mismatched sizes of outPk and rv.p.rangeSigs"); CHECK_AND_ASSERT_MES(rv.outPk.size() == rv.p.rangeSigs.size(), false, "Mismatched sizes of outPk and rv.p.rangeSigs");
@ -778,6 +783,7 @@ namespace rct {
key sumOutpks = identity(); key sumOutpks = identity();
for (i = 0; i < rv.outPk.size(); i++) { for (i = 0; i < rv.outPk.size(); i++) {
if (!verRange(rv.outPk[i].mask, rv.p.rangeSigs[i])) { if (!verRange(rv.outPk[i].mask, rv.p.rangeSigs[i])) {
LOG_ERROR("Range proof verified failed for input " << i);
return false; return false;
} }
addKeys(sumOutpks, sumOutpks, rv.outPk[i].mask); addKeys(sumOutpks, sumOutpks, rv.outPk[i].mask);
@ -794,21 +800,19 @@ namespace rct {
addKeys(sumPseudoOuts, sumPseudoOuts, rv.pseudoOuts[i]); addKeys(sumPseudoOuts, sumPseudoOuts, rv.pseudoOuts[i]);
DP(tmpb); DP(tmpb);
if (!tmpb) { if (!tmpb) {
LOG_ERROR("verRctMGSimple failed for input " << i);
return false; return false;
} }
} }
DP(sumPseudoOuts); DP(sumPseudoOuts);
bool mgVerd = true;
//check pseudoOuts vs Outs.. //check pseudoOuts vs Outs..
if (!equalKeys(sumPseudoOuts, sumOutpks)) { if (!equalKeys(sumPseudoOuts, sumOutpks)) {
LOG_ERROR("Sum check failed");
return false; return false;
} }
DP("mg sig verified?"); return true;
DP(mgVerd);
return (rvb && mgVerd);
} }
//RingCT protocol //RingCT protocol