-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change makes the `serde` dependency optional to reduce the total number of them from 57 to 51 using `--no-default-features` flag. Also for simpler maintainablity, moved `SerializableProof` into separate `serializable` modules, so by placing `#[cfg(feature = "serde")]` above it's declaration the whole implementations and structures became optional (instead of placing `#[cfg(feature = "serde")]` above each of them). Removed usage of `serde` inside tests for more prefered `Debug` implementations.
- Loading branch information
Showing
9 changed files
with
158 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use k256::{AffinePoint, ProjectivePoint, Scalar}; | ||
|
||
use super::Proof; | ||
|
||
/// Represent serializable version of arithmetic circuit proof (uses AffinePoint instead of ProjectivePoint). | ||
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] | ||
pub struct SerializableProof { | ||
pub c_l: AffinePoint, | ||
pub c_r: AffinePoint, | ||
pub c_o: AffinePoint, | ||
pub c_s: AffinePoint, | ||
pub r: Vec<AffinePoint>, | ||
pub x: Vec<AffinePoint>, | ||
pub l: Vec<Scalar>, | ||
pub n: Vec<Scalar>, | ||
} | ||
|
||
impl From<&SerializableProof> for Proof { | ||
fn from(value: &SerializableProof) -> Self { | ||
return Proof { | ||
c_l: ProjectivePoint::from(&value.c_l), | ||
c_r: ProjectivePoint::from(&value.c_r), | ||
c_o: ProjectivePoint::from(&value.c_o), | ||
c_s: ProjectivePoint::from(&value.c_s), | ||
r: value.r.iter().map(|r_val| ProjectivePoint::from(r_val)).collect::<Vec<ProjectivePoint>>(), | ||
x: value.x.iter().map(|x_val| ProjectivePoint::from(x_val)).collect::<Vec<ProjectivePoint>>(), | ||
l: value.l.clone(), | ||
n: value.n.clone(), | ||
}; | ||
} | ||
} | ||
|
||
impl From<&Proof> for SerializableProof { | ||
fn from(value: &Proof) -> Self { | ||
return SerializableProof { | ||
c_l: value.c_l.to_affine(), | ||
c_r: value.c_r.to_affine(), | ||
c_o: value.c_o.to_affine(), | ||
c_s: value.c_s.to_affine(), | ||
r: value.r.iter().map(|r_val| r_val.to_affine()).collect::<Vec<AffinePoint>>(), | ||
x: value.x.iter().map(|x_val| x_val.to_affine()).collect::<Vec<AffinePoint>>(), | ||
l: value.l.clone(), | ||
n: value.n.clone(), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
pub mod reciprocal; | ||
pub mod u64_proof; | ||
pub mod u64_proof; | ||
|
||
#[cfg(feature = "serde")] | ||
mod serializable; | ||
|
||
#[cfg(feature = "serde")] | ||
pub use serializable::SerializableProof; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use k256::{AffinePoint, ProjectivePoint}; | ||
|
||
use crate::circuit; | ||
|
||
use super::reciprocal::Proof; | ||
|
||
|
||
/// Represent serializable version of reciprocal proof (uses AffinePoint instead of ProjectivePoint | ||
/// and serialized version of circuit proof). | ||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] | ||
pub struct SerializableProof { | ||
pub circuit_proof: circuit::SerializableProof, | ||
pub r: AffinePoint, | ||
} | ||
|
||
impl From<&SerializableProof> for Proof { | ||
fn from(value: &SerializableProof) -> Self { | ||
return Proof { | ||
circuit_proof: circuit::Proof::from(&value.circuit_proof), | ||
r: ProjectivePoint::from(value.r), | ||
}; | ||
} | ||
} | ||
|
||
impl From<&Proof> for SerializableProof { | ||
fn from(value: &Proof) -> Self { | ||
return SerializableProof { | ||
circuit_proof: circuit::SerializableProof::from(&value.circuit_proof), | ||
r: value.r.to_affine(), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use k256::{AffinePoint, ProjectivePoint, Scalar}; | ||
|
||
use super::Proof; | ||
|
||
/// Represent serializable version of weight norm linear argument proof (uses AffinePoint instead of ProjectivePoint). | ||
#[derive(Clone, Debug)] | ||
pub struct SerializableProof { | ||
pub r: Vec<AffinePoint>, | ||
pub x: Vec<AffinePoint>, | ||
pub l: Vec<Scalar>, | ||
pub n: Vec<Scalar>, | ||
} | ||
|
||
impl From<&SerializableProof> for Proof { | ||
fn from(value: &SerializableProof) -> Self { | ||
return Proof { | ||
r: value.r.iter().map(ProjectivePoint::from).collect::<Vec<ProjectivePoint>>(), | ||
x: value.x.iter().map(ProjectivePoint::from).collect::<Vec<ProjectivePoint>>(), | ||
l: value.l.clone(), | ||
n: value.n.clone(), | ||
}; | ||
} | ||
} | ||
|
||
impl From<&Proof> for SerializableProof { | ||
fn from(value: &Proof) -> Self { | ||
return SerializableProof { | ||
r: value.r.iter().map(|r_val| r_val.to_affine()).collect::<Vec<AffinePoint>>(), | ||
x: value.x.iter().map(|x_val| x_val.to_affine()).collect::<Vec<AffinePoint>>(), | ||
l: value.l.clone(), | ||
n: value.n.clone(), | ||
}; | ||
} | ||
} |