-
Notifications
You must be signed in to change notification settings - Fork 147
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
Verified Bedrock2 code for Number-Theoretic Transform #1997
base: master
Are you sure you want to change the base?
Conversation
In principle, I am interested in theory of polynomials and NTTs, as well as a Bedrock2 implementation. The main reason I have not undertaken it myself is simply the amount of work I expect it to take. Already polynomial CRT is impressive, let alone the rest of the PR. FYI, there is another exploration of NTT in Bedrock2 by @lukaszobernig at master...lukaszobernig:fiat-crypto:ntt#diff-2ba131d0bae59c3f1d7bf36175bb93917df54b968bb82545a3ad793cbecee00f As for what to merge, and in what shape, I think the main considerations are that (1) I want to only merge things I can see myself recommending, either for use or study and (2) it would be really cool to have something on NTTs, and fiat-crypto seems like a good place for this work to live. In that spirit, let me raise some high-level questions
Overall, this is an ambitious and impressive project. I would like to get something like this in, but it would require a fair bit of work and more tight collaboration between us. Please let me know what you think; we could also do a call if that sounds helpful to you. |
The PR is still in a bit of a rough state, but I'm opening it to see if there is interest in adding it.
The Number-Theoretic Transform is a technique to accelerate polynomial multiplications used in recent lattice-based cryptography for PQC.
This PR defines:
Polynomial.v
CyclotomicDecomposition.v
which defines an homomorphism from a typePquotl (cyclotomic_decomposition n 0)
toPquotl (cyclotomic_decomposition n k)
wherePquotl ql
is defined asPquotl (ql: list P): Type := { pl: list P | List.Forall2 (fun p q => Peq p (Pmod p q)) pl ql }
, andcyclotomic_decomposition n i
is the i-th layer decomposition ofX^n + 1
. It also defines various optimizations for the NTT.RupicolaNTT.v
BedrockNTT.v
, I initially tried to automatically synthesize the code using Rupicola, but ended up doing the proof manuallyRupicolaBarrettReduction.v
andRupicolaMontgomeryArithmetic.v
MLKEM.v
andMLDSA.v
.I believe the C code should look like what someone would write after reading the NIST standards with no other reference. In terms of performance, this is slower than the handwritten C reference implementations for Kyber/Dilithium which use a so-called centered signed representation for field elements, and delay reduction of the coefficients to the end of the NTT instead of systematically doing it at each step like the synthesised code.