-
Notifications
You must be signed in to change notification settings - Fork 1
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
Comments on new ntt #4
Comments
Many thanks for the comments. Note that some of the code (e.g. the "bitrev" function and the "ParametricNTT" function) were written by Galois (and copied here from the cryptol-specs repo just for ease of testing and stating the equivalence properties.) I won't be modifying that code, but we can pass those comments back to Galois, of course... |
I hope to contribute this work to the cryptol-specs repo, so it will naturally fit into their module system. |
I have also just commited a significant simplification of the ct_butterfly and gs_butterfly functions - I realized that the additional decomposition in ct_lowerhalf and ct_upperhalf was not really necessary. The specification of ct_butterfly now also closely matches the inner loop of Algorithm 8 in FIPS 203, which is a pleasant side-effect. Reference code updates to match are also now in entt.adb |
Using
|
Where is the |
You can also try:
|
OK... |
@rod-chapman It is super cool that you established the equivalence between the slow and fast versions. Overall looks good to me and I just have some high-level comments. I agree with @weaversa that the code should be in a module when integrated into Cryptol-specs. Even better, it could take use of Cryptol's module system when referencing exiting functions like Another high-level comment, I think it will be easier to read if references or comments are added especially for constant numbers. For example, It is unclear how |
Thanks for the comments.
|
I have tidied up a bit more - adopted the doc-string format for the property proof commands, and removed redundant parentheses. I await comms from Galois about how they prefer to integrate into cryptol-specs |
I have opened a PR to integrate this code into Galois' cryptol-specs repo. |
This is great work @rod-chapman!
My main suggestion is to add documentation. Cryptol supports doc-strings - every definition should have one that describes the intent of the function along w/ citations to appropriate reference documents. For example:
LibMLKEM/spark_ada/experimental/ntt.cry
Lines 23 to 24 in 6d192dd
What is
BitRev7
? Why7
when the input and outputs are both8
bits? On the face it looks like there could be a typo. If the function was documented and a reference provided, understanding could be given rather than inferred/reverse engineered.Otherwise, some nit-picky things --
Cryptol has a robust (@WeeknightMVP 😄) module system. The first line should be something like
Or where ever you want it to live - could be as simple as:
But it should have one!
I suggest being consistent with names and extensions thereof. For example,
LibMLKEM/spark_ada/experimental/ntt.cry
Lines 8 to 9 in 6d192dd
I suggest either
or
Both camelCase and snake_case are being used. I suggest you pick one. It's ideally best to follow the naming convention in whatever document you are following to create a specification. That way developers will have an easier time using the Cryptol spec along w/ other reference documentation to assist their development work.
Cryptol will soon have the ability to check properties in doc-strings (a la
cargo test
) -- GaloisInc/cryptol#1682So, properties like the following:
LibMLKEM/spark_ada/experimental/ntt.cry
Lines 44 to 49 in 6d192dd
could be better supported like so:
It's also suggested to write properties (when possible) in the style of a rewrite rule. This assists with any future effort where
saw
would use such a property as a lemma to prove a larger property.There are unnecessary (and distracting) parens in places. Here is an example:
LibMLKEM/spark_ada/experimental/ntt.cry
Line 92 in 6d192dd
This could instead be:
Suggest removing miscellaneous newlines, for example:
LibMLKEM/spark_ada/experimental/ntt.cry
Lines 180 to 181 in 6d192dd
Suggest exploring Cryptol's
generate
syntactic sugar (https://github.com/GaloisInc/cryptol/blob/f5fa503b1898e8bb9dc3358ada036adb4c54b832/docs/RefMan/BasicTypes.rst?plain=1#L161-L163) to simplify some expressions. For example:LibMLKEM/spark_ada/experimental/ntt.cry
Lines 27 to 30 in 6d192dd
How cool is that!
It might be worthwhile to add a comment saying that
coerceSize
is necessary here until the issues related to GaloisInc/cryptol#1392 are addressed. That way, someone may be able to remove this blight at a later date.The text was updated successfully, but these errors were encountered: