Skip to content

Commit

Permalink
has error
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenfeizhang committed Jun 10, 2024
1 parent 8eb6b78 commit d42ed39
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
27 changes: 23 additions & 4 deletions bi-kzg/src/bi_kzg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,34 @@ where
point: &Self::Point,
) -> (Self::Proof, Self::Evaluation) {
// fixme
let eval = polynomial.evaluate(&point.0, &point.1);
let q_0 = polynomial.evaluate(&prover_param.borrow().tau_0, &point.1);
let q_1 = polynomial.evaluate(&point.0, &prover_param.borrow().tau_1);
let tau_0 = prover_param.borrow().tau_0;
let tau_1 = prover_param.borrow().tau_1;
let a = point.0;
let b = point.1;

let u = polynomial.evaluate(&a, &b);
let u_prime = polynomial.evaluate(&tau_0, &b);

let f_tau0_b = polynomial.evaluate(&tau_0, &b);
let f_a_tau1 = polynomial.evaluate(&a, &tau_1);

let q_0 = (f_tau0_b - u) * ((tau_0 - a).invert().unwrap());
let q_1 = (f_a_tau1 - u_prime) * ((tau_1 - b).invert().unwrap());

let proof = BiKZGProof {
pi0: (prover_param.borrow().powers_of_g[0] * q_0).into(),
pi1: (prover_param.borrow().powers_of_g[0] * q_1).into(),
};

(proof, eval)
let c = polynomial.evaluate(&tau_0, &tau_1);

let t0 = q_0 * (tau_0 - a);
let t1 = q_1 * (tau_1 - b);
let right = c - u;

assert_eq!(t0 + t1, right, "t0 + t1 != right");

(proof, u)
}

fn verify(
Expand Down
4 changes: 1 addition & 3 deletions bi-kzg/src/poly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl<F: Field> BivaraitePolynomial<F> {
degree_1,
}
}

pub fn random(mut rng: impl RngCore, degree_0: usize, degree_1: usize) -> Self {
let coefficients = (0..degree_0 * degree_1)
.map(|_| F::random(&mut rng))
Expand All @@ -37,8 +37,6 @@ impl<F: Field> BivaraitePolynomial<F> {
* y_i
})
}


}

#[cfg(test)]
Expand Down

0 comments on commit d42ed39

Please sign in to comment.