chore(zk): check that k <= d for zk crs

This commit is contained in:
Nicolas Sarlin
2024-12-13 10:56:49 +01:00
committed by Nicolas Sarlin
parent ef684649f9
commit 03956a9a24
3 changed files with 12 additions and 1 deletions

View File

@@ -153,6 +153,7 @@ fn assert_pke_proof_preconditions(
big_d: usize,
big_d_max: usize,
) {
assert!(k_max <= d);
assert_eq!(c1.len(), d);
assert_eq!(e1.len(), d);

View File

@@ -497,6 +497,12 @@ pub fn compute_crs_params(
msbs_zero_padding_bit_count: u64,
bound_type: Bound,
) -> (usize, usize, u128, usize) {
assert!(
k <= d,
"Invalid parameters for zk_pok, the maximum number of messages k should be smaller \
than the lwe dimension d. Please pick a smaller k: k = {k}, d = {d}"
);
let mut B_bound_squared = {
(match bound_type {
// GHL factor is 9.75, 9.75**2 = 95.0625
@@ -526,7 +532,7 @@ Please select a smaller B, d and/or k"
// safely used for this
assert!(
m_bound <= 64,
"Invalid parameters for zk_pok, w e only support 64 bits integer. \
"Invalid parameters for zk_pok, we only support 64 bits integer. \
The computed m parameter is {m_bound} > 64. Please select a smaller B, d and/or k"
);

View File

@@ -298,6 +298,10 @@ impl CompactPkeCrs {
Scalar: UnsignedInteger + CastInto<u64> + Debug,
NoiseDistribution: BoundedDistribution<Scalar::Signed>,
{
if max_num_cleartext.0 > lwe_dim.0 {
return Err("Maximum number of cleartexts is greater than the lwe dimension".into());
}
let noise_bound = match zk_scheme {
CompactPkeZkScheme::V1 => Self::compute_bound_v1(noise_distribution)?,
CompactPkeZkScheme::V2 => Self::compute_bound_v2(noise_distribution)?,