arkworks-rs / r1cs-std

R1CS constraints for bits, fields, and elliptic curves
https://www.arkworks.rs
Apache License 2.0
137 stars 59 forks source link

Fix for add_many (issue #23) #113

Closed tgodden closed 1 year ago

tgodden commented 1 year ago

Description

Fixed issue #23.

Explanation

An addition of two n-bit number can at most be an n+1-bit number. So for m n-bit numbers, the result will be at most ceil(log2(m)) + n bits long.

I am not sure how to write these unit tests, because group size varies drastically between tested curves, any suggestions are appreciated.

Pratyush commented 1 year ago

Thanks for the fix!

Pratyush commented 1 year ago

Re: tests, we don't need to test every edge case (as that is infeasible in this case anyway), so we can just focus on a good number of inputs (say, 25), and a single field (say bls12_381::Fr).