Skip to content

Commit

Permalink
add rayon lib, use par_iter for encrypt_vote fn (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Leshiy authored Oct 29, 2024
1 parent 2f9277f commit 874b506
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions rust/catalyst-voting/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ rand_chacha = "0.3.1"
curve25519-dalek = { version = "4.1.3", features = ["digest", "rand_core"] }
ed25519-dalek = { version = "2.1.1", features = ["rand_core"] }
blake2b_simd = "1.0.2"
rayon = "1.10.0"

[dev-dependencies]
criterion = "0.5.1"
Expand Down
5 changes: 3 additions & 2 deletions rust/catalyst-voting/src/vote_protocol/voter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod proof;

use anyhow::{anyhow, bail, ensure};
use rand_core::CryptoRngCore;
use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator};

use super::committee::{ElectionPublicKey, ElectionSecretKey};
use crate::crypto::{
Expand Down Expand Up @@ -97,8 +98,8 @@ pub fn encrypt_vote<R: CryptoRngCore>(

let unit_vector = vote.to_unit_vector();
let ciphers = unit_vector
.iter()
.zip(randomness.0.iter())
.par_iter()
.zip(randomness.0.par_iter())
.map(|(m, r)| encrypt(m, &public_key.0, r))
.collect();

Expand Down

0 comments on commit 874b506

Please sign in to comment.