-
Notifications
You must be signed in to change notification settings - Fork 39
pub_inputs support #215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
pub_inputs support #215
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
af8ad76
feat: pubwit struct
ashpect 3d5754a
feat: put pub wit at starting
ashpect 8e3a863
feat: prover addon
ashpect 3521416
feat: verifier updates
ashpect fba715e
feat: patch batch_prove
ashpect 09b4a3f
fix: rearrange for w2
ashpect 5cb683a
fix: reduce reduendancy in prove
ashpect 91859f8
chore: cleanup, remove logging and fmt
ashpect 6545a59
feat: fix ordering and hashing
ashpect efc2f07
chore: cleanup, namin, etc
ashpect 5bd5739
feat: add gnark support for public witness
ashpect ff7174a
feat: tooling support
ashpect 3534a95
feat: switch to skyscraper for hashing
ashpect 5122790
feat: fix dualmode
ashpect 0c5e3be
chore: cleanup
ashpect f9776b5
chore: cargofmt
ashpect 3c961eb
fix: cleanup reviews
ashpect 65cd065
fix: iotranscript
ashpect 278a7ff
chore: fmt
ashpect File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,87 @@ | ||
| use { | ||
| crate::FieldElement, | ||
| ark_serialize::{CanonicalDeserialize, CanonicalSerialize}, | ||
| serde::{ | ||
| de::{Error as _, SeqAccess, Visitor}, | ||
| ser::{Error as _, SerializeSeq}, | ||
| Deserializer, Serializer, | ||
| }, | ||
| std::fmt, | ||
| }; | ||
|
|
||
| pub fn serialize<S>(vec: &Vec<FieldElement>, serializer: S) -> Result<S::Ok, S::Error> | ||
| where | ||
| S: Serializer, | ||
| { | ||
| let is_human_readable = serializer.is_human_readable(); | ||
| let mut seq = serializer.serialize_seq(Some(vec.len()))?; | ||
| for element in vec { | ||
| let mut buf = Vec::with_capacity(element.compressed_size()); | ||
| element | ||
| .serialize_compressed(&mut buf) | ||
| .map_err(|e| S::Error::custom(format!("Failed to serialize: {e}")))?; | ||
|
|
||
| // Write bytes | ||
| if is_human_readable { | ||
| // ark_serialize doesn't have human-readable serialization. And Serde | ||
| // doesn't have good defaults for [u8]. So we implement hexadecimal | ||
| // serialization. | ||
| let hex = hex::encode(buf); | ||
| seq.serialize_element(&hex)?; | ||
| } else { | ||
| seq.serialize_element(&buf)?; | ||
| } | ||
| } | ||
| seq.end() | ||
| } | ||
|
|
||
| pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<FieldElement>, D::Error> | ||
| where | ||
| D: Deserializer<'de>, | ||
| { | ||
| struct VecVisitor { | ||
| is_human_readable: bool, | ||
| } | ||
|
|
||
| impl<'de> Visitor<'de> for VecVisitor { | ||
| type Value = Vec<FieldElement>; | ||
|
|
||
| fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { | ||
| formatter.write_str("a sequence of field elements") | ||
| } | ||
|
|
||
| fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error> | ||
| where | ||
| A: SeqAccess<'de>, | ||
| { | ||
| let mut vec = Vec::new(); | ||
| if self.is_human_readable { | ||
| while let Some(hex) = seq.next_element::<String>()? { | ||
| let bytes = hex::decode(hex) | ||
| .map_err(|e| A::Error::custom(format!("invalid hex: {e}")))?; | ||
| let mut reader = &*bytes; | ||
| let element = FieldElement::deserialize_compressed(&mut reader) | ||
| .map_err(|e| A::Error::custom(format!("deserialize failed: {e}")))?; | ||
| if !reader.is_empty() { | ||
| return Err(A::Error::custom("while deserializing: trailing bytes")); | ||
| } | ||
| vec.push(element); | ||
| } | ||
| } else { | ||
| while let Some(bytes) = seq.next_element::<Vec<u8>>()? { | ||
| let mut reader = &*bytes; | ||
| let element = FieldElement::deserialize_compressed(&mut reader) | ||
| .map_err(|e| A::Error::custom(format!("deserialize failed: {e}")))?; | ||
| if !reader.is_empty() { | ||
| return Err(A::Error::custom("while deserializing: trailing bytes")); | ||
| } | ||
| vec.push(element); | ||
| } | ||
| } | ||
| Ok(vec) | ||
| } | ||
| } | ||
|
|
||
| let is_human_readable = deserializer.is_human_readable(); | ||
| deserializer.deserialize_seq(VecVisitor { is_human_readable }) | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.