update plonky2 and fix serialization.

This commit is contained in:
M Alghazwi 2025-04-03 10:14:45 +02:00
parent aa13ff3253
commit 9ce15d8e00
No known key found for this signature in database
GPG Key ID: 646E567CAD7DB607
2 changed files with 3 additions and 33 deletions

View File

@ -6,10 +6,10 @@ resolver = "2"
[workspace.dependencies]
anyhow = { version = "1.0.89"}
unroll = { version = "0.1.5"}
plonky2 = { version = "1.0.0" , default-features = false}
plonky2 = { version = "1.0.2" , default-features = false}
plonky2_field = { version = "1.0.0" }
plonky2_maybe_rayon = { version = "1.0.0"}
itertools = { version = "0.12.1"}
itertools = { version = "0.14.0" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "2.0.10"

View File

@ -19,7 +19,7 @@ use plonky2::gates::random_access::RandomAccessGate;
use plonky2::gates::reducing::ReducingGate;
use plonky2::gates::reducing_extension::ReducingExtensionGate;
use plonky2::hash::hash_types::RichField;
use plonky2::{read_gate_impl, get_gate_tag_impl};
use plonky2::{read_gate_impl, get_gate_tag_impl, impl_gate_serializer};
use plonky2::plonk::circuit_data::{CircuitConfig, CommonCircuitData};
use plonky2::util::serialization::{Buffer, GateSerializer, IoResult};
use crate::poseidon2_hash::poseidon2::Poseidon2;
@ -28,36 +28,6 @@ use plonky2::iop::witness::PartialWitness;
use plonky2::plonk::circuit_builder::CircuitBuilder;
use plonky2_field::goldilocks_field::GoldilocksField;
#[macro_export]
/// The macros are re-implemented here because of import issue with plonky2
/// in plonky2 `use std::vec::Vec;` // For macros was not set to public
/// so here these are re-implemented
macro_rules! impl_gate_serializer {
($target:ty, $($gate_types:ty),+) => {
fn read_gate(
&self,
buf: &mut plonky2::util::serialization::Buffer,
common: &plonky2::plonk::circuit_data::CommonCircuitData<F, D>,
) -> plonky2::util::serialization::IoResult<plonky2::gates::gate::GateRef<F, D>> {
let tag = plonky2::util::serialization::Read::read_u32(buf)?;
read_gate_impl!(buf, tag, common, $($gate_types),+)
}
fn write_gate(
&self,
buf: &mut Vec<u8>,
gate: &plonky2::gates::gate::GateRef<F, D>,
common: &plonky2::plonk::circuit_data::CommonCircuitData<F, D>,
) -> plonky2::util::serialization::IoResult<()> {
let tag = get_gate_tag_impl!(gate, $($gate_types),+)?;
plonky2::util::serialization::Write::write_u32(buf, tag)?;
gate.0.serialize(buf, common)?;
Ok(())
}
};
}
/// A gate serializer that can be used to serialize all default gates supported
/// by the `plonky2` library with the added Poseidon2 Gate
#[derive(Debug)]