defund / coppersmith

Coppersmith's method for multivariate polynomials
148 stars 10 forks source link

Cannot divide by leading coefficient in non-integral domain #2

Open user202729 opened 10 months ago

user202729 commented 10 months ago

If I do, for example,

R.<x, y> = Integers(6)[]
small_roots(x, (5, 5))

I get an error:

TypeError: self must be an integral domain.

(I'm not sure why it does not happen when N is a product of two large primes.)

Anyway, I think it's safer to modify the code as follows:

-   f /= f.coefficients().pop(0)
+   leading = 1 / f.coefficients().pop(0)
+   f = f.map_coefficients(lambda x: x * leading)

The code is functionally equivalent, and does not hit the aforementioned error.