-
Notifications
You must be signed in to change notification settings - Fork 0
Add CLI Commands for Frida-poc #17
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
Conversation
- Set up the main function outline - Added stubs for implementation functions without details
TODO: - Save commitment to the file
frozenspider
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed, left comments
src/main.rs
Outdated
| let mut input = String::new(); | ||
| io::stdin() | ||
| .read_line(&mut input) | ||
| .map_err(|_| "Failed to read input.".to_string())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed as suggested.
let mut input = String::new();
io::stdin()
.read_line(&mut input)
.expect("Failed to read input.");
src/main.rs
Outdated
| } | ||
| } | ||
|
|
||
| fn match_prover(prover: &mut Option<FridaProverType>) -> &mut FridaProverType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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);
}
}
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed as suggested.
And thanks for the detailed feedback. I really appreciate it!
frozenspider
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
BTW @0xwonj this PR has a really nice usage description, would you mind also making a README out of it? |
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.