mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 12:49:23 +00:00
Fix serialization
This enabled getting the proof sizes, which are: - ConciseLinear had a proof size of 44607 bytes - CompromiseLinear had a proof size of 48765 bytes - ClassicLinear had a proof size of 56829 bytes - EfficientLinear had a proof size of 65145 byte
This commit is contained in:
@@ -9,6 +9,7 @@ use crate::{
|
||||
tests::cross_group::{G0, G1, transcript, generators}
|
||||
};
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#[cfg(feature = "serialize")]
|
||||
fn test_aos_serialization<const RING_LEN: usize>(proof: Aos<G0, G1, RING_LEN>, Re_0: Re<G0, G1>) {
|
||||
let mut buf = vec![];
|
||||
|
||||
@@ -49,7 +49,7 @@ pub(crate) fn generators() -> (Generators<G0>, Generators<G1>) {
|
||||
}
|
||||
|
||||
macro_rules! verify_and_deserialize {
|
||||
($type: ident, $proof: ident, $generators: ident, $keys: ident) => {
|
||||
($type: ty, $proof: ident, $generators: ident, $keys: ident) => {
|
||||
let public_keys = $proof.verify(&mut OsRng, &mut transcript(), $generators).unwrap();
|
||||
assert_eq!($generators.0.primary * $keys.0, public_keys.0);
|
||||
assert_eq!($generators.1.primary * $keys.1, public_keys.1);
|
||||
@@ -58,14 +58,14 @@ macro_rules! verify_and_deserialize {
|
||||
{
|
||||
let mut buf = vec![];
|
||||
$proof.serialize(&mut buf).unwrap();
|
||||
let deserialized = $type::<G0, G1>::deserialize(&mut std::io::Cursor::new(&buf)).unwrap();
|
||||
assert_eq!(proof, deserialized);
|
||||
let deserialized = <$type>::deserialize(&mut std::io::Cursor::new(&buf)).unwrap();
|
||||
assert_eq!($proof, deserialized);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! test_dleq {
|
||||
($str: expr, $benchmark: ident, $name: ident, $type: ident) => {
|
||||
($str: literal, $benchmark: ident, $name: ident, $type: ident) => {
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn $benchmark() {
|
||||
@@ -93,7 +93,7 @@ macro_rules! test_dleq {
|
||||
#[cfg(feature = "serialize")]
|
||||
{
|
||||
let mut buf = vec![];
|
||||
proofs[0].serialize(&mut buf);
|
||||
proofs[0].serialize(&mut buf).unwrap();
|
||||
println!("{} had a proof size of {} bytes", $str, buf.len());
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ macro_rules! test_dleq {
|
||||
res
|
||||
};
|
||||
|
||||
verify_and_deserialize!($type, proof, generators, keys);
|
||||
verify_and_deserialize!($type::<G0, G1>, proof, generators, keys);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,5 +183,10 @@ fn test_remainder() {
|
||||
).unwrap();
|
||||
assert_eq!(keys, res);
|
||||
|
||||
verify_and_deserialize!(ConciseLinearDLEq, proof, generators, keys);
|
||||
verify_and_deserialize!(
|
||||
ConciseLinearDLEq::<ProjectivePoint, ProjectivePoint>,
|
||||
proof,
|
||||
generators,
|
||||
keys
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user