From 648cccb77b8e56c6a6e843857205252626c29888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tancr=C3=A8de=20Lepoint?= Date: Thu, 8 Jan 2026 21:06:00 -0500 Subject: [PATCH 1/2] Clarify MSRV for workspace lints --- Cargo.toml | 9 ++++++++- README.md | 2 +- crates/fhe-math/benches/ntt.rs | 1 + crates/fhe-math/benches/rns.rs | 1 + crates/fhe-math/benches/rq.rs | 1 + crates/fhe-math/benches/zq.rs | 1 + crates/fhe-math/src/lib.rs | 1 - crates/fhe-math/src/rq/convert.rs | 2 ++ crates/fhe-math/src/rq/ops.rs | 1 + crates/fhe-traits/src/lib.rs | 1 - crates/fhe-util/src/lib.rs | 12 +++++++++++- crates/fhe/benches/bfv.rs | 1 + crates/fhe/benches/bfv_optimized_ops.rs | 1 + crates/fhe/benches/bfv_rgsw.rs | 1 + crates/fhe/examples/bfv_basic.rs | 1 + crates/fhe/examples/bfv_ops.rs | 1 + crates/fhe/examples/mulpir.rs | 1 + crates/fhe/examples/pir.rs | 1 + crates/fhe/examples/rgsw.rs | 1 + crates/fhe/examples/sealpir.rs | 1 + crates/fhe/examples/util.rs | 1 + crates/fhe/examples/voting.rs | 1 + crates/fhe/src/bfv/ciphertext.rs | 2 ++ crates/fhe/src/bfv/context/chain.rs | 1 + crates/fhe/src/bfv/parameters.rs | 2 ++ crates/fhe/src/lib.rs | 1 - crates/fhe/tests/unified_context_integration.rs | 2 ++ 27 files changed, 45 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1034db67..9ca16b0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,12 @@ authors = ["Tancrède Lepoint"] edition = "2021" repository = "https://github.com/tlepoint/fhe.rs" license = "MIT" -rust-version = "1.73" +rust-version = "1.89" # MSRV for workspace lints + +[workspace.lints.rust] +missing_docs = "warn" +unused_imports = "warn" +unused_must_use = "deny" [workspace.dependencies] clap = { version = "^4.5.53", features = ["derive"] } @@ -37,6 +42,8 @@ zeroize = "^1.8.2" zeroize_derive = "^1.4.2" [workspace.lints.clippy] +expect_used = "deny" +panic = "deny" indexing_slicing = "deny" fallible_impl_from = "deny" wildcard_enum_match_arm = "deny" diff --git a/README.md b/README.md index 25f64e48..40a10cb6 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ fhe-traits = "0.1.1" ## Minimum supported version / toolchain -Rust **1.73** or newer. +Rust **1.89** or newer (required for workspace lint configuration). ## ⚠️ Security / Stability diff --git a/crates/fhe-math/benches/ntt.rs b/crates/fhe-math/benches/ntt.rs index dc2dd579..096aebc5 100644 --- a/crates/fhe-math/benches/ntt.rs +++ b/crates/fhe-math/benches/ntt.rs @@ -1,5 +1,6 @@ // Allow indexing in benchmarks for convenience #![allow(clippy::indexing_slicing)] +#![allow(missing_docs)] use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use fhe_math::{ntt::NttOperator, zq::Modulus}; diff --git a/crates/fhe-math/benches/rns.rs b/crates/fhe-math/benches/rns.rs index d4dffbb2..6abd5a2b 100644 --- a/crates/fhe-math/benches/rns.rs +++ b/crates/fhe-math/benches/rns.rs @@ -1,5 +1,6 @@ // Allow indexing in benchmarks for convenience #![allow(clippy::indexing_slicing)] +#![allow(missing_docs)] use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use fhe_math::rns::{RnsContext, RnsScaler, ScalingFactor}; diff --git a/crates/fhe-math/benches/rq.rs b/crates/fhe-math/benches/rq.rs index dc857ce2..077c4720 100644 --- a/crates/fhe-math/benches/rq.rs +++ b/crates/fhe-math/benches/rq.rs @@ -1,5 +1,6 @@ // Allow indexing in benchmarks for convenience #![allow(clippy::indexing_slicing)] +#![allow(missing_docs)] use criterion::measurement::WallTime; use criterion::{criterion_group, criterion_main, BenchmarkGroup, BenchmarkId, Criterion}; diff --git a/crates/fhe-math/benches/zq.rs b/crates/fhe-math/benches/zq.rs index 9abdeb59..95cf60a5 100644 --- a/crates/fhe-math/benches/zq.rs +++ b/crates/fhe-math/benches/zq.rs @@ -1,5 +1,6 @@ // Allow indexing in benchmarks for convenience #![allow(clippy::indexing_slicing)] +#![allow(missing_docs)] use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use fhe_math::zq::Modulus; diff --git a/crates/fhe-math/src/lib.rs b/crates/fhe-math/src/lib.rs index 5cc2376c..4cd452c6 100644 --- a/crates/fhe-math/src/lib.rs +++ b/crates/fhe-math/src/lib.rs @@ -1,6 +1,5 @@ #![crate_name = "fhe_math"] #![crate_type = "lib"] -#![warn(missing_docs, unused_imports)] //! Mathematical utilities for the fhe.rs library. diff --git a/crates/fhe-math/src/rq/convert.rs b/crates/fhe-math/src/rq/convert.rs index c0799060..13f2bf28 100644 --- a/crates/fhe-math/src/rq/convert.rs +++ b/crates/fhe-math/src/rq/convert.rs @@ -434,6 +434,8 @@ impl From<&Poly> for Vec { #[cfg(test)] mod tests { + #![allow(clippy::expect_used)] + use crate::{ proto::rq::Rq, rq::{traits::TryConvertFrom, Context, Poly, Representation}, diff --git a/crates/fhe-math/src/rq/ops.rs b/crates/fhe-math/src/rq/ops.rs index 2269646f..ec8d5b54 100644 --- a/crates/fhe-math/src/rq/ops.rs +++ b/crates/fhe-math/src/rq/ops.rs @@ -110,6 +110,7 @@ impl Sub<&Poly> for &Poly { } impl MulAssign<&Poly> for Poly { + #[allow(clippy::panic)] fn mul_assign(&mut self, p: &Poly) { assert!(!p.has_lazy_coefficients); assert_ne!( diff --git a/crates/fhe-traits/src/lib.rs b/crates/fhe-traits/src/lib.rs index 2825d085..eca9594a 100644 --- a/crates/fhe-traits/src/lib.rs +++ b/crates/fhe-traits/src/lib.rs @@ -1,6 +1,5 @@ #![crate_name = "fhe_traits"] #![crate_type = "lib"] -#![warn(missing_docs, unused_imports)] //! Traits for Fully Homomorphic Encryption diff --git a/crates/fhe-util/src/lib.rs b/crates/fhe-util/src/lib.rs index 5d797d23..5f77ef19 100644 --- a/crates/fhe-util/src/lib.rs +++ b/crates/fhe-util/src/lib.rs @@ -1,6 +1,5 @@ #![crate_name = "fhe_util"] #![crate_type = "lib"] -#![warn(missing_docs, unused_imports)] //! Utilities for the fhe.rs library. @@ -57,6 +56,7 @@ pub fn sample_vec_cbd( /// Transcodes a vector of u64 of `nbits`-bit numbers into a vector of bytes. #[must_use] +#[allow(clippy::expect_used)] pub fn transcode_to_bytes(a: &[u64], nbits: usize) -> Vec { assert!(0 < nbits && nbits <= 64); @@ -96,6 +96,7 @@ pub fn transcode_to_bytes(a: &[u64], nbits: usize) -> Vec { /// Transcodes a vector of u8 into a vector of u64 of `nbits`-bit numbers. #[must_use] +#[allow(clippy::expect_used)] pub fn transcode_from_bytes(b: &[u8], nbits: usize) -> Vec { assert!(0 < nbits && nbits <= 64); let mask = (u64::MAX >> (64 - nbits)) as u128; @@ -134,6 +135,7 @@ pub fn transcode_from_bytes(b: &[u8], nbits: usize) -> Vec { /// Transcodes a vector of u64 of `input_nbits`-bit numbers into a vector of u64 /// of `output_nbits`-bit numbers. #[must_use] +#[allow(clippy::expect_used)] pub fn transcode_bidirectional(a: &[u64], input_nbits: usize, output_nbits: usize) -> Vec { assert!(0 < input_nbits && input_nbits <= 64); assert!(0 < output_nbits && output_nbits <= 64); @@ -281,6 +283,14 @@ mod tests { } } + #[test] + fn transcode_known_roundtrip() { + let input = vec![0x1u64, 0x2u64, 0x3u64, 0x4u64]; + let bytes = transcode_to_bytes(&input, 4); + let decoded = transcode_from_bytes(&bytes, 4); + assert_eq!(&decoded[..input.len()], input); + } + #[test] fn inv_kats() { // KATs for inversion generated in Sage using the following code. diff --git a/crates/fhe/benches/bfv.rs b/crates/fhe/benches/bfv.rs index 74f5d97b..90997e88 100644 --- a/crates/fhe/benches/bfv.rs +++ b/crates/fhe/benches/bfv.rs @@ -1,5 +1,6 @@ // Allow indexing in benchmarks for convenience #![allow(clippy::indexing_slicing)] +#![allow(missing_docs)] use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use fhe::bfv::{ diff --git a/crates/fhe/benches/bfv_optimized_ops.rs b/crates/fhe/benches/bfv_optimized_ops.rs index 55827375..65b36591 100644 --- a/crates/fhe/benches/bfv_optimized_ops.rs +++ b/crates/fhe/benches/bfv_optimized_ops.rs @@ -1,5 +1,6 @@ // Allow indexing in benchmarks for convenience #![allow(clippy::indexing_slicing)] +#![allow(missing_docs)] use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use fhe::bfv::{dot_product_scalar, BfvParameters, Ciphertext, Encoding, Plaintext, SecretKey}; diff --git a/crates/fhe/benches/bfv_rgsw.rs b/crates/fhe/benches/bfv_rgsw.rs index 1829e15d..9de65e36 100644 --- a/crates/fhe/benches/bfv_rgsw.rs +++ b/crates/fhe/benches/bfv_rgsw.rs @@ -1,5 +1,6 @@ // Allow indexing in benchmarks for convenience #![allow(clippy::indexing_slicing)] +#![allow(missing_docs)] use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use fhe::bfv::{BfvParameters, Ciphertext, Encoding, Plaintext, RGSWCiphertext, SecretKey}; diff --git a/crates/fhe/examples/bfv_basic.rs b/crates/fhe/examples/bfv_basic.rs index 745fa600..7d26d997 100644 --- a/crates/fhe/examples/bfv_basic.rs +++ b/crates/fhe/examples/bfv_basic.rs @@ -1,5 +1,6 @@ // Allow indexing in examples for simplicity #![allow(clippy::indexing_slicing)] +#![allow(missing_docs)] use std::error::Error; diff --git a/crates/fhe/examples/bfv_ops.rs b/crates/fhe/examples/bfv_ops.rs index 56e198f5..3b85cc53 100644 --- a/crates/fhe/examples/bfv_ops.rs +++ b/crates/fhe/examples/bfv_ops.rs @@ -1,5 +1,6 @@ // Allow indexing in examples for simplicity #![allow(clippy::indexing_slicing)] +#![allow(missing_docs)] mod util; diff --git a/crates/fhe/examples/mulpir.rs b/crates/fhe/examples/mulpir.rs index 99c99e0b..75de12d2 100644 --- a/crates/fhe/examples/mulpir.rs +++ b/crates/fhe/examples/mulpir.rs @@ -1,5 +1,6 @@ // Allow indexing in examples for simplicity #![allow(clippy::indexing_slicing)] +#![allow(missing_docs)] // Implementation of MulPIR using the `fhe` crate. // diff --git a/crates/fhe/examples/pir.rs b/crates/fhe/examples/pir.rs index b0822f27..e75dab42 100644 --- a/crates/fhe/examples/pir.rs +++ b/crates/fhe/examples/pir.rs @@ -1,5 +1,6 @@ // Allow indexing in examples for simplicity #![allow(clippy::indexing_slicing)] +#![allow(missing_docs)] use clap::Parser; diff --git a/crates/fhe/examples/rgsw.rs b/crates/fhe/examples/rgsw.rs index b6cc0730..1749b469 100644 --- a/crates/fhe/examples/rgsw.rs +++ b/crates/fhe/examples/rgsw.rs @@ -1,5 +1,6 @@ // Allow indexing in examples for simplicity #![allow(clippy::indexing_slicing)] +#![allow(missing_docs)] use std::error::Error; diff --git a/crates/fhe/examples/sealpir.rs b/crates/fhe/examples/sealpir.rs index 8ad40d0f..709d658b 100644 --- a/crates/fhe/examples/sealpir.rs +++ b/crates/fhe/examples/sealpir.rs @@ -1,5 +1,6 @@ // Allow indexing in examples for simplicity #![allow(clippy::indexing_slicing)] +#![allow(missing_docs)] // Implementation of SealPIR using the `fhe` crate. // diff --git a/crates/fhe/examples/util.rs b/crates/fhe/examples/util.rs index e3e26e89..11ff230a 100644 --- a/crates/fhe/examples/util.rs +++ b/crates/fhe/examples/util.rs @@ -1,5 +1,6 @@ // Allow indexing in examples for simplicity #![allow(clippy::indexing_slicing)] +#![allow(missing_docs)] //! Utility functions for the examples diff --git a/crates/fhe/examples/voting.rs b/crates/fhe/examples/voting.rs index 1afad190..b84adae5 100644 --- a/crates/fhe/examples/voting.rs +++ b/crates/fhe/examples/voting.rs @@ -1,5 +1,6 @@ // Allow indexing in examples for simplicity #![allow(clippy::indexing_slicing)] +#![allow(missing_docs)] // Implementation of multiparty voting using the `fhe` crate. diff --git a/crates/fhe/src/bfv/ciphertext.rs b/crates/fhe/src/bfv/ciphertext.rs index f80660b2..9f8e74a9 100644 --- a/crates/fhe/src/bfv/ciphertext.rs +++ b/crates/fhe/src/bfv/ciphertext.rs @@ -47,6 +47,7 @@ impl Ciphertext { /// Create a ciphertext from a vector of polynomials. /// A ciphertext must contain at least two polynomials, and all polynomials /// must be in Ntt representation and with the same context. + #[allow(clippy::expect_used)] pub fn new(c: Vec, par: &Arc) -> Result { if c.len() < 2 { return Err(Error::TooFewValues { @@ -358,6 +359,7 @@ mod tests { } #[test] + #[allow(clippy::panic)] fn switch_to_level_invalid() -> Result<(), Box> { let mut rng = rng(); let params = BfvParameters::default_arc(2, 16); diff --git a/crates/fhe/src/bfv/context/chain.rs b/crates/fhe/src/bfv/context/chain.rs index df829a7f..794724e0 100644 --- a/crates/fhe/src/bfv/context/chain.rs +++ b/crates/fhe/src/bfv/context/chain.rs @@ -132,6 +132,7 @@ impl ContextLevel { } /// Access multiplication parameters for this level + #[allow(clippy::expect_used)] pub(crate) fn mul_params(&self) -> &MultiplicationParameters { self.mul_params .get() diff --git a/crates/fhe/src/bfv/parameters.rs b/crates/fhe/src/bfv/parameters.rs index cde4d8db..05fe6bce 100644 --- a/crates/fhe/src/bfv/parameters.rs +++ b/crates/fhe/src/bfv/parameters.rs @@ -246,6 +246,7 @@ impl BfvParameters { #[cfg(test)] /// Returns default parameters for tests. #[must_use] + #[allow(clippy::panic)] pub fn default_arc(num_moduli: usize, degree: usize) -> Arc { if !degree.is_power_of_two() || degree < 8 { panic!("Invalid degree"); @@ -691,6 +692,7 @@ mod tests { let result = BfvParameters::default_parameters_128(10); assert!(result.is_err()); + #[allow(clippy::panic)] match result { Err(e) => { let error_string = format!("{e}"); diff --git a/crates/fhe/src/lib.rs b/crates/fhe/src/lib.rs index 3f8e02aa..232b64ec 100644 --- a/crates/fhe/src/lib.rs +++ b/crates/fhe/src/lib.rs @@ -1,6 +1,5 @@ #![crate_name = "fhe"] #![crate_type = "lib"] -#![warn(missing_docs, unused_imports)] #![doc = include_str!("../README.md")] mod errors; diff --git a/crates/fhe/tests/unified_context_integration.rs b/crates/fhe/tests/unified_context_integration.rs index 6e6bd9d0..c2e96bab 100644 --- a/crates/fhe/tests/unified_context_integration.rs +++ b/crates/fhe/tests/unified_context_integration.rs @@ -1,4 +1,6 @@ // Integration test to verify the unified context management API works correctly +#![allow(missing_docs)] + use fhe::bfv::BfvParametersBuilder; #[test] From 6ef653fd5f02ae23d60940ccff358a5a3c846121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tancr=C3=A8de=20Lepoint?= Date: Thu, 8 Jan 2026 21:22:04 -0500 Subject: [PATCH 2/2] Set MSRV to 1.74 for workspace lints --- Cargo.toml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9ca16b0e..515c4304 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Tancrède Lepoint"] edition = "2021" repository = "https://github.com/tlepoint/fhe.rs" license = "MIT" -rust-version = "1.89" # MSRV for workspace lints +rust-version = "1.74" # MSRV for workspace lints [workspace.lints.rust] missing_docs = "warn" diff --git a/README.md b/README.md index 40a10cb6..a9e65a0f 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ fhe-traits = "0.1.1" ## Minimum supported version / toolchain -Rust **1.89** or newer (required for workspace lint configuration). +Rust **1.74** or newer (required for workspace lint configuration). ## ⚠️ Security / Stability