Likely incorrect code in spend validation
https://github.com/zcoinofficial/zcoin/blob/master/src/main.cpp#L835
if (pubcoinId < 1 && pubcoinId == INT_MAX) { // IT BEGINS WITH 1
return state.DoS(100, error("CTransaction::CheckTransaction() : Error: nSequence is not correct format"));
}
The condition cannot be true.
Some of the other code around this point probably needs more thorough review; there are several stale comments, for example.
Thank you, it should be ||
Note that the whole of the validation code for Zerocoin spends is duplicated for each denomination. The copies for denominations other than ZQ_LOVELACE have just pubCoin < 1 in the corresponding condition. Why would anyone write it this way -- why not loop over the denominations?
The stale comments seem to have come from Tutorial.cpp in libzerocash. [Edit: I meant libzerocoin.]
@daira it should come from libzerocoin ?
Potential integer overflow in code above: https://github.com/zcoinofficial/zcoin/pull/73#issuecomment-280890654
In main.cpp: https://github.com/zcoinofficial/zcoin/pull/73/files#diff-7ec3c68a81efff79b6ca22ac1f1eabbaR833
Also, when using unsigned int, should the comparison be against UINT_MAX rather than INT_MAX ? https://github.com/zcoinofficial/zcoin/pull/73/files#diff-7ec3c68a81efff79b6ca22ac1f1eabbaR1009
The main issue I pointed out was fixed in 0359bcb2ead7feac5a3a5f6c6581b1b54cda8dd1, but the integer overflow @bitcartel mentioned has not been fixed, the validation code is still duplicated per denomination, and the stale comments are still there.
Closing as all issues raised in this thread have been rectified.