fix: missing gate and generator for serialization (#369)
Add the missing gates and generator in the serializer that were added with the PublicKeyOf operation. Add a test for CircuitData serialization+deserialization to avoid these kind of bugs in the future.
This commit is contained in:
parent
59c6151dbc
commit
0606a4098b
3 changed files with 32 additions and 4 deletions
|
|
@ -578,7 +578,7 @@ pub(crate) fn rec_main_pod_circuit_data(
|
|||
)
|
||||
}
|
||||
|
||||
fn cache_get_rec_main_pod_circuit_data(
|
||||
pub(crate) fn cache_get_rec_main_pod_circuit_data(
|
||||
params: &Params,
|
||||
) -> CacheEntry<(
|
||||
RecursiveCircuitTarget<MainPodVerifyTarget>,
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use plonky2::{
|
|||
get_gate_tag_impl, impl_gate_serializer, read_gate_impl,
|
||||
util::serialization::GateSerializer,
|
||||
};
|
||||
use plonky2_u32::gates::comparison::{ComparisonGate, ComparisonGenerator};
|
||||
use serde::{de, ser, Deserialize, Serialize};
|
||||
|
||||
use crate::backends::plonky2::{
|
||||
|
|
@ -56,7 +57,8 @@ impl GateSerializer<F, D> for Pod2GateSerializer {
|
|||
GateAdapter::<NNFMulSimple<5, QuinticExtension<F>>>,
|
||||
RecursiveGateAdapter::<D, NNFMulSimple<5, QuinticExtension<F>>>,
|
||||
GateAdapter::<ECAddHomogOffset>,
|
||||
RecursiveGateAdapter::<D, ECAddHomogOffset>
|
||||
RecursiveGateAdapter::<D, ECAddHomogOffset>,
|
||||
ComparisonGate::<F, D>
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +129,8 @@ impl WitnessGeneratorSerializer<F, D> for Pod2GeneratorSerializer {
|
|||
RecursiveGenerator<D, NNFMulSimple<5, QuinticExtension<F>>>,
|
||||
RecursiveGenerator<1, NNFMulSimple<5, QuinticExtension<F>>>,
|
||||
RecursiveGenerator<D, ECAddHomogOffset>,
|
||||
RecursiveGenerator<1, ECAddHomogOffset>
|
||||
RecursiveGenerator<1, ECAddHomogOffset>,
|
||||
ComparisonGenerator<F, D>
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -250,3 +253,28 @@ impl<'de> Deserialize<'de> for VerifierCircuitDataSerializer {
|
|||
Ok(VerifierCircuitDataSerializer(circuit_data))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
backends::plonky2::mainpod::cache_get_rec_main_pod_circuit_data, middleware::Params,
|
||||
};
|
||||
|
||||
// Round trip of CircuitData serialization and deserialization. This test should pass if
|
||||
// we have registered all the gates and generators used in the recursive MainPod
|
||||
// circuit.
|
||||
#[test]
|
||||
fn test_serialize_main_pod_circuit_data() {
|
||||
let params = Params::default();
|
||||
let (_, circuit_data) = &*cache_get_rec_main_pod_circuit_data(¶ms);
|
||||
let gate_serializer = Pod2GateSerializer {};
|
||||
let generator_serializer = Pod2GeneratorSerializer {};
|
||||
let bytes = circuit_data
|
||||
.to_bytes(&gate_serializer, &generator_serializer)
|
||||
.unwrap();
|
||||
let circuit_data_de =
|
||||
CircuitData::from_bytes(&bytes, &gate_serializer, &generator_serializer).unwrap();
|
||||
assert_eq!(circuit_data.0, circuit_data_de);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue