diff --git a/crates/mpz-common/Cargo.toml b/crates/mpz-common/Cargo.toml index 7d057cc4..2dd1e3f5 100644 --- a/crates/mpz-common/Cargo.toml +++ b/crates/mpz-common/Cargo.toml @@ -25,7 +25,7 @@ serde = { workspace = true, features = ["derive"] } pollster.workspace = true rayon = { workspace = true, optional = true } cfg-if.workspace = true -tokio = { workspace = true, optional = true, default-features = false } +tokio = { workspace = true, optional = true } [dev-dependencies] tokio = { workspace = true, features = [ diff --git a/crates/mpz-common/src/cpu.rs b/crates/mpz-common/src/cpu.rs index 7cc4766c..e161a1dd 100644 --- a/crates/mpz-common/src/cpu.rs +++ b/crates/mpz-common/src/cpu.rs @@ -33,12 +33,12 @@ mod st { /// Executes a closure on the CPU backend. #[inline] - pub fn blocking(f: F) -> impl Future + Send + pub async fn blocking(f: F) -> R where F: FnOnce() -> R + Send + 'static, R: Send + 'static, { - async move { f() } + f() } } @@ -88,18 +88,16 @@ mod rayon_backend { } /// Executes a closure on the CPU backend. - pub fn blocking(f: F) -> impl Future + Send + pub async fn blocking(f: F) -> R where F: FnOnce() -> R + Send + 'static, R: Send + 'static, { - async move { - let (sender, receiver) = oneshot::channel(); - rayon::spawn(move || { - _ = sender.send(f()); - }); - receiver.await.expect("worker thread does not drop channel") - } + let (sender, receiver) = oneshot::channel(); + rayon::spawn(move || { + _ = sender.send(f()); + }); + receiver.await.expect("worker thread does not drop channel") } } diff --git a/crates/mpz-common/src/id.rs b/crates/mpz-common/src/id.rs index 42d7e55b..5344df68 100644 --- a/crates/mpz-common/src/id.rs +++ b/crates/mpz-common/src/id.rs @@ -83,6 +83,7 @@ pub struct Counter(u32); impl Counter { /// Increments the counter in place, returning the previous value. + #[allow(clippy::should_implement_trait)] pub fn next(&mut self) -> Self { let prev = self.0; self.0 += 1; diff --git a/crates/mpz-fields/src/lib.rs b/crates/mpz-fields/src/lib.rs index d71956d8..041a83c7 100644 --- a/crates/mpz-fields/src/lib.rs +++ b/crates/mpz-fields/src/lib.rs @@ -164,6 +164,6 @@ mod tests { assert!(GetBit::::get_bit(&a, 0)); assert_eq!(b, T::two_pow(T::BIT_SIZE as u32 - 1)); - assert!(GetBit::::get_bit(&b, (T::BIT_SIZE - 1) as usize)); + assert!(GetBit::::get_bit(&b, T::BIT_SIZE - 1)); } } diff --git a/crates/mpz-garble-core/src/circuit.rs b/crates/mpz-garble-core/src/circuit.rs index da8fe499..e2457b82 100644 --- a/crates/mpz-garble-core/src/circuit.rs +++ b/crates/mpz-garble-core/src/circuit.rs @@ -19,7 +19,7 @@ impl EncryptedGate { Self(inner) } - pub(crate) fn to_bytes(&self) -> [u8; 32] { + pub(crate) fn to_bytes(self) -> [u8; 32] { let mut bytes = [0u8; 32]; bytes[..16].copy_from_slice(&self.0[0].to_bytes()); bytes[16..].copy_from_slice(&self.0[1].to_bytes()); diff --git a/crates/mpz-garble-core/src/evaluator.rs b/crates/mpz-garble-core/src/evaluator.rs index 9ea29035..f503ef0e 100644 --- a/crates/mpz-garble-core/src/evaluator.rs +++ b/crates/mpz-garble-core/src/evaluator.rs @@ -68,20 +68,12 @@ pub struct EvaluatorOutput { } /// Garbled circuit evaluator. -#[derive(Debug)] +#[derive(Debug, Default)] pub struct Evaluator { /// Buffer for the active labels. buffer: Vec