Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.74" # 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"] }
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fhe-traits = "0.1.1"

## Minimum supported version / toolchain

Rust **1.73** or newer.
Rust **1.74** or newer (required for workspace lint configuration).

## ⚠️ Security / Stability

Expand Down
1 change: 1 addition & 0 deletions crates/fhe-math/benches/ntt.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
1 change: 1 addition & 0 deletions crates/fhe-math/benches/rns.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
1 change: 1 addition & 0 deletions crates/fhe-math/benches/rq.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
1 change: 1 addition & 0 deletions crates/fhe-math/benches/zq.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion crates/fhe-math/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![crate_name = "fhe_math"]
#![crate_type = "lib"]
#![warn(missing_docs, unused_imports)]

//! Mathematical utilities for the fhe.rs library.

Expand Down
2 changes: 2 additions & 0 deletions crates/fhe-math/src/rq/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ impl From<&Poly> for Vec<BigUint> {

#[cfg(test)]
mod tests {
#![allow(clippy::expect_used)]

use crate::{
proto::rq::Rq,
rq::{traits::TryConvertFrom, Context, Poly, Representation},
Expand Down
1 change: 1 addition & 0 deletions crates/fhe-math/src/rq/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
1 change: 0 additions & 1 deletion crates/fhe-traits/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![crate_name = "fhe_traits"]
#![crate_type = "lib"]
#![warn(missing_docs, unused_imports)]

//! Traits for Fully Homomorphic Encryption

Expand Down
12 changes: 11 additions & 1 deletion crates/fhe-util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![crate_name = "fhe_util"]
#![crate_type = "lib"]
#![warn(missing_docs, unused_imports)]

//! Utilities for the fhe.rs library.

Expand Down Expand Up @@ -57,6 +56,7 @@ pub fn sample_vec_cbd<R: RngCore + CryptoRng>(

/// 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<u8> {
assert!(0 < nbits && nbits <= 64);

Expand Down Expand Up @@ -96,6 +96,7 @@ pub fn transcode_to_bytes(a: &[u64], nbits: usize) -> Vec<u8> {

/// 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<u64> {
assert!(0 < nbits && nbits <= 64);
let mask = (u64::MAX >> (64 - nbits)) as u128;
Expand Down Expand Up @@ -134,6 +135,7 @@ pub fn transcode_from_bytes(b: &[u8], nbits: usize) -> Vec<u64> {
/// 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<u64> {
assert!(0 < input_nbits && input_nbits <= 64);
assert!(0 < output_nbits && output_nbits <= 64);
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions crates/fhe/benches/bfv.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
1 change: 1 addition & 0 deletions crates/fhe/benches/bfv_optimized_ops.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
1 change: 1 addition & 0 deletions crates/fhe/benches/bfv_rgsw.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
1 change: 1 addition & 0 deletions crates/fhe/examples/bfv_basic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Allow indexing in examples for simplicity
#![allow(clippy::indexing_slicing)]
#![allow(missing_docs)]

use std::error::Error;

Expand Down
1 change: 1 addition & 0 deletions crates/fhe/examples/bfv_ops.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Allow indexing in examples for simplicity
#![allow(clippy::indexing_slicing)]
#![allow(missing_docs)]

mod util;

Expand Down
1 change: 1 addition & 0 deletions crates/fhe/examples/mulpir.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Allow indexing in examples for simplicity
#![allow(clippy::indexing_slicing)]
#![allow(missing_docs)]

// Implementation of MulPIR using the `fhe` crate.
//
Expand Down
1 change: 1 addition & 0 deletions crates/fhe/examples/pir.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Allow indexing in examples for simplicity
#![allow(clippy::indexing_slicing)]
#![allow(missing_docs)]

use clap::Parser;

Expand Down
1 change: 1 addition & 0 deletions crates/fhe/examples/rgsw.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Allow indexing in examples for simplicity
#![allow(clippy::indexing_slicing)]
#![allow(missing_docs)]

use std::error::Error;

Expand Down
1 change: 1 addition & 0 deletions crates/fhe/examples/sealpir.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Allow indexing in examples for simplicity
#![allow(clippy::indexing_slicing)]
#![allow(missing_docs)]

// Implementation of SealPIR using the `fhe` crate.
//
Expand Down
1 change: 1 addition & 0 deletions crates/fhe/examples/util.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Allow indexing in examples for simplicity
#![allow(clippy::indexing_slicing)]
#![allow(missing_docs)]

//! Utility functions for the examples

Expand Down
1 change: 1 addition & 0 deletions crates/fhe/examples/voting.rs
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 2 additions & 0 deletions crates/fhe/src/bfv/ciphertext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Poly>, par: &Arc<BfvParameters>) -> Result<Self> {
if c.len() < 2 {
return Err(Error::TooFewValues {
Expand Down Expand Up @@ -358,6 +359,7 @@ mod tests {
}

#[test]
#[allow(clippy::panic)]
fn switch_to_level_invalid() -> Result<(), Box<dyn StdError>> {
let mut rng = rng();
let params = BfvParameters::default_arc(2, 16);
Expand Down
1 change: 1 addition & 0 deletions crates/fhe/src/bfv/context/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions crates/fhe/src/bfv/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self> {
if !degree.is_power_of_two() || degree < 8 {
panic!("Invalid degree");
Expand Down Expand Up @@ -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}");
Expand Down
1 change: 0 additions & 1 deletion crates/fhe/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![crate_name = "fhe"]
#![crate_type = "lib"]
#![warn(missing_docs, unused_imports)]
#![doc = include_str!("../README.md")]

mod errors;
Expand Down
2 changes: 2 additions & 0 deletions crates/fhe/tests/unified_context_integration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Integration test to verify the unified context management API works correctly
#![allow(missing_docs)]

use fhe::bfv::BfvParametersBuilder;

#[test]
Expand Down
Loading