Skip to content
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

Fast F2 polynomial arithmetic #923

Merged
merged 8 commits into from
Oct 27, 2020
Merged

Fast F2 polynomial arithmetic #923

merged 8 commits into from
Oct 27, 2020

Conversation

robdockins
Copy link
Contributor

Add new primitives for pmult, pdiv and pmod. Currently, these are exposed in the prelude via new symbols named fast_pmult, fast_pdiv and fast_pmod. The plan is to relocate the current in-Cryptol implementations to a reference implementation module and continue to use these definitions for the symbolic backends, along the lines suggested in #922.

These still require additional testing, but seem to work correctly on a limited selection of tests.

@@ -257,12 +260,22 @@ prepareQuery sym ProverCommand { .. } =
simulate args =
do let lPutStrLn = M.withLogger logPutStrLn
when pcVerbose (lPutStrLn "Simulating...")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This following sequence feels like a bit of a hack. Binding the top-level decls of the module using EWhere does seem to work, but feels pretty dirty. Any ideas how to handle this better, @brianhuffman, @yav?

@robdockins robdockins marked this pull request as ready for review October 11, 2020 21:56
@robdockins
Copy link
Contributor Author

I haven't thought of any especially better way to handle the primitive redirection. We'll just have to be sure we don't rely too much on CAFs being evaluated only once.

@robdockins robdockins force-pushed the fast-f2 branch 2 times, most recently from cfee6a7 to 7bf93c1 Compare October 19, 2020 17:04
Ths allows larger concrete bitvector values before falling back on
the "sparse" representation.  This is a bit of a bandaid for the
underlying problem, which I have some ideas how to fix later.
a new `Cryptol::Reference` module. Change the evaluator API slightly
so that primitives can be bound to expressions, in addition to values.
We can use this to inject the reference implementations of the above
operations into the symbolic evaluators.

Because of the exact way evaluation environments are piped around,
the bound expression will be evaluated in the environment that
the primitive symbol is declared.  So, we can't just reference
the name of the reference implementation when we inject it.
Instead, we abuse the `EWhere` construct to add local definitions
corresponding to the entire module.  This works, but is a bit
unsatisfying, as any top-level CAFs will not be shared across
different invocations.  This doesn't matter for these
functions, but might for e.g, AES.
the reference implementations.  The `:check` commands are really the
only ones of interest for correctness of the algorithms.
The `:prove` commands end up just checking
the reference implementation against itself, but this checks that the
primitive redirection code is working properly.
"Loading module" message.  This is used when we implicitly load
reference implementation modules.
@robdockins robdockins merged commit 246b677 into master Oct 27, 2020
robdockins added a commit to GaloisInc/saw-core that referenced this pull request Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant