Inversed-Tech / eyelid

Private iris matching
Apache License 2.0
0 stars 0 forks source link

Manual polynomial modulus and ark_poly::divide_with_q_and_r produce different constant terms #17

Closed teor2345 closed 4 months ago

teor2345 commented 4 months ago

In #16 I benchmarked two different polynomial modulus implementations. But they produce different constant terms in the polynomial remainder. (All other terms are the same.)

This seems like it could be a bug in the manual polynomial modulus implementation.

Using #16 and a Fq8 test field with degree 4, I get this test failure output:

Testing Cyclotomic multiplication: polynomial/2 random polys of degree N                           
thread 'main' panicked at eyelid-match-ops/src/primitives/poly.rs:63:5:                              
assertion `left == right` failed
  left:                                                                                              
BigInt([22]) +                                                                                       
BigInt([18]) * x + 
BigInt([57]) * x^2 +                                                                                 
BigInt([25]) * x^3                                                                                   
 right:                                                                                              
BigInt([86]) +                                                                                       
BigInt([18]) * x + 
BigInt([57]) * x^2 +                                                                                 
BigInt([25]) * x^3 

This is consistent with the full-resolution Fq79 test failure, which is too long to display here. Only the constant term is different in both tests.

See PR #19 for a Fq8 failure in CI, and PR #18 for a Fq79 failure in CI.