mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 03:55:04 -05:00
use assert_eq where possible
This commit is contained in:
@@ -16,7 +16,7 @@ pub fn variance_keyswitch<W: UnsignedInteger>(
|
||||
ciphertext_modulus_log: u64,
|
||||
variance_ksk: Variance,
|
||||
) -> Variance {
|
||||
assert!(ciphertext_modulus_log == W::BITS as u64);
|
||||
assert_eq!(ciphertext_modulus_log, W::BITS as u64);
|
||||
concrete_npe::estimate_keyswitch_noise_lwe_to_glwe_with_constant_terms::<
|
||||
W,
|
||||
Variance,
|
||||
@@ -69,7 +69,7 @@ pub fn variance_bootstrap<W: UnsignedInteger>(
|
||||
ciphertext_modulus_log: u64,
|
||||
variance_bsk: Variance,
|
||||
) -> Variance {
|
||||
assert!(ciphertext_modulus_log == W::BITS as u64);
|
||||
assert_eq!(ciphertext_modulus_log, W::BITS as u64);
|
||||
let out_variance_pbs = concrete_npe::estimate_pbs_noise::<W, Variance, BinaryKeyKind>(
|
||||
LweDimension(param.internal_lwe_dimension.0 as usize),
|
||||
PolynomialSize(param.output_glwe_params.polynomial_size() as usize),
|
||||
@@ -115,7 +115,7 @@ where
|
||||
D: DispersionParameter,
|
||||
W: UnsignedInteger,
|
||||
{
|
||||
assert!(ciphertext_modulus_log == W::BITS as u64);
|
||||
assert_eq!(ciphertext_modulus_log, W::BITS as u64);
|
||||
let v_keyswitch = variance_keyswitch::<W>(
|
||||
param.ks_parameters(),
|
||||
ciphertext_modulus_log,
|
||||
@@ -149,7 +149,7 @@ where
|
||||
D: DispersionParameter,
|
||||
W: UnsignedInteger,
|
||||
{
|
||||
assert!(ciphertext_modulus_log == W::BITS as u64);
|
||||
assert_eq!(ciphertext_modulus_log, W::BITS as u64);
|
||||
let v_out_multi_sum = if dispersions.is_empty() {
|
||||
let mut weights = vec![];
|
||||
for (weight, _) in weights_tuples.iter() {
|
||||
|
||||
@@ -413,8 +413,9 @@ fn assert_checks<W: UnsignedInteger>(
|
||||
let complexity_pbs_ = DEFAULT_COMPLEXITY
|
||||
.pbs
|
||||
.complexity(pbs_parameters, ciphertext_modulus_log);
|
||||
assert!(complexity_pbs == complexity_pbs_);
|
||||
assert!(noise_in == noise_in_);
|
||||
|
||||
assert_eq!(complexity_pbs, complexity_pbs_);
|
||||
assert_eq!(noise_in, noise_in_);
|
||||
let variance_ksk =
|
||||
noise_atomic_pattern::variance_ksk(internal_dim, ciphertext_modulus_log, security_level);
|
||||
|
||||
@@ -433,8 +434,8 @@ fn assert_checks<W: UnsignedInteger>(
|
||||
let complexity_keyswitch_ = DEFAULT_COMPLEXITY
|
||||
.ks_lwe
|
||||
.complexity(keyswitch_parameters, ciphertext_modulus_log);
|
||||
assert!(complexity_keyswitch == complexity_keyswitch_);
|
||||
assert!(noise_keyswitch == noise_keyswitch_);
|
||||
assert_eq!(complexity_keyswitch, complexity_keyswitch_);
|
||||
assert_eq!(noise_keyswitch, noise_keyswitch_);
|
||||
|
||||
let atomic_pattern_parameters = AtomicPatternParameters {
|
||||
input_lwe_dimension: LweDimension(input_lwe_dimension),
|
||||
@@ -484,7 +485,7 @@ pub fn optimise_one<W: UnsignedInteger>(
|
||||
restart_at: Option<Solution>,
|
||||
) -> OptimizationState {
|
||||
assert!(0 < precision && precision <= 16);
|
||||
assert!(security_level == 128);
|
||||
assert_eq!(security_level, 128);
|
||||
assert!(1.0 <= noise_factor);
|
||||
assert!(0.0 < maximum_acceptable_error_probability);
|
||||
assert!(maximum_acceptable_error_probability < 1.0);
|
||||
|
||||
@@ -11,8 +11,8 @@ pub fn minimal_variance(
|
||||
) -> Variance {
|
||||
// https://github.com/zama-ai/concrete-optimizer/blob/prototype/python/optimizer/noise_formulas/security.py
|
||||
// ensure to have a minimal on std deviation covering the 2 lowest bits on modular scale
|
||||
assert!(
|
||||
security_level == 128,
|
||||
assert_eq!(
|
||||
security_level, 128,
|
||||
"Only 128 bits of security is supported"
|
||||
);
|
||||
let espsilon_log2_std_modular = 2.0;
|
||||
|
||||
Reference in New Issue
Block a user