Add CLI Commands for Frida-poc - #17
Merged
Merged
Conversation
added 16 commits
June 17, 2024 09:23
- Set up the main function outline - Added stubs for implementation functions without details
TODO: - Save commitment to the file
frozenspider
requested changes
Jul 16, 2024
frozenspider
left a comment
Contributor
There was a problem hiding this comment.
Reviewed, left comments
frozenspider
requested changes
Jul 18, 2024
| let mut input = String::new(); | ||
| io::stdin() | ||
| .read_line(&mut input) | ||
| .map_err(|_| "Failed to read input.".to_string())?; |
Contributor
There was a problem hiding this comment.
Nit: In this method I think it makes sense to use unwrap/expect on IO stuff as those errors probably mean something is deeply wrong and we won't be able to recover anyway.
Author
There was a problem hiding this comment.
Changed as suggested.
let mut input = String::new();
io::stdin()
.read_line(&mut input)
.expect("Failed to read input.");| } | ||
| } | ||
|
|
||
| fn match_prover(prover: &mut Option<FridaProverType>) -> &mut FridaProverType { |
Contributor
There was a problem hiding this comment.
This is better to be done on an outer level, for several reasons, specifically:
- This should be caller's responsibility to provide a ready-to-use arguments
- This error is not actually fatal, and caller can recover from it
I suggest this:
fn main() {
let mut prover: Option<FridaProverType> = None;
fn try_unwrap_mut<T>(prover: &mut Option<T>) -> Result<&mut T, String> {
prover.as_mut().ok_or("Please call the init command first.".to_owned())
}
let mut iteration = || -> Result<(), String> {
let cli = read_and_parse_command()?;
match cli.command {
// ...
Commands::Commit { .. } => {
handle_commit(cli.command, try_unwrap_mut(&mut prover)?);
}
// ...
}
Ok(())
};
loop {
if let Err(err) = iteration() {
eprintln!("Error: {}", err);
}
}
}
Author
There was a problem hiding this comment.
Changed as suggested.
And thanks for the detailed feedback. I really appreciate it!
Contributor
|
BTW @0xwonj this PR has a really nice usage description, would you mind also making a README out of it? |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR Description
This PR introduces several CLI commands to the Frida Prover project, enabling users to initialize the system, generate data, create commitments, generate proofs, and verify proofs. The key additions are:
Running the Project
Run the project using Cargo with the following command:
Commands
Generate Data
Usage:
Generates a random data file of the specified size (in bytes).
generate-data 200(size ≥ 200 bytes)Options:
--data_path: Path to the data file. (default:data/data.bin)Note: Use double dash (
--) when specifying options.generate-data 200 --data_path custom/data.binInit
Usage:
Initializes the system with default or specified values. Should be called at the start.
Options:
--data_path: Path to the data file. (default:data/data.bin)--blowup_factor: Blowup factor of the evaluation domain (power of two). (default: 8)--folding_factor: Factor by which the degree of a polynomial is reduced with each FRI layer (one of 2, 4, 8, 16). (default: 2)--max_remainder_degree: Maximum allowed remainder polynomial degree. (default: 7)Note: Ensure the data file is present at the specified path. If not, use the
generate-datacommand to create the data first.Commit
Usage:
Generates a commitment from the data.
commit 31Open
Usage:
Generates a proof for the specified positions.
open 1 2 4,open 5Verify
Usage:
Verifies the generated proof.
This PR aims to enhance the functionality and usability of the Frida Prover project by providing a set of essential CLI commands. These commands allow users to perform critical operations such as data generation, system initialization, commitment creation, proof generation, and proof verification with ease.
Please review the changes and provide feedback.