Some algorithms require a quadratic nonresidue in a given
field. These are computed lazily: The first time a quadratic
nonresidue is requested, one is generated at random, using the
same source of random bits as other PBC random functions.
[Which reminds me, should I get rid of the nqr
field and instead have it as part of the
data
field in struct field_s?]
In fieldquadratic.c
, a
quadratic field extension is constructed with a square root of
this randomly generated quadratic nonresidue in the base field.
Thus for a nondeterminstic source of random bits, the same
field may be constructed differently on different runs.
To construct the same field the same way every time, one
must record the quadratic nonresidue generated from one run,
and call field_set_nqr()
every
time this particular construction of a quadratic field
extension is desired. Another use for this function is to save
time by setting the quadratic nonresidue to some precomputed
value.
Similarly, for higher degree extensions, a random irreducible polynomial may be chosen to construct it, but this must be recorded if the same construction is later required.
This happens behind the scenes in PBC.