mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-08 20:40:31 +00:00
Hash fixed_commitments and permutations into transcript
This commit is contained in:
parent
068babe3d0
commit
437782e902
4 changed files with 28 additions and 1 deletions
14
src/plonk.rs
14
src/plonk.rs
|
|
@ -9,7 +9,7 @@ use crate::arithmetic::CurveAffine;
|
||||||
use crate::poly::{
|
use crate::poly::{
|
||||||
commitment::Params, Coeff, EvaluationDomain, ExtendedLagrangeCoeff, LagrangeCoeff, Polynomial,
|
commitment::Params, Coeff, EvaluationDomain, ExtendedLagrangeCoeff, LagrangeCoeff, Polynomial,
|
||||||
};
|
};
|
||||||
use crate::transcript::ChallengeScalar;
|
use crate::transcript::{ChallengeScalar, Transcript};
|
||||||
|
|
||||||
mod circuit;
|
mod circuit;
|
||||||
mod keygen;
|
mod keygen;
|
||||||
|
|
@ -74,6 +74,18 @@ impl<C: CurveAffine> VerifyingKey<C> {
|
||||||
cs,
|
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
|
/// This is a proving key which allows for the creation of proofs for a
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ use super::circuit::{Any, Column};
|
||||||
use crate::{
|
use crate::{
|
||||||
arithmetic::CurveAffine,
|
arithmetic::CurveAffine,
|
||||||
poly::{Coeff, ExtendedLagrangeCoeff, LagrangeCoeff, Polynomial},
|
poly::{Coeff, ExtendedLagrangeCoeff, LagrangeCoeff, Polynomial},
|
||||||
|
transcript::Transcript,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) mod keygen;
|
pub(crate) mod keygen;
|
||||||
|
|
@ -66,6 +67,14 @@ impl<C: CurveAffine> VerifyingKey<C> {
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
Ok(VerifyingKey { commitments })
|
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.
|
/// The proving key for a single permutation argument.
|
||||||
|
|
|
||||||
|
|
@ -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 domain = &pk.vk.domain;
|
||||||
let mut meta = ConstraintSystem::default();
|
let mut meta = ConstraintSystem::default();
|
||||||
let config = ConcreteCircuit::configure(&mut meta);
|
let config = ConcreteCircuit::configure(&mut meta);
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@ pub fn verify_proof<'a, C: CurveAffine, T: TranscriptRead<C>>(
|
||||||
|
|
||||||
let num_proofs = instance_commitments.len();
|
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() {
|
for instance_commitments in instance_commitments.iter() {
|
||||||
// Hash the instance (external) commitments into the transcript
|
// Hash the instance (external) commitments into the transcript
|
||||||
for commitment in *instance_commitments {
|
for commitment in *instance_commitments {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue