mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
wip on RLWE
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use rand_chacha::rand_core::SeedableRng;
|
||||
use rand_chacha::ChaCha8Rng;
|
||||
use rand_core::RngCore;
|
||||
use rand_core::{OsRng, RngCore};
|
||||
|
||||
const MAXF64: f64 = 9007199254740992.0;
|
||||
|
||||
@@ -8,6 +8,12 @@ pub struct Source {
|
||||
source: ChaCha8Rng,
|
||||
}
|
||||
|
||||
pub fn new_seed() -> [u8; 32] {
|
||||
let mut seed = [0u8; 32];
|
||||
OsRng.fill_bytes(&mut seed);
|
||||
seed
|
||||
}
|
||||
|
||||
impl Source {
|
||||
pub fn new(seed: [u8; 32]) -> Source {
|
||||
Source {
|
||||
@@ -21,6 +27,10 @@ impl Source {
|
||||
seed
|
||||
}
|
||||
|
||||
pub fn branch(&mut self) -> Self {
|
||||
Source::new(self.new_seed())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn next_u64n(&mut self, max: u64, mask: u64) -> u64 {
|
||||
let mut x: u64 = self.next_u64() & mask;
|
||||
|
||||
Reference in New Issue
Block a user