Rename ChallengeX6 to ChallengeZ

This commit is contained in:
Jack Grigg 2020-12-01 21:23:05 +00:00
parent a63e6e25d8
commit eb7ce442f9
5 changed files with 24 additions and 24 deletions

View file

@ -87,8 +87,8 @@ impl<F: FieldExt, T> Deref for ChallengeScalar<F, T> {
}
#[derive(Clone, Copy, Debug)]
pub(crate) struct X6 {}
pub(crate) type ChallengeX6<F> = ChallengeScalar<F, X6>;
pub(crate) struct Z {}
pub(crate) type ChallengeZ<F> = ChallengeScalar<F, Z>;
/// These are the public parameters for the polynomial commitment scheme.
#[derive(Debug)]
@ -346,16 +346,16 @@ fn test_opening_proof() {
let mut transcript = Transcript::<_, DummyHash<_>, DummyHash<_>>::new();
transcript.absorb_point(&p).unwrap();
let x = ChallengeX6::get(&mut transcript);
let z = ChallengeZ::get(&mut transcript);
// Evaluate the polynomial
let v = eval_polynomial(&px, *x);
let v = eval_polynomial(&px, *z);
transcript.absorb_base(Fp::from_bytes(&v.to_bytes()).unwrap()); // unlikely to fail since p ~ q
loop {
let mut transcript_dup = transcript.clone();
let opening_proof = Proof::create(&params, &mut transcript, &px, blind, x);
let opening_proof = Proof::create(&params, &mut transcript, &px, blind, z);
if let Ok(opening_proof) = opening_proof {
// Verify the opening proof
let mut commitment_msm = params.empty_msm();
@ -365,7 +365,7 @@ fn test_opening_proof() {
&params,
params.empty_msm(),
&mut transcript_dup,
x,
z,
commitment_msm,
v,
)

View file

@ -1,7 +1,7 @@
use ff::Field;
use super::super::{Coeff, Error, Polynomial};
use super::{Blind, Challenge, ChallengeScalar, ChallengeX6, Params, Proof};
use super::{Blind, Challenge, ChallengeScalar, ChallengeZ, Params, Proof};
use crate::arithmetic::{
best_multiexp, compute_inner_product, parallelize, small_multiexp, Curve, CurveAffine, FieldExt,
};
@ -26,7 +26,7 @@ impl<C: CurveAffine> Proof<C> {
transcript: &mut Transcript<C, HBase, HScalar>,
px: &Polynomial<C::Scalar, Coeff>,
blind: Blind<C::Scalar>,
x: ChallengeX6<C::Scalar>,
z: ChallengeZ<C::Scalar>,
) -> Result<Self, Error>
where
HBase: Hasher<C::Base>,
@ -61,7 +61,7 @@ impl<C: CurveAffine> Proof<C> {
let mut cur = C::Scalar::one();
for _ in 0..(1 << params.k) {
b.push(cur);
cur *= &x;
cur *= &z;
}
}

View file

@ -1,7 +1,7 @@
use ff::Field;
use super::super::Error;
use super::{Challenge, ChallengeScalar, ChallengeX6, Params, Proof, MSM};
use super::{Challenge, ChallengeScalar, ChallengeZ, Params, Proof, MSM};
use crate::transcript::{Hasher, Transcript};
use crate::arithmetic::{best_multiexp, Curve, CurveAffine, FieldExt};
@ -71,7 +71,7 @@ impl<C: CurveAffine> Proof<C> {
params: &'a Params<C>,
mut msm: MSM<'a, C>,
transcript: &mut Transcript<C, HBase, HScalar>,
x: ChallengeX6<C::Scalar>,
z: ChallengeZ<C::Scalar>,
mut commitment_msm: MSM<'a, C>,
v: C::Scalar,
) -> Result<Guard<'a, C>, Error>
@ -164,7 +164,7 @@ impl<C: CurveAffine> Proof<C> {
// The computation of [z1] (G + H) happens in either Guard::use_challenges()
// or Guard::use_g().
let b = compute_b(*x, &challenges, &challenges_inv);
let b = compute_b(*z, &challenges, &challenges_inv);
let neg_z1 = -self.z1;

View file

@ -1,5 +1,5 @@
use super::super::{
commitment::{self, Blind, ChallengeScalar, ChallengeX6, Params},
commitment::{self, Blind, ChallengeScalar, ChallengeZ, Params},
Coeff, Error, Polynomial,
};
use super::{construct_intermediate_sets, Proof, ProverQuery, Query};
@ -113,11 +113,11 @@ impl<C: CurveAffine> Proof<C> {
.absorb_point(&f_commitment)
.map_err(|_| Error::SamplingError)?;
let x_6 = ChallengeX6::get(&mut transcript);
let z = ChallengeZ::get(&mut transcript);
let q_evals: Vec<C::Scalar> = q_polys
.iter()
.map(|poly| eval_polynomial(poly.as_ref().unwrap(), *x_6))
.map(|poly| eval_polynomial(poly.as_ref().unwrap(), *z))
.collect();
for eval in q_evals.iter() {
@ -137,7 +137,7 @@ impl<C: CurveAffine> Proof<C> {
);
if let Ok(opening) =
commitment::Proof::create(&params, &mut transcript, &f_poly, f_blind_try, x_6)
commitment::Proof::create(&params, &mut transcript, &f_poly, f_blind_try, z)
{
break (opening, q_evals);
} else {

View file

@ -1,7 +1,7 @@
use ff::Field;
use super::super::{
commitment::{ChallengeScalar, ChallengeX6, Guard, Params, MSM},
commitment::{ChallengeScalar, ChallengeZ, Guard, Params, MSM},
Error,
};
use super::{construct_intermediate_sets, Proof, Query, VerifierQuery};
@ -77,15 +77,15 @@ impl<C: CurveAffine> Proof<C> {
.absorb_point(&self.f_commitment)
.map_err(|_| Error::SamplingError)?;
// Sample a challenge x_6 for checking that f(X) was committed to
// Sample a challenge z for checking that f(X) was committed to
// correctly.
let x_6 = ChallengeX6::get(transcript);
let z = ChallengeZ::get(transcript);
for eval in self.q_evals.iter() {
transcript.absorb_scalar(*eval);
}
// We can compute the expected msm_eval at x_6 using the q_evals provided
// We can compute the expected msm_eval at z using the q_evals provided
// by the prover and from x_5
let msm_eval = point_sets
.iter()
@ -95,16 +95,16 @@ impl<C: CurveAffine> Proof<C> {
C::Scalar::zero(),
|msm_eval, ((points, evals), proof_eval)| {
let r_poly = lagrange_interpolate(points, evals);
let r_eval = eval_polynomial(&r_poly, *x_6);
let r_eval = eval_polynomial(&r_poly, *z);
let eval = points.iter().fold(*proof_eval - &r_eval, |eval, point| {
eval * &(*x_6 - point).invert().unwrap()
eval * &(*z - point).invert().unwrap()
});
msm_eval * &x_5 + &eval
},
);
// Sample a challenge x_7 that we will use to collapse the openings of
// the various remaining polynomials at x_6 together.
// the various remaining polynomials at z together.
let x_7 = ChallengeScalar::<_, ()>::get(transcript);
// Compute the final commitment that has to be opened
@ -121,7 +121,7 @@ impl<C: CurveAffine> Proof<C> {
// Verify the opening proof
self.opening
.verify(params, msm, transcript, x_6, commitment_msm, msm_eval)
.verify(params, msm, transcript, z, commitment_msm, msm_eval)
}
}