Skip to content

Commit

Permalink
allow zero-length payload
Browse files Browse the repository at this point in the history
  • Loading branch information
ggutoski committed Sep 26, 2023
1 parent 55889ef commit fea8afb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions primitives/src/pcs/univariate_kzg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,14 @@ where
) -> Result<GeneralDensePolynomial<E::G1, F>, PCSError> {
// First, pad to power_of_two, since Toeplitz mul only works for 2^k
let mut padded_coeffs: Vec<F> = poly_coeffs.to_vec();
let padded_degree = (padded_coeffs.len() - 1)
let padded_degree = padded_coeffs
.len()
.saturating_sub(1)
.checked_next_power_of_two()
.ok_or_else(|| {
PCSError::InvalidParameters(ark_std::format!(
"Next power of two overflows! Got: {}",
(padded_coeffs.len() - 1)
padded_coeffs.len().saturating_sub(1)
))
})?;
let padded_len = padded_degree + 1;
Expand Down
6 changes: 5 additions & 1 deletion primitives/src/vid/advz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,11 @@ where
/// Same as [`VidScheme::disperse`] except `payload` is a slice of
/// field elements.
pub fn disperse_from_elems(&self, payload: &[P::Evaluation]) -> VidResult<VidDisperse<Self>> {
let num_polys = (payload.len() - 1) / self.payload_chunk_size + 1;
let num_polys = if payload.is_empty() {
0
} else {
(payload.len() - 1) / self.payload_chunk_size + 1
};
let domain = P::multi_open_rou_eval_domain(self.payload_chunk_size, self.num_storage_nodes)
.map_err(vid)?;

Expand Down

0 comments on commit fea8afb

Please sign in to comment.