Skip to content

Commit

Permalink
feat: mod exp in worker threads
Browse files Browse the repository at this point in the history
  • Loading branch information
0xWOLAND committed Nov 19, 2023
1 parent f0844cd commit 6e9f39c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ntt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ fn fft(inp: Vec<BigInt>, c: &Constants, w: BigInt) -> Vec<BigInt> {
let CHUNK_COUNT = 128;
let chunk_count = BigInt::from(CHUNK_COUNT);

(1..N / (2 * CHUNK_COUNT))
.for_each(|i| pre[i * CHUNK_COUNT] = w.mod_exp(BigInt::from(i) * chunk_count, MOD));
pre.par_chunks_mut(CHUNK_COUNT)
.enumerate()
.for_each(|(i, arr)| arr[0] = w.mod_exp(BigInt::from(i) * chunk_count, MOD));
pre.par_chunks_mut(CHUNK_COUNT).for_each(|x| {
(1..x.len()).for_each(|y| {
let _x = x.to_vec();
Expand Down
5 changes: 5 additions & 0 deletions src/numbers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ impl BigInt {
v: U256::random(&mut OsRng),
}
}

pub fn reverse(&self) -> BigInt {
let mut v = self.v;
BigInt { v }
}
}

impl From<u16> for BigInt {
Expand Down

0 comments on commit 6e9f39c

Please sign in to comment.