@@ -2,8 +2,8 @@ use super::utils::noise_simulation::*;
22use super :: utils:: traits:: * ;
33use super :: utils:: {
44 expected_pfail_for_precision, mean_and_variance_check, normality_check, pfail_check,
5- precision_with_padding, DecryptionAndNoiseResult , NoiseSample , PfailAndPrecision ,
6- PfailTestMeta , PfailTestResult ,
5+ precision_with_padding, update_ap_params_msg_and_carry_moduli , DecryptionAndNoiseResult ,
6+ NoiseSample , PfailAndPrecision , PfailTestMeta , PfailTestResult ,
77} ;
88use super :: { should_run_short_pfail_tests_debug, should_use_single_key_debug} ;
99use crate :: shortint:: atomic_pattern:: AtomicPattern ;
@@ -19,7 +19,7 @@ use crate::shortint::parameters::test_params::{
1919} ;
2020use crate :: shortint:: parameters:: {
2121 AtomicPatternParameters , CarryModulus , CiphertextModulusLog , CompressionParameters ,
22- MessageModulus , PBSParameters , Variance ,
22+ MessageModulus , Variance ,
2323} ;
2424use crate :: shortint:: server_key:: ServerKey ;
2525use crate :: shortint:: { PaddingBit , ShortintEncoding } ;
@@ -616,9 +616,23 @@ where
616616 compression_carry_mod,
617617 ) ;
618618
619+ // Here we update the message modulus only:
620+ // - because the message modulus matches for the compression encoding and compute encoding
621+ // - so that the carry modulus stays the same and we apply the same dot product as normal
622+ // for 2_2
623+ // - so that the effective encoding after the storage is the one we used to evaluate the
624+ // pfail
619625 let updated_message_mod = MessageModulus ( 1 << 6 ) ;
620626 let updated_carry_mod = compression_carry_mod;
621627
628+ update_ap_params_msg_and_carry_moduli ( & mut params, updated_message_mod, updated_carry_mod) ;
629+
630+ assert ! (
631+ ( params. message_modulus( ) . 0 * params. carry_modulus( ) . 0 ) . ilog2( )
632+ <= comp_params. storage_log_modulus( ) . 0 as u32 ,
633+ "Compression storage modulus cannot store enough bits for pfail estimation"
634+ ) ;
635+
622636 let updated_precision_with_padding =
623637 precision_with_padding ( updated_message_mod, updated_carry_mod) ;
624638
@@ -633,27 +647,6 @@ where
633647 updated_carry_mod,
634648 ) ;
635649
636- // Here we update the message modulus only:
637- // - because the message modulus matches for the compression encoding and compute encoding
638- // - so that the carry modulus stays the same and we apply the same dot product as normal
639- // for 2_2
640- // - so that the effective encoding after the storage is the one we used to evaluate the
641- // pfail
642- // TODO: do something about this
643- match & mut params {
644- AtomicPatternParameters :: Standard ( pbsparameters) => match pbsparameters {
645- PBSParameters :: PBS ( classic_pbsparameters) => {
646- classic_pbsparameters. message_modulus = updated_message_mod
647- }
648- PBSParameters :: MultiBitPBS ( multi_bit_pbsparameters) => {
649- multi_bit_pbsparameters. message_modulus = updated_message_mod
650- }
651- } ,
652- AtomicPatternParameters :: KeySwitch32 ( key_switch32_pbsparameters) => {
653- key_switch32_pbsparameters. message_modulus = updated_message_mod
654- }
655- }
656-
657650 let pfail_test_meta = if should_run_short_pfail_tests_debug ( ) {
658651 // To have the same amount of keys generated as the case where a single run is a single
659652 // sample
0 commit comments