masp
masp copied to clipboard
Check for cases of i64/u64 overflow in note values
Unlike Zcash Sapling, notes are not limited to MAX_MONEY
. The logic needs to be checked thoroughly, and tests written, to make sure that there are no overflow or other issues when the value
is close to i64 or u64 limits.
I did not figure out why we use i64
in Amount
(like Zcash Sapling). And the negative Amount
will be rejected when constructing note and circuit. Actually, we use u64
in note and circuit.
Another question, if we use MAX_MONEY = i64::MAX
, should we still use the range [-MAX_MONEY, MAX_MONEY], or [i64::MIN, i64::MAX]?
I think setting MAX_MONEY = i64::MAX
and use the range [-MAX_MONEY, MAX_MONEY]
makes sense. So we should undo any change which removed MAX_MONEY
.
There is no reason why we need to support exactly i64::MIN
amount, so it seems unnecessarily risky to try.
Think that we've covered this in the i128 promotion.