Documentation
¶
Overview ¶
Package safeprime computes safe primes, i.e. primes of the form 2p+1 where p is also prime.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
Generate a safe prime of the given size, using the fact that:
If q is prime and 2^(2q) = 1 mod (2q+1), then 2q+1 is a safe prime.
We take a random bigint q; if the above formula holds and q is prime, then we return 2q+1. (See https://www.ijipbangalore.org/abstracts_2(1)/p5.pdf and https://groups.google.com/group/sci.crypt/msg/34c4abf63568a8eb)
In order to cancel the generation algorithm, send a struct{} on the stop parameter or close() it. (Passing nil is allowed; then the algorithm cannot be cancelled).
func GenerateConcurrent ¶
GenerateConcurrent concurrently and continuously generates safeprimes on all CPU cores, until the stop channel receives a struct or is closed. If an error is encountered, generation is stopped in all goroutines, and the error is sent on the second return parameter.
func ProbablySafePrime ¶
ProbablySafePrime reports whether x is probably safe prime, by calling big.Int.ProbablyPrime(n) on x as well as on (x-1)/2.
If x is safe prime, ProbablySafePrime returns true. If x is chosen randomly and not safe prime, ProbablyPrime probably returns false.
Types ¶
This section is empty.