Crypto++  8.8
Free C++ class library of cryptographic schemes
Public Member Functions | List of all members
PrimeAndGenerator Class Reference

Generator of prime numbers of special forms. More...

Public Member Functions

 PrimeAndGenerator ()
 Construct a PrimeAndGenerator.
 
 PrimeAndGenerator (signed int delta, RandomNumberGenerator &rng, unsigned int pbits)
 Construct a PrimeAndGenerator. More...
 
 PrimeAndGenerator (signed int delta, RandomNumberGenerator &rng, unsigned int pbits, unsigned qbits)
 Construct a PrimeAndGenerator. More...
 
void Generate (signed int delta, RandomNumberGenerator &rng, unsigned int pbits, unsigned qbits)
 Generate a Prime and Generator. More...
 
const IntegerPrime () const
 Retrieve first prime. More...
 
const IntegerSubPrime () const
 Retrieve second prime. More...
 
const IntegerGenerator () const
 Retrieve the generator. More...
 

Detailed Description

Generator of prime numbers of special forms.

Definition at line 263 of file nbtheory.h.

Constructor & Destructor Documentation

◆ PrimeAndGenerator() [1/2]

PrimeAndGenerator::PrimeAndGenerator ( signed int  delta,
RandomNumberGenerator rng,
unsigned int  pbits 
)
inline

Construct a PrimeAndGenerator.

Parameters
delta+1 or -1
rnga RandomNumberGenerator derived class
pbitsthe number of bits in the prime p

PrimeAndGenerator() generates a random prime p of the form 2*q+delta, where delta is 1 or -1 and q is also prime. Internally the constructor calls Generate(delta, rng, pbits, pbits-1).

Precondition
pbits > 5
Warning
This PrimeAndGenerator() is slow because primes of this form are harder to find.

Definition at line 277 of file nbtheory.h.

◆ PrimeAndGenerator() [2/2]

PrimeAndGenerator::PrimeAndGenerator ( signed int  delta,
RandomNumberGenerator rng,
unsigned int  pbits,
unsigned  qbits 
)
inline

Construct a PrimeAndGenerator.

Parameters
delta+1 or -1
rnga RandomNumberGenerator derived class
pbitsthe number of bits in the prime p
qbitsthe number of bits in the prime q

PrimeAndGenerator() generates a random prime p of the form 2*r*q+delta, where q is also prime. Internally the constructor calls Generate(delta, rng, pbits, qbits).

Precondition
qbits > 4 && pbits > qbits

Definition at line 288 of file nbtheory.h.

Member Function Documentation

◆ Generate()

void PrimeAndGenerator::Generate ( signed int  delta,
RandomNumberGenerator rng,
unsigned int  pbits,
unsigned  qbits 
)

Generate a Prime and Generator.

Parameters
delta+1 or -1
rnga RandomNumberGenerator derived class
pbitsthe number of bits in the prime p
qbitsthe number of bits in the prime q

Generate() generates a random prime p of the form 2*r*q+delta, where q is also prime.

◆ Prime()

const Integer& PrimeAndGenerator::Prime ( ) const
inline

Retrieve first prime.

Returns
Prime() returns the prime p.

Definition at line 301 of file nbtheory.h.

◆ SubPrime()

const Integer& PrimeAndGenerator::SubPrime ( ) const
inline

Retrieve second prime.

Returns
SubPrime() returns the prime q.

Definition at line 305 of file nbtheory.h.

◆ Generator()

const Integer& PrimeAndGenerator::Generator ( ) const
inline

Retrieve the generator.

Returns
Generator() returns the generator g.

Definition at line 309 of file nbtheory.h.


The documentation for this class was generated from the following file: