-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polynomial Arithmetic #1340
Comments
Related discussion here: #763 |
A generic polynomial multiplication function for arbitrary rings can be defined in Cryptol like this:
Here's a correctness property to go with it:
@smithnormform: Would something like this be sufficient for your needs? If so, then no changes to Cryptol itself are necessary. If you need something with better asymptotic performance, then we could probably implement a more optimized version using a Karatsuba algorithm. (The code for this would be nicer if we implemented #701, but would probably still be possible with Cryptol as-is.) I think it's likely that we can get something that works well enough without adding any new primitives. |
This is faster, but unfortunately not fast enough for the application. I think a Karatsuba algorithm is worth a shot! If the ring is Z or Z p then Fast Fourier Transform methods are often used for speedups, although these methods might cause issues with the SMT solvers. Whatever we come up with, it may be beneficial to place all of our results in a Polynomial package. |
I think built-in support for polynomials is necessary to support some PQ crypto such as NTRU and BFV. Both of those algorithms are elegant to spec in Cryptol excepting the polynomial arithmetic. Also, the solutions provided here are prohibitively slow on real parameters. I like the suggestion of beefing-up the current polynomial arithmetic commands ( (@brianhuffman this is an opportunity to take back |
Some time ago, I worked up a basic Karatsuba multiplier for bitvectors. It would probably not be too hard to rework it for polynomial rings. https://github.com/GaloisInc/cryptol/blob/master/examples/Karatsuba.cry It would be interesting to know if the asymptotic behavior or the constant factors are a bigger contributor at realistic parameter sizes. |
Here's a Karatsuba polynomial multiplier that I put together:
I chose a cutoff of 50 to switch to the naive FFT-based algorithms could certainly be faster with better asymptotic behavior for very large polynomials, but unfortunately such algorithms can't be used polynomial multiplication over an arbitrary |
Currently Cryptol has built-in polynomial arithmetic functions like pmult, pmod, and pdiv. However, pmult is restricted to polynomials with Bit coefficients. It would nice if Cryptol supported optimized primitive functions like pmult for polynomials with Z p or Integer coefficients.
The text was updated successfully, but these errors were encountered: