hermeznetwork / circuits

Implements hermez network zk-Snarks circuits
GNU Affero General Public License v3.0
55 stars 21 forks source link

New fee table #14

Closed krlosMata closed 3 years ago

krlosMata commented 3 years ago

Describe issue

Current fee table values are all shifted left 79 bits in order to have precision for all feeFactors. This leads that the maximum feeFactorShifted value is 10**31 << 79, with a bit length of 182.

Taking into account that maximum transferred amountFloat could be 0xFFFF, with a bit length of 113 bits, computing amount * feeFactorShifted could overflow snark Field maximum bits length (253) since 182 + 113 = 295 > 253. Error is not triggered since num2bits template does not checks overflows and therefore, it could led to applying an erroneous feeAmount

Solution

Implementation

krlosMata commented 3 years ago

Duplicated in #15