Hash fixed_commitments and permutations into transcript

This commit is contained in:
therealyingtong 2021-02-09 14:01:33 +08:00 committed by Sean Bowe
parent 068babe3d0
commit 437782e902
No known key found for this signature in database
GPG Key ID: 95684257D8F8B031
4 changed files with 28 additions and 1 deletions

View File

@ -9,7 +9,7 @@ use crate::arithmetic::CurveAffine;
use crate::poly::{
commitment::Params, Coeff, EvaluationDomain, ExtendedLagrangeCoeff, LagrangeCoeff, Polynomial,
};
use crate::transcript::ChallengeScalar;
use crate::transcript::{ChallengeScalar, Transcript};
mod circuit;
mod keygen;
@ -74,6 +74,18 @@ impl<C: CurveAffine> VerifyingKey<C> {
cs,
})
}
/// Hashes a verification key into a transcript.
pub fn hash<T: Transcript<C>>(&self, transcript: &mut T) -> io::Result<()> {
for commitment in &self.fixed_commitments {
transcript.common_point(*commitment)?;
}
for permutation in &self.permutations {
permutation.hash(transcript)?;
}
Ok(())
}
}
/// This is a proving key which allows for the creation of proofs for a

View File

@ -4,6 +4,7 @@ use super::circuit::{Any, Column};
use crate::{
arithmetic::CurveAffine,
poly::{Coeff, ExtendedLagrangeCoeff, LagrangeCoeff, Polynomial},
transcript::Transcript,
};
pub(crate) mod keygen;
@ -66,6 +67,14 @@ impl<C: CurveAffine> VerifyingKey<C> {
.collect::<Result<Vec<_>, _>>()?;
Ok(VerifyingKey { commitments })
}
pub(crate) fn hash<T: Transcript<C>>(&self, transcript: &mut T) -> io::Result<()> {
for commitment in &self.commitments {
transcript.common_point(*commitment)?;
}
Ok(())
}
}
/// The proving key for a single permutation argument.

View File

@ -30,6 +30,9 @@ pub fn create_proof<C: CurveAffine, T: TranscriptWrite<C>, ConcreteCircuit: Circ
}
}
// Hash verification key into transcript
pk.vk.hash(transcript).map_err(|_| Error::TranscriptError)?;
let domain = &pk.vk.domain;
let mut meta = ConstraintSystem::default();
let config = ConcreteCircuit::configure(&mut meta);

View File

@ -29,6 +29,9 @@ pub fn verify_proof<'a, C: CurveAffine, T: TranscriptRead<C>>(
let num_proofs = instance_commitments.len();
// Hash verification key into transcript
vk.hash(transcript).map_err(|_| Error::TranscriptError)?;
for instance_commitments in instance_commitments.iter() {
// Hash the instance (external) commitments into the transcript
for commitment in *instance_commitments {