Skip to content

Commit 874b506

Browse files
authored
add rayon lib, use par_iter for encrypt_vote fn (#71)
1 parent 2f9277f commit 874b506

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

rust/catalyst-voting/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ rand_chacha = "0.3.1"
2323
curve25519-dalek = { version = "4.1.3", features = ["digest", "rand_core"] }
2424
ed25519-dalek = { version = "2.1.1", features = ["rand_core"] }
2525
blake2b_simd = "1.0.2"
26+
rayon = "1.10.0"
2627

2728
[dev-dependencies]
2829
criterion = "0.5.1"

rust/catalyst-voting/src/vote_protocol/voter/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub mod proof;
55

66
use anyhow::{anyhow, bail, ensure};
77
use rand_core::CryptoRngCore;
8+
use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator};
89

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

9899
let unit_vector = vote.to_unit_vector();
99100
let ciphers = unit_vector
100-
.iter()
101-
.zip(randomness.0.iter())
101+
.par_iter()
102+
.zip(randomness.0.par_iter())
102103
.map(|(m, r)| encrypt(m, &public_key.0, r))
103104
.collect();
104105

0 commit comments

Comments
 (0)