PBC Library Manual 0.5.11 - Stanford Crypto Group
PBC Library Manual 0.5.11 - Stanford Crypto Group
PBC Library Manual 0.5.11 - Stanford Crypto Group
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Chapter 6. Other functions<br />
Random number generation, memory allocation, logging.<br />
6.1. Random bits<br />
The first time <strong>PBC</strong> is asked to generate a random number, the library will try to open the file<br />
/dev/urandom as a source of random bits. If this fails, <strong>PBC</strong> falls back to a deterministic random<br />
number generator (which is of course completely useless for cryptography).<br />
It is possible to change the file used for random bits. Also, explicitly selecting the deterministic random<br />
number generator will suppress the warning.<br />
On Windows, by default, <strong>PBC</strong> uses the Microsoft <strong>Crypto</strong> API to generate random bits.<br />
void pbc_random_set_file(char *filename)<br />
Sets filename as a source of random bytes. For example, on Linux one might use /dev/random.<br />
void pbc_random_set_deterministic(unsigned int seed)<br />
Uses a determinstic random number generator, seeded with seed.<br />
void pbc_random_set_function(void (*fun)(mpz_t, mpz_t, void *), void *data)<br />
Uses given function as a random number generator.<br />
void pbc_mpz_random(mpz_t z, mpz_t limit)<br />
Selects a random z that is less than limit.<br />
void pbc_mpz_randomb(mpz_t z, unsigned int bits)<br />
28