- Documentation
- Reference manual
 - Packages
- SWI-Prolog SSL Interface
- library(crypto): Cryptography and authentication library
 
 
 - SWI-Prolog SSL Interface
 
 
3.9 Number theory
This library provides operations from number theory that frequently arise in cryptographic applications, complementing the existing built-ins and GMP bindings:
- [det]crypto_modular_inverse(+X, +M, -Y)
 - Compute the modular multiplicative inverse of the integer X. Y is unified with an integer such that X*Y is congruent to 1 modulo M.
 - [det]crypto_generate_prime(+N, -P, +Options)
 - Generate a prime P with at least N bits. Options 
is a list of options. Currently, the only supported option is:
- safe(Boolean)
 - If Boolean is 
true(default isfalse), then a safe prime is generated. This means that P is of the form 2*Q + 1 where Q is also prime. 
 - [semidet]crypto_is_prime(+P, +Options)
 - True iff P passes a probabilistic primality test. Options 
is a list of options. Currently, the only supported option is:
- iterations(N)
 - N is the number of iterations that are performed. If this 
option is not specified, a number of iterations is used such that the 
probability of a false positive is at most 2
^(-80).