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

Add primality testing #714

Open
atomb opened this issue May 4, 2020 · 4 comments
Open

Add primality testing #714

atomb opened this issue May 4, 2020 · 4 comments
Labels
design needed We need to specify precisely what we want feature request Asking for new or improved functionality

Comments

@atomb
Copy link
Contributor

atomb commented May 4, 2020

Many bits of public-key cryptography use integers modulo primes as their core mathematical foundation, and involve operations that are only well-defined for groups of prime order. For such operations, and even just documentation, it may be useful to have the ability to test whether numbers are prime within Cryptol. This may be especially useful at the type level, but once it's implemented we may want to expose it at the value level, too.

Some existing Haskell packages support both probabilistic and certified primality checking. The former is generally fast enough for regular use. The latter can be very slow for large primes, but is perhaps still useful sometimes.

The arithmoi package is large and complex, but does what we need. Other, simpler packages might also be available.

@brianhuffman
Copy link
Contributor

gmp provides primality tests, so it seems like there ought to be a binding for primality testing for ghc's gmp-based Integer type.

@atomb atomb added this to the 3.0.0 milestone May 5, 2020
@robdockins robdockins added the feature request Asking for new or improved functionality label Jun 5, 2020
robdockins referenced this issue in GaloisInc/cryptol-specs Jun 22, 2020
…ible

with Cryptol changes.

At the same time, fix a bug in the `ec_decompress`, and add
a property for testing it.
@robdockins
Copy link
Contributor

CF #882, which implements the primality constraint in the type system and finite field inverses.

@robdockins robdockins added the design needed We need to specify precisely what we want label Sep 30, 2020
@robdockins
Copy link
Contributor

With the merge of #882, we now have a prime constraint at the type level, which asserts the primality of a numeric type, and allows Z p to inhabit the Field class for prime p. The constraint uses the probable-prime test from GMP to implement the check.

Certainly, we can expose this capability at the value level, but we should spend some time thinking about the design for this feature. Are probable prime tests enough, or do we want certified primes? If certified, do we want to produce checkable certificates? Do we also want prime sampling/generation algorithms? If so, which ones? At the moment, it isn't clear to me what is actually useful to have.

@robdockins
Copy link
Contributor

I think we can remove this ticket from the 2.10 milestone, as the work on the prime constraint is done and merged, and we don't have a clear idea of what we need WRT value primitives for primality testing and generation.

@robdockins robdockins removed this from the 2.10.0 milestone Nov 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design needed We need to specify precisely what we want feature request Asking for new or improved functionality
Projects
None yet
Development

No branches or pull requests

3 participants