Next: Some issues, Previous: I/O, Up: Preface
The G2HEC library uses NTL’s pseudo-random number generator for generating functions that output random values. It is recommended to override the default seed by calling
NTL::SetSeed( seed )
to set the PRNG seed using a ZZ
object seed
if you are to
do serious cryptographic applications which use the G2HEC’s randomness
functions.
The G2HEC library exports in include/g2hec_rand.h
a function
ZZ g2hec_rand()
,
which obtains a random ZZ
object of 128-bit integer by trying
to use the file /dev/urandom as a source of random bits; if it fails,
then 0 is returned.
User can set its own random seed, or call
NTL::SetSeed(g2hec_rand())
to generate one.
The class g2hcurve
has a member function to generate a random
valid genus 2 curve.
g2hcurve& random()
:
generates a random valid genus 2 curve.
The class divisor
has two member functions to generate random
valid divisors, if the associated curve is valid.
divisor& random()
:
If the associated curve is valid, sets the divisor to a random valid divisor of degree 2, i.e., \deg{u} = 2.
divisor& random(divdeg_t dgr)
:
If the associated curve is valid, sets divisor to a random valid divisor
of degree dgr
, where dgr
takes values 1 (DEGREE_1) or
2 (DEGREE_2).
Note that divisor.random()
never returns a unit divisor [1, 0].