Skip to content
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

fix: VID ADVZ allow zero-length payload #377

Merged
merged 3 commits into from
Sep 27, 2023
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: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and follow [semantic versioning](https://semver.org/) for our releases.
### Fixed

- [#243](https://github.com/EspressoSystems/jellyfish/pull/243) fixes bug in MerkleTreeGadget implementation for SparseRescueMerkleTree.
- [#377](https://github.com/EspressoSystems/jellyfish/pull/377) fix: VID ADVZ allow zero-length payload

### Added

Expand Down
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
2 changes: 1 addition & 1 deletion primitives/tests/advz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod vid;
fn round_trip() {
// play with these items
let vid_sizes = [(2, 3), (5, 9)];
let byte_lens = [2, 16, 32, 47, 48, 49, 64, 100, 400];
let byte_lens = [0, 1, 2, 16, 32, 47, 48, 49, 64, 100, 400];

// more items as a function of the above
let supported_degree = vid_sizes.iter().max_by_key(|v| v.0).unwrap().0;
Expand Down