Crypto++ 8.9
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...

#include <nbtheory.h>

Public Member Functions

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

Detailed Description

Generator of prime numbers of special forms.

Definition at line 266 of file nbtheory.h.

Constructor & Destructor Documentation

◆ PrimeAndGenerator() [1/3]

PrimeAndGenerator::PrimeAndGenerator ( )
inline

Construct a PrimeAndGenerator.

Definition at line 270 of file nbtheory.h.

◆ PrimeAndGenerator() [2/3]

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

◆ PrimeAndGenerator() [3/3]

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

◆ SubPrime()

const Integer & PrimeAndGenerator::SubPrime ( ) const
inline

Retrieve second prime.

Returns
SubPrime() returns the prime q.

Definition at line 308 of file nbtheory.h.

◆ Generator()

const Integer & PrimeAndGenerator::Generator ( ) const
inline

Retrieve the generator.

Returns
Generator() returns the generator g.

Definition at line 312 of file nbtheory.h.


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