mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-04 20:03:39 +00:00
Rename ChallengeX6 to ChallengeZ
This commit is contained in:
parent
a63e6e25d8
commit
eb7ce442f9
5 changed files with 24 additions and 24 deletions
|
|
@ -87,8 +87,8 @@ impl<F: FieldExt, T> Deref for ChallengeScalar<F, T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub(crate) struct X6 {}
|
pub(crate) struct Z {}
|
||||||
pub(crate) type ChallengeX6<F> = ChallengeScalar<F, X6>;
|
pub(crate) type ChallengeZ<F> = ChallengeScalar<F, Z>;
|
||||||
|
|
||||||
/// These are the public parameters for the polynomial commitment scheme.
|
/// These are the public parameters for the polynomial commitment scheme.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
@ -346,16 +346,16 @@ fn test_opening_proof() {
|
||||||
|
|
||||||
let mut transcript = Transcript::<_, DummyHash<_>, DummyHash<_>>::new();
|
let mut transcript = Transcript::<_, DummyHash<_>, DummyHash<_>>::new();
|
||||||
transcript.absorb_point(&p).unwrap();
|
transcript.absorb_point(&p).unwrap();
|
||||||
let x = ChallengeX6::get(&mut transcript);
|
let z = ChallengeZ::get(&mut transcript);
|
||||||
// Evaluate the polynomial
|
// 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
|
transcript.absorb_base(Fp::from_bytes(&v.to_bytes()).unwrap()); // unlikely to fail since p ~ q
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let mut transcript_dup = transcript.clone();
|
let mut transcript_dup = transcript.clone();
|
||||||
|
|
||||||
let opening_proof = Proof::create(¶ms, &mut transcript, &px, blind, x);
|
let opening_proof = Proof::create(¶ms, &mut transcript, &px, blind, z);
|
||||||
if let Ok(opening_proof) = opening_proof {
|
if let Ok(opening_proof) = opening_proof {
|
||||||
// Verify the opening proof
|
// Verify the opening proof
|
||||||
let mut commitment_msm = params.empty_msm();
|
let mut commitment_msm = params.empty_msm();
|
||||||
|
|
@ -365,7 +365,7 @@ fn test_opening_proof() {
|
||||||
¶ms,
|
¶ms,
|
||||||
params.empty_msm(),
|
params.empty_msm(),
|
||||||
&mut transcript_dup,
|
&mut transcript_dup,
|
||||||
x,
|
z,
|
||||||
commitment_msm,
|
commitment_msm,
|
||||||
v,
|
v,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use ff::Field;
|
use ff::Field;
|
||||||
|
|
||||||
use super::super::{Coeff, Error, Polynomial};
|
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::{
|
use crate::arithmetic::{
|
||||||
best_multiexp, compute_inner_product, parallelize, small_multiexp, Curve, CurveAffine, FieldExt,
|
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>,
|
transcript: &mut Transcript<C, HBase, HScalar>,
|
||||||
px: &Polynomial<C::Scalar, Coeff>,
|
px: &Polynomial<C::Scalar, Coeff>,
|
||||||
blind: Blind<C::Scalar>,
|
blind: Blind<C::Scalar>,
|
||||||
x: ChallengeX6<C::Scalar>,
|
z: ChallengeZ<C::Scalar>,
|
||||||
) -> Result<Self, Error>
|
) -> Result<Self, Error>
|
||||||
where
|
where
|
||||||
HBase: Hasher<C::Base>,
|
HBase: Hasher<C::Base>,
|
||||||
|
|
@ -61,7 +61,7 @@ impl<C: CurveAffine> Proof<C> {
|
||||||
let mut cur = C::Scalar::one();
|
let mut cur = C::Scalar::one();
|
||||||
for _ in 0..(1 << params.k) {
|
for _ in 0..(1 << params.k) {
|
||||||
b.push(cur);
|
b.push(cur);
|
||||||
cur *= &x;
|
cur *= &z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use ff::Field;
|
use ff::Field;
|
||||||
|
|
||||||
use super::super::Error;
|
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::transcript::{Hasher, Transcript};
|
||||||
|
|
||||||
use crate::arithmetic::{best_multiexp, Curve, CurveAffine, FieldExt};
|
use crate::arithmetic::{best_multiexp, Curve, CurveAffine, FieldExt};
|
||||||
|
|
@ -71,7 +71,7 @@ impl<C: CurveAffine> Proof<C> {
|
||||||
params: &'a Params<C>,
|
params: &'a Params<C>,
|
||||||
mut msm: MSM<'a, C>,
|
mut msm: MSM<'a, C>,
|
||||||
transcript: &mut Transcript<C, HBase, HScalar>,
|
transcript: &mut Transcript<C, HBase, HScalar>,
|
||||||
x: ChallengeX6<C::Scalar>,
|
z: ChallengeZ<C::Scalar>,
|
||||||
mut commitment_msm: MSM<'a, C>,
|
mut commitment_msm: MSM<'a, C>,
|
||||||
v: C::Scalar,
|
v: C::Scalar,
|
||||||
) -> Result<Guard<'a, C>, Error>
|
) -> 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()
|
// The computation of [z1] (G + H) happens in either Guard::use_challenges()
|
||||||
// or Guard::use_g().
|
// 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;
|
let neg_z1 = -self.z1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use super::super::{
|
use super::super::{
|
||||||
commitment::{self, Blind, ChallengeScalar, ChallengeX6, Params},
|
commitment::{self, Blind, ChallengeScalar, ChallengeZ, Params},
|
||||||
Coeff, Error, Polynomial,
|
Coeff, Error, Polynomial,
|
||||||
};
|
};
|
||||||
use super::{construct_intermediate_sets, Proof, ProverQuery, Query};
|
use super::{construct_intermediate_sets, Proof, ProverQuery, Query};
|
||||||
|
|
@ -113,11 +113,11 @@ impl<C: CurveAffine> Proof<C> {
|
||||||
.absorb_point(&f_commitment)
|
.absorb_point(&f_commitment)
|
||||||
.map_err(|_| Error::SamplingError)?;
|
.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
|
let q_evals: Vec<C::Scalar> = q_polys
|
||||||
.iter()
|
.iter()
|
||||||
.map(|poly| eval_polynomial(poly.as_ref().unwrap(), *x_6))
|
.map(|poly| eval_polynomial(poly.as_ref().unwrap(), *z))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
for eval in q_evals.iter() {
|
for eval in q_evals.iter() {
|
||||||
|
|
@ -137,7 +137,7 @@ impl<C: CurveAffine> Proof<C> {
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Ok(opening) =
|
if let Ok(opening) =
|
||||||
commitment::Proof::create(¶ms, &mut transcript, &f_poly, f_blind_try, x_6)
|
commitment::Proof::create(¶ms, &mut transcript, &f_poly, f_blind_try, z)
|
||||||
{
|
{
|
||||||
break (opening, q_evals);
|
break (opening, q_evals);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use ff::Field;
|
use ff::Field;
|
||||||
|
|
||||||
use super::super::{
|
use super::super::{
|
||||||
commitment::{ChallengeScalar, ChallengeX6, Guard, Params, MSM},
|
commitment::{ChallengeScalar, ChallengeZ, Guard, Params, MSM},
|
||||||
Error,
|
Error,
|
||||||
};
|
};
|
||||||
use super::{construct_intermediate_sets, Proof, Query, VerifierQuery};
|
use super::{construct_intermediate_sets, Proof, Query, VerifierQuery};
|
||||||
|
|
@ -77,15 +77,15 @@ impl<C: CurveAffine> Proof<C> {
|
||||||
.absorb_point(&self.f_commitment)
|
.absorb_point(&self.f_commitment)
|
||||||
.map_err(|_| Error::SamplingError)?;
|
.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.
|
// correctly.
|
||||||
let x_6 = ChallengeX6::get(transcript);
|
let z = ChallengeZ::get(transcript);
|
||||||
|
|
||||||
for eval in self.q_evals.iter() {
|
for eval in self.q_evals.iter() {
|
||||||
transcript.absorb_scalar(*eval);
|
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
|
// by the prover and from x_5
|
||||||
let msm_eval = point_sets
|
let msm_eval = point_sets
|
||||||
.iter()
|
.iter()
|
||||||
|
|
@ -95,16 +95,16 @@ impl<C: CurveAffine> Proof<C> {
|
||||||
C::Scalar::zero(),
|
C::Scalar::zero(),
|
||||||
|msm_eval, ((points, evals), proof_eval)| {
|
|msm_eval, ((points, evals), proof_eval)| {
|
||||||
let r_poly = lagrange_interpolate(points, evals);
|
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| {
|
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
|
msm_eval * &x_5 + &eval
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// Sample a challenge x_7 that we will use to collapse the openings of
|
// 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);
|
let x_7 = ChallengeScalar::<_, ()>::get(transcript);
|
||||||
|
|
||||||
// Compute the final commitment that has to be opened
|
// Compute the final commitment that has to be opened
|
||||||
|
|
@ -121,7 +121,7 @@ impl<C: CurveAffine> Proof<C> {
|
||||||
|
|
||||||
// Verify the opening proof
|
// Verify the opening proof
|
||||||
self.opening
|
self.opening
|
||||||
.verify(params, msm, transcript, x_6, commitment_msm, msm_eval)
|
.verify(params, msm, transcript, z, commitment_msm, msm_eval)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue