Skip to content

Commit

Permalink
Add test coverage for polynomial evaluations
Browse files Browse the repository at this point in the history
The test vectors are calcolate by @marta-belles, assuming the `ifft`
function is actually correct.

Resolves: #586
  • Loading branch information
ZER0 committed Oct 14, 2021
1 parent 21ffc38 commit 9605eb6
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/permutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,65 @@ fn plonkup_denominator_irreducible(
mod test {
use super::*;
use crate::constraint_system::{Constraint, TurboComposer};
use crate::error::Error;
use crate::fft::Polynomial;
use crate::plonkup::MultiSet;
use dusk_bls12_381::BlsScalar;
use rand_core::OsRng;

#[test]
fn test_compute_lookup_permutation_poly() -> Result<(), Error> {
const SIZE: u32 = 4;

let delta = BlsScalar::from(10u64);
let epsilon = BlsScalar::from(20u64);

// assert_ne!(delta, epsilon);

let mut t = MultiSet::from(
&[
BlsScalar::one(),
BlsScalar::from(2u64),
BlsScalar::from(3u64),
][..],
);
t.pad(SIZE);

let mut f = MultiSet::from(
&[
BlsScalar::one(),
BlsScalar::from(3u64),
BlsScalar::from(3u64),
][..],
);
f.pad(SIZE);

let mut h_1 = MultiSet::from(
&[BlsScalar::one(), BlsScalar::one(), BlsScalar::one()][..],
);
h_1.pad(SIZE);

let mut h_2 = MultiSet::from(
&[
BlsScalar::from(2u64),
BlsScalar::from(3u64),
BlsScalar::one(),
][..],
);
h_2.pad(SIZE);

let domain = EvaluationDomain::new(4)?;
let perm = Permutation::new();

let poly = perm.compute_lookup_permutation_poly(
&domain, &f.0, &t.0, &h_1.0, &h_2.0, &delta, &epsilon,
);

assert_eq!(format!("{:?}", poly), "Polynomial { coeffs: [0eaa2fe1c155cfb88bf91f7800c3b855fc67989c949da6cc87a68c9499680d1c, 077d37bc33db4e8809cc64da6e65d911d3d14ae877e61d9afe13d8229c3c9667, 504f5bba23e3439bb5c1ac5968bea1db2491ad7237d03f4cccc5258c605c3e17, 9e893da8e4eb9d23b330cb532e61476416e5b21bcc5b6fb33d7ab00f104df94c] }");

Ok(())
}

#[allow(dead_code)]
fn compute_fast_permutation_poly(
domain: &EvaluationDomain,
Expand Down

0 comments on commit 9605eb6

Please sign in to comment.