Skip to content
Snippets Groups Projects
Commit c66f7e45 authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

fix Semi-AVID for files with holes (!216)

addresses #20 

this uses the `supernova.mp3` test file from the issue, with less bytes and enough $0$s at the front to introduce a null polynomial at the start

## the fix
- iterate over the $k$ polynomials instead of looking at the length of `polynomials[0].coeffs()` which is smaller than $k$ in case the polynomial has holes in the higher monomials
- give a default value of $0_{\mathbb{F}_p}$ when trying to index into the polynomial coefficients
parent 98ec07b9
No related branches found
No related tags found
1 merge request!216fix Semi-AVID for files with holes
Pipeline #9363 passed
File added
......@@ -298,8 +298,18 @@ where
);
debug!("transposing the polynomials to commit");
let polynomials_to_commit = (0..polynomials[0].coeffs().len())
.map(|i| P::from_coefficients_vec(polynomials.iter().map(|p| p.coeffs()[i]).collect()))
let polynomials_to_commit = (0..k)
.map(|i| {
P::from_coefficients_vec(
polynomials
.iter()
.map(|p| {
#[allow(clippy::clone_on_copy)]
p.coeffs().get(i).unwrap_or(&F::zero()).clone()
})
.collect(),
)
})
.collect::<Vec<P>>();
debug!("committing the polynomials");
......@@ -359,12 +369,13 @@ mod tests {
use ark_ff::PrimeField;
use ark_poly::{univariate::DensePolynomial, DenseUVPolynomial};
use ark_std::{ops::Div, test_rng};
use rand::{rngs::StdRng, SeedableRng};
use crate::{
algebra::linalg::Matrix,
error::KomodoError,
fec::{decode, encode, Shard},
zk::{setup, Commitment},
zk::{setup, Commitment, Powers},
};
use super::{build, prove, recode, verify, Block};
......@@ -676,4 +687,13 @@ mod tests {
)
});
}
#[test]
fn prove_with_holes() {
let mut rng = StdRng::seed_from_u64(42);
let powers: Powers<Fr, G1Projective> = setup(300, &mut rng).unwrap();
let data = std::fs::read("assets/bin_with_holes").unwrap();
prove::<Fr, G1Projective, DensePolynomial<Fr>>(&data, &powers, 5).unwrap();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment