-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement FromBytes and ToBytes for ProverKey and VerifierKey * Implement FromBytes and ToBytes for srs * Implement FromBytes and ToBytes for Proof * Add serde macro * Implement Serde for Proof, SRS, ProverKey and VerifierKey
- Loading branch information
1 parent
1702222
commit a8d8f3e
Showing
17 changed files
with
1,058 additions
and
34 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
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
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,42 @@ | ||
macro_rules! impl_serde { | ||
($w : ident) => { | ||
impl Serialize for $w { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
{ | ||
serializer.serialize_bytes(&self.to_bytes()[..]) | ||
} | ||
} | ||
|
||
impl<'de> Deserialize<'de> for $w { | ||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
{ | ||
struct StructVisitor; | ||
|
||
impl<'de> Visitor<'de> for StructVisitor { | ||
type Value = $w; | ||
|
||
fn expecting( | ||
&self, | ||
formatter: &mut ::core::fmt::Formatter, | ||
) -> ::core::fmt::Result { | ||
let struct_name = String::from(stringify!($w)); | ||
formatter.write_fmt(format_args!("expected a valid {}", struct_name)) | ||
} | ||
|
||
fn visit_bytes<E>(self, v: &[u8]) -> Result<$w, E> | ||
where | ||
E: serde::de::Error, | ||
{ | ||
return $w::from_bytes(v).map_err(serde::de::Error::custom); | ||
} | ||
} | ||
|
||
deserializer.deserialize_bytes(StructVisitor) | ||
} | ||
} | ||
}; | ||
} |
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
Oops, something went wrong.
Is there any reason why this was removed? Or it was just that you didn't rebase to `master``before merging @kevaundray ?