#ifndef PRIMEGEN_H
#define	PRIMEGEN_H

#include <NTL/ZZ.h>
using namespace NTL;

#include <print.h>

/*!
\brief  Generate n-bit prime numbers.

 The library could do many of these functions but these functions 
 are so easily
 to implement that another library could be easily used instead, so
 the library calls are isolated. 

ie ZZ could be
 templated, random bit generation implemented and prime testing
 implemented then the only dependency is ZZ.
*/
class largePrimeGenerator
{
  long int * v;
  uintc vmax;
public:

  /** Constructor generates a small prime table. */
  largePrimeGenerator();
  ~largePrimeGenerator();

  // Note findprime_randomly is faster than 
  //   findprime_sequentially in general.

  /* Randomly choose large number, then sequentially search
     till a prime is encountered. */
  void findprime_sequentially( ZZ & n, uintc nbits ) const;
  /** Keep looking for primes randomly till one found. */
  void findprime_randomly( ZZ & n, uintc nbits ) const;

  /** Statistical prime test. Do not use with small primes. */
  bool const isprime( ZZ const & n ) const;

  /** n is >= 2^nbits. */
  void ensurenbits( ZZ & n, uintc nbits ) const;
};



#endif



