-
Notifications
You must be signed in to change notification settings - Fork 396
fix: circom public inputs commitment #2077
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
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cec54d3
update batcher circom verifier to accept raw pub inputs
MarcosNicolau c22391e
update operator circom verifier to accept raw pub inputs
MarcosNicolau ddb130b
feat: sdk and cli parse input.json to the raw numbers
MarcosNicolau 81efbd2
chore: update fork to org
MarcosNicolau 2b7baa2
chore: update go mod to point to main branch commit
MarcosNicolau 6067e86
fix: avoid panic on invalid pub inputs length
MarcosNicolau 0f46e92
Explain why the replacement in the go.mod
MauroToscano be11294
chore: no pub input proof
MarcosNicolau 31b79ff
fix: docker no pub input circom target
MarcosNicolau 22f5049
chore: update docker sent proofs
MarcosNicolau 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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| pub mod constants; | ||
| pub mod errors; | ||
| pub mod types; | ||
| pub mod utils; |
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,32 @@ | ||
| use ethers::{abi::ethereum_types::FromDecStrErr, types::U256}; | ||
|
|
||
| /// Encodes Circom public inputs into a single byte vector. | ||
| /// | ||
| /// Circom normally outputs public inputs as a JSON array of strings, where each | ||
| /// entry is actually a big integer represented in decimal. For example: | ||
| /// | ||
| /// ```json | ||
| /// { "pubInputs": ["123", "456", "789"] } | ||
| /// ``` | ||
| /// | ||
| /// For on-chain usage (e.g. in Solidity), working with JSON is inefficient. | ||
| /// Instead, we prefer the **raw form**: each input is converted to a 32-byte | ||
| /// big-endian encoding of the integer, concatenated together. This makes it | ||
| /// simple to compute commitments and verify proofs on-chain, since the contract | ||
| /// receives a compact `bytes` array rather than parsing JSON. | ||
| /// | ||
| /// Each input must fit in 32 bytes (i.e. < 2^256). | ||
| pub fn encode_circom_pub_inputs(input: &[String]) -> Result<Vec<u8>, FromDecStrErr> { | ||
| let mut out = Vec::with_capacity(input.len() * 32); | ||
|
|
||
| for s in input { | ||
| // parse as decimal (base 10). Use from_str_radix(s, 16) if they're hex. | ||
| let n = U256::from_dec_str(s)?; | ||
| let mut bytes = [0u8; 32]; | ||
| n.to_big_endian(&mut bytes); | ||
|
|
||
| out.extend_from_slice(&bytes); | ||
| } | ||
|
|
||
| Ok(out) | ||
| } |
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.
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.