Skip to content
Snippets Groups Projects

add aPlonK

Merged STEVAN Antoine requested to merge aplonk into main
1 file
+ 1
67
Compare changes
  • Side-by-side
  • Inline
+ 1
67
@@ -380,13 +380,7 @@ where
#[cfg(test)]
mod tests {
use super::{commit, prove, setup, Block};
use crate::{
conversions::u32_to_u8_vec,
fec::{decode, encode},
field,
linalg::Matrix,
zk::trim,
};
use crate::{conversions::u32_to_u8_vec, fec::encode, field, linalg::Matrix, zk::trim};
use ark_bls12_381::Bls12_381;
use ark_ec::{pairing::Pairing, AffineRepr};
@@ -522,39 +516,6 @@ mod tests {
Ok(())
}
fn reconstruct_template<E, P>(
bytes: &[u8],
k: usize,
n: usize,
l: usize,
) -> Result<(), ark_poly_commit::Error>
where
E: Pairing,
P: DenseUVPolynomial<E::ScalarField, Point = E::ScalarField>,
for<'a, 'b> &'a P: Div<&'b P, Output = P>,
{
assert!(
n >= k + l,
"kzg::tests::reconstruct_template requires at least {} = k (= {}) + l (= {}) shards, found {}",
k + l,
k,
l,
n
);
let (blocks, _, _) = test_setup::<E, P>(bytes, k, n).expect("proof failed for bls12-381");
let mut shards = blocks.iter().map(|x| x.shard.clone()).collect::<Vec<_>>();
for _ in 0..l {
shards.remove(0);
}
assert_eq!(bytes.to_vec(), decode::<E::ScalarField>(shards).unwrap());
Ok(())
}
#[test]
fn verify_2() {
verify_template::<Bls12_381, UniPoly381>(&bytes::<Bls12_381>(4, 2), 4, 6)
@@ -599,31 +560,4 @@ mod tests {
verify_template::<Bls12_381, UniPoly381>(&bytes[0..(bytes.len() - 33)], 4, 6)
.expect("verification failed for bls12-381 with padding");
}
#[test]
fn reconstruct_2() {
reconstruct_template::<Bls12_381, UniPoly381>(&bytes::<Bls12_381>(4, 2), 4, 6, 2)
.expect("reconstruction failed for bls12-381");
}
#[test]
fn reconstruct_4() {
reconstruct_template::<Bls12_381, UniPoly381>(&bytes::<Bls12_381>(4, 4), 4, 6, 2)
.expect("reconstruction failed for bls12-381");
}
#[test]
fn reconstruct_8() {
reconstruct_template::<Bls12_381, UniPoly381>(&bytes::<Bls12_381>(4, 8), 4, 6, 2)
.expect("reconstruction failed for bls12-381");
}
// TODO: implement padding for aPlonK
#[ignore = "padding not supported by aPlonK"]
#[test]
fn reconstruct_with_padding() {
let bytes = bytes::<Bls12_381>(4, 2);
reconstruct_template::<Bls12_381, UniPoly381>(&bytes[0..(bytes.len() - 33)], 4, 6, 2)
.expect("verification failed for bls12-381 with padding");
}
}
Loading