aboutsummaryrefslogtreecommitdiff
path: root/src/math/random.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/random.h')
-rw-r--r--src/math/random.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/math/random.h b/src/math/random.h
index de03abb..1152bb5 100644
--- a/src/math/random.h
+++ b/src/math/random.h
@@ -11,10 +11,29 @@
#include <pari/pari.h>
#include <stdbool.h>
+/**
+ * @brief Init the PARI-GP random generator.
+ *
+ * Initializes the PARI-GP random generator, tries to do so from
+ * cryptographically strong sources(/dev/urandom) at first but falls back on
+ * clock_gettime and {@link time(NULL)}.
+ *
+ * @return Whether the initialization was successful.
+ */
bool random_init(void);
+/**
+ * @brief Generate random <code>bits</code> sized prime.
+ * @param bits the size of the prime to generate
+ * @return a random prime in range [2^(bits - 1), 2^bits]
+ */
GEN random_prime(unsigned long bits);
+/**
+ * @brief Generate random <code>bits</code> sized integer.
+ * @param bits the size of the integer to generate
+ * @return a random integer in range [2^(bits - 1), 2^bits]
+ */
GEN random_int(unsigned long bits);
#endif // ECGEN_RANDOM_H