helib::RandomState Class Reference

Facility for "restoring" the NTL PRG state. More...

#include <NumbTh.h>

Public Member Functions

 RandomState ()
 
void restore ()
 Restore the PRG state of NTL. More...
 
 ~RandomState ()
 

Detailed Description

Facility for "restoring" the NTL PRG state.

NTL's random number generation facility is pretty limited, and does not provide a way to save/restore the state of a pseudo-random stream. This class gives us that ability: Constructing a RandomState object uses the PRG to generate 512 bits and stores them. Upon destruction (or an explicit call to restore()), these bits are used to re-set the seed of the PRG. A typical usage of the class is as follows:

{
RandomState r; // save the random state
SetSeed(something); // set the PRG seed to something
... // more code that uses the new PRG seed
} // The destructor is called implicitly, PRG state is restored

Constructor & Destructor Documentation

◆ RandomState()

helib::RandomState::RandomState ( )
inline

◆ ~RandomState()

helib::RandomState::~RandomState ( )
inline

Member Function Documentation

◆ restore()

void helib::RandomState::restore ( )
inline

Restore the PRG state of NTL.

RandomState()
Definition: NumbTh.h:588