Skip to content
This repository was archived by the owner on Aug 18, 2025. It is now read-only.
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
1 change: 0 additions & 1 deletion src/plonk/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ where
fixed_commitments,
permutation_vk,
cs,
assembly.selectors,
))
}

Expand Down
30 changes: 4 additions & 26 deletions src/plonk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ pub struct VerifyingKey<F: PrimeField, CS: PolynomialCommitmentScheme<F>> {
cs_degree: usize,
/// The representative of this `VerifyingKey` in transcripts.
transcript_repr: F,
selectors: Vec<Vec<bool>>,
}

// Current version of the VK
Expand Down Expand Up @@ -91,13 +90,6 @@ where
}
self.permutation.write(writer, format)?;

// write self.selectors
for selector in &self.selectors {
// since `selector` is filled with `bool`, we pack them 8 at a time into bytes and then write
for bits in selector.chunks(8) {
writer.write_all(&[crate::utils::helpers::pack(bits)])?;
}
}
Ok(())
}

Expand Down Expand Up @@ -150,18 +142,11 @@ where

let permutation = permutation::VerifyingKey::read(reader, &cs.permutation, format)?;

let selectors = vec![];
// we still need to replace selectors with fixed Expressions in `cs`
let fake_selectors = vec![vec![]; cs.num_selectors];
let (cs, _) = cs.directly_convert_selectors_to_fixed(fake_selectors);

Ok(Self::from_parts(
domain,
fixed_commitments,
permutation,
cs,
selectors,
))
Ok(Self::from_parts(domain, fixed_commitments, permutation, cs))
}

/// Writes a verifying key to a vector of bytes using [`Self::write`].
Expand All @@ -187,23 +172,17 @@ where
}

impl<F: WithSmallOrderMulGroup<3>, CS: PolynomialCommitmentScheme<F>> VerifyingKey<F, CS> {
fn bytes_length(&self, format: SerdeFormat) -> usize {
/// Return the bytes_length of a VerifyingKey
pub fn bytes_length(&self, format: SerdeFormat) -> usize {
10 + (self.fixed_commitments.len() * byte_length::<CS::Commitment>(format))
+ self.permutation.bytes_length(format)
+ self.selectors.len()
* (self
.selectors
.first()
.map(|selector| (selector.len() + 7) / 8)
.unwrap_or(0))
}

fn from_parts(
domain: EvaluationDomain<F>,
fixed_commitments: Vec<CS::Commitment>,
permutation: permutation::VerifyingKey<F, CS>,
cs: ConstraintSystem<F>,
selectors: Vec<Vec<bool>>,
) -> Self
where
F: FromUniformBytes<64>,
Expand All @@ -219,7 +198,6 @@ impl<F: WithSmallOrderMulGroup<3>, CS: PolynomialCommitmentScheme<F>> VerifyingK
cs_degree,
// Temporary, this is not pinned.
transcript_repr: F::ZERO,
selectors,
};

let mut hasher = Blake2bParams::new()
Expand Down Expand Up @@ -315,7 +293,7 @@ where
}

/// Gets the total number of bytes in the serialization of `self`
fn bytes_length(&self, format: SerdeFormat) -> usize {
pub fn bytes_length(&self, format: SerdeFormat) -> usize {
self.vk.bytes_length(format)
+ 12 // bytes used for encoding the length(u32) of "l0", "l_last" & "l_active_row" polys
+ polynomial_slice_byte_length(&self.fixed_values)
Expand Down