Skip to content
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

Verify the challenge file exists before asking user to input randomness. #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/bin/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@ use powersoftau::*;

use std::fs::OpenOptions;
use std::io::{self, Read, BufReader, Write, BufWriter};
use std::path::Path;
use std::process;

fn main() {

// Check that the user placed the challenge file into the local directory
if !Path::new("./challenge").exists() {
println!("Error: ./challenge file not found.");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

panic! here would suffice instead of pulling in std::process.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here is that a regular error message is better for users, rather than a scary panic message.

If the compute binary is to be as bare bones as possible, where fewer dependencies is deemed better, I can change to panic.

process::exit(1);
}

// Create an RNG based on a mixture of system randomness and user provided randomness
let mut rng = {
use byteorder::{ReadBytesExt, BigEndian};
Expand Down