Skip to content

Commit

Permalink
speeds up dh multi encrypt by using chunks_exact
Browse files Browse the repository at this point in the history
  • Loading branch information
seanwatters committed Feb 27, 2024
1 parent bbe49da commit cc45f06
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -14,7 +14,7 @@ license = "MIT"
name = "rgp"
readme = "README.md"
repository = "https://github.com/seanwatters/rgp"
version = "0.3.1"
version = "0.3.2"

[dependencies]
blake2 = "0.10.6"
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/modes/dh.rs
Expand Up @@ -115,9 +115,9 @@ fn dh_encrypt_keys(
let mut keys = vec![0u8; KEY_SIZE * keys_count];

#[cfg(feature = "multi-thread")]
let chunks = keys.par_chunks_mut(KEY_SIZE);
let chunks = keys.par_chunks_exact_mut(KEY_SIZE);
#[cfg(not(feature = "multi-thread"))]
let chunks = keys.chunks_mut(KEY_SIZE);
let chunks = keys.chunks_exact_mut(KEY_SIZE);

chunks.enumerate().for_each(|(i, chunk)| {
let mut key = GenericArray::from(priv_key.diffie_hellman(&pub_keys[i].into()).to_bytes());
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/modes/kem.rs
Expand Up @@ -107,7 +107,7 @@ pub fn generate_kem_keys() -> ([u8; KEM_SECRET_KEY_SIZE], [u8; KEM_PUB_KEY_SIZE]
(*secret_key.as_array(), *pub_key.as_array())
}

/// for reading a large volume of McEliece public keys
/// for reading a large volume of Classic McEliece public keys
pub struct KemKeyReader<R: Read> {
pub reader: BufReader<R>,

Expand Down

0 comments on commit cc45f06

Please sign in to comment.