-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
conformance ProvenCompactCiphertextList #1602
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
use crate::conformance::{ListSizeConstraint, ParameterSetConformant}; | ||
use crate::core_crypto::algorithms::verify_lwe_compact_ciphertext_list; | ||
use crate::core_crypto::prelude::LweCiphertextListParameters; | ||
use crate::shortint::ciphertext::CompactCiphertextList; | ||
use crate::shortint::parameters::{ | ||
CiphertextListConformanceParams, CompactCiphertextListExpansionKind, | ||
CompactPublicKeyEncryptionParameters, MessageModulus, ShortintCompactCiphertextListCastingMode, | ||
}; | ||
use crate::shortint::{Ciphertext, CompactPublicKey}; | ||
use crate::shortint::{Ciphertext, ClassicPBSParameters, CompactPublicKey}; | ||
use crate::zk::{ | ||
CompactPkeCrs, CompactPkeProof, CompactPkePublicParams, ZkMSBZeroPaddingBitCount, | ||
ZkVerificationOutCome, | ||
}; | ||
use rayon::prelude::*; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::{Degree, NoiseLevel}; | ||
|
||
impl CompactPkeCrs { | ||
/// Construct the CRS that corresponds to the given parameters | ||
/// | ||
|
@@ -141,6 +146,74 @@ impl ProvenCompactCiphertextList { | |
} | ||
} | ||
|
||
pub struct ProvenCompactCiphertextListConformanceParams { | ||
pub sk_params: ClassicPBSParameters, | ||
pub elements_per_block: usize, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this be called |
||
pub expected_len: usize, | ||
pub expansion_kind: CompactCiphertextListExpansionKind, | ||
} | ||
|
||
impl ParameterSetConformant for ProvenCompactCiphertextList { | ||
type ParameterSet = ProvenCompactCiphertextListConformanceParams; | ||
|
||
fn is_conformant(&self, parameter_set: &Self::ParameterSet) -> bool { | ||
let Self { proved_lists } = self; | ||
|
||
let ProvenCompactCiphertextListConformanceParams { | ||
sk_params, | ||
elements_per_block, | ||
expected_len: full_expected_len, | ||
expansion_kind, | ||
} = parameter_set; | ||
|
||
let mut remaining_len = *full_expected_len; | ||
|
||
let elements_per_block = *elements_per_block; | ||
|
||
for (compatc_ct_lict, proof) in proved_lists { | ||
if remaining_len == 0 { | ||
return false; | ||
} | ||
|
||
let expected_len; | ||
|
||
if remaining_len > elements_per_block { | ||
remaining_len -= elements_per_block; | ||
|
||
expected_len = elements_per_block | ||
} else { | ||
expected_len = remaining_len; | ||
remaining_len = 0; | ||
}; | ||
|
||
let params = CiphertextListConformanceParams { | ||
ct_list_params: LweCiphertextListParameters { | ||
lwe_dim: sk_params | ||
.glwe_dimension | ||
.to_equivalent_lwe_dimension(sk_params.polynomial_size), | ||
lwe_ciphertext_count_constraint: ListSizeConstraint::exact_size(expected_len), | ||
ct_modulus: sk_params.ciphertext_modulus, | ||
}, | ||
message_modulus: sk_params.message_modulus, | ||
carry_modulus: sk_params.carry_modulus, | ||
degree: Degree::new(sk_params.message_modulus.0 * sk_params.message_modulus.0 - 1), | ||
noise_level: NoiseLevel::NOMINAL, | ||
expansion_kind: *expansion_kind, | ||
}; | ||
|
||
if !proof.is_valid() { | ||
return false; | ||
} | ||
Comment on lines
+204
to
+206
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this API name is confusing, so more "content_is_usable" |
||
|
||
if !compatc_ct_lict.is_conformant(¶ms) { | ||
return false; | ||
} | ||
} | ||
|
||
true | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::shortint::parameters::{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need a test case with casting