Remove logic for reading and writing VerificationKey to/from buffers.

This commit is contained in:
Sean Bowe 2022-03-16 12:52:26 -06:00
parent 819bc3c2f5
commit f46d77763e
No known key found for this signature in database
GPG Key ID: 95684257D8F8B031
3 changed files with 1 additions and 60 deletions

View File

@ -46,37 +46,6 @@ pub struct VerifyingKey<C: CurveAffine> {
}
impl<C: CurveAffine> VerifyingKey<C> {
/// Writes a verifying key to a buffer.
pub fn write<W: io::Write>(&self, writer: &mut W) -> io::Result<()> {
for commitment in &self.fixed_commitments {
writer.write_all(commitment.to_bytes().as_ref())?;
}
self.permutation.write(writer)?;
Ok(())
}
/// Reads a verification key from a buffer.
pub fn read<R: io::Read, ConcreteCircuit: Circuit<C::Scalar>>(
reader: &mut R,
params: &Params<C>,
) -> io::Result<Self> {
let (domain, cs, _) = keygen::create_domain::<C, ConcreteCircuit>(params);
let fixed_commitments: Vec<_> = (0..cs.num_fixed_columns)
.map(|_| C::read(reader))
.collect::<Result<_, _>>()?;
let permutation = permutation::VerifyingKey::read(reader, &cs.permutation)?;
Ok(VerifyingKey {
domain,
fixed_commitments,
permutation,
cs,
})
}
/// Hashes a verification key into a transcript.
pub fn hash_into<E: EncodedChallenge<C>, T: Transcript<C, E>>(
&self,

View File

@ -78,23 +78,6 @@ pub(crate) struct VerifyingKey<C: CurveAffine> {
commitments: Vec<C>,
}
impl<C: CurveAffine> VerifyingKey<C> {
pub(crate) fn write<W: io::Write>(&self, writer: &mut W) -> io::Result<()> {
for commitment in &self.commitments {
writer.write_all(commitment.to_bytes().as_ref())?;
}
Ok(())
}
pub(crate) fn read<R: io::Read>(reader: &mut R, argument: &Argument) -> io::Result<Self> {
let commitments = (0..argument.columns.len())
.map(|_| C::read(reader))
.collect::<Result<Vec<_>, _>>()?;
Ok(VerifyingKey { commitments })
}
}
/// The proving key for a single permutation argument.
#[derive(Debug)]
pub(crate) struct ProvingKey<C: CurveAffine> {

View File

@ -9,7 +9,6 @@ use halo2_proofs::pasta::{Eq, EqAffine, Fp};
use halo2_proofs::plonk::{
create_proof, keygen_pk, keygen_vk, verify_proof, Advice, BatchVerifier, Circuit, Column,
ConstraintSystem, Error, Fixed, SingleVerifier, TableColumn, VerificationStrategy,
VerifyingKey,
};
use halo2_proofs::poly::commitment::{Guard, MSM};
use halo2_proofs::poly::{commitment::Params, Rotation};
@ -565,21 +564,11 @@ fn plonk_api() {
)
.unwrap();
// Write and then read the verification key in between (to check round-trip
// serialization).
// TODO: Figure out whether https://github.com/zcash/halo2/issues/449 should
// be caught by this, or if it is caused by downstream changes to halo2.
let mut vk_buffer = vec![];
pk.get_vk().write(&mut vk_buffer).unwrap();
let vk =
VerifyingKey::<EqAffine>::read::<_, MyCircuit<Fp>>(&mut &vk_buffer[..], &params)
.unwrap();
// "Second" proof (just the first proof again).
let mut transcript = Blake2bRead::<_, _, Challenge255<_>>::init(&proof[..]);
let strategy = verify_proof(
&params,
&vk,
pk.get_vk(),
strategy,
&[&[&pubinputs[..]], &[&pubinputs[..]]],
&mut transcript,