Crypto++  5.6.5
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 148 of file nbtheory.h.

Constructor & Destructor Documentation

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 162 of file nbtheory.h.

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 173 of file nbtheory.h.

Member Function Documentation

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.

Definition at line 1038 of file nbtheory.cpp.

const Integer& PrimeAndGenerator::Prime ( ) const
inline

Retrieve first prime.

Returns
Prime() returns the prime p.

Definition at line 186 of file nbtheory.h.

const Integer& PrimeAndGenerator::SubPrime ( ) const
inline

Retrieve second prime.

Returns
SubPrime() returns the prime q.

Definition at line 190 of file nbtheory.h.

const Integer& PrimeAndGenerator::Generator ( ) const
inline

Retrieve the generator.

Returns
Generator() returns the the generator g.

Definition at line 194 of file nbtheory.h.


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