Fabcoin Core  0.16.2
P2P Digital Currency
Public Member Functions | Private Attributes | List of all members
PrimeAndGenerator Class Reference

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

#include <nbtheory.h>

Collaboration diagram for PrimeAndGenerator:
[legend]

Public Member Functions

 PrimeAndGenerator ()
 Construct a PrimeAndGenerator. More...
 
 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...
 

Private Attributes

Integer p
 
Integer q
 
Integer g
 

Detailed Description

Generator of prime numbers of special forms.

Definition at line 148 of file nbtheory.h.

Constructor & Destructor Documentation

PrimeAndGenerator::PrimeAndGenerator ( )
inline

Construct a PrimeAndGenerator.

Definition at line 152 of file nbtheory.h.

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.

Here is the call graph for this function:

Here is the caller graph for this function:

const Integer& PrimeAndGenerator::Generator ( ) const
inline

Retrieve the generator.

Returns
Generator() returns the the generator g.

Definition at line 194 of file nbtheory.h.

Here is the caller graph for this function:

const Integer& PrimeAndGenerator::Prime ( ) const
inline

Retrieve first prime.

Returns
Prime() returns the prime p.

Definition at line 186 of file nbtheory.h.

Here is the caller graph for this function:

const Integer& PrimeAndGenerator::SubPrime ( ) const
inline

Retrieve second prime.

Returns
SubPrime() returns the prime q.

Definition at line 190 of file nbtheory.h.

Here is the caller graph for this function:

Member Data Documentation

Integer PrimeAndGenerator::g
private

Definition at line 197 of file nbtheory.h.

Integer PrimeAndGenerator::p
private

Definition at line 197 of file nbtheory.h.

Integer PrimeAndGenerator::q
private

Definition at line 197 of file nbtheory.h.


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