fn load_params(file_name: &str) -> Parameters<Bls12> {
    match File::open(format!("{}.params", file_name)) {
        Ok(file) => Parameters::read(BufReader::new(file), false).expect("Cannot read from file."),
        Err(_) => {
            let params = match file_name {
                "cred" => {
                    let time_start = Instant::now();
                    let params = credential::generator::generate_random_parameters()
                        .expect("Parameter generation should not fail.");
                    let duration = time_start.elapsed();
                    println!(
                        "CREDENTIAL parameter generation took {} seconds",
                        duration.as_secs_f64()
                    );
                    params
                }
                "c_to" => {
                    let time_start = Instant::now();
                    let params = convert_to::generator::generate_random_parameters()
                        .expect("Parameter generation should not fail.");
                    let duration = time_start.elapsed();
                    println!(
                        "CONVERT_TO parameter generation took {} seconds",
                        duration.as_secs_f64()
                    );
                    params
                }
                "c_from" => {
                    let time_start = Instant::now();
                    let params = convert_from::generator::generate_random_parameters()
                        .expect("Parameter generation should not fail.");
                    let duration = time_start.elapsed();
                    println!(
                        "CONVERT_FROM parameter generation took {} seconds",
                        duration.as_secs_f64()
                    );
                    params
                }
                "transfer" => {
                    let time_start = Instant::now();
                    let (params, saver_keys) = transfer::generator::generate_random_parameters()
                        .expect("Parameter generation should not fail.");
                    let duration = time_start.elapsed();
                    println!(
                        "TRANSFER parameter generation (incl. SAVER) took {} seconds",
                        duration.as_secs_f64()
                    );
                    let mut file = BufWriter::new(
                        File::create(format!("{}.saver", file_name)).expect("Cannot create file."),
                    );
                    saver_keys
                        .write(file.by_ref())
                        .expect("Cannot write to file.");
                    file.flush().expect("Cannot flush buffer to file.");
                    params
                }
                _ => panic!("Unknown parameter type."),
            };
            let mut file = BufWriter::new(
                File::create(format!("{}.params", file_name)).expect("Cannot create file."),
            );
            params.write(file.by_ref()).expect("Cannot write to file.");
            file.flush().expect("Cannot flush buffer to file.");
            params
        }
    }
}
/// Function to load the parameters of type `file_name` from the corresponding file. If the file
/// does not exist, the parameters are generated and written to a new file with name `file_name`.
Function to load the parameters of type `file_name` from the corresponding file. If the file
does not exist, the parameters are generated and written to a new file with name `file_name`.
Function to load the parameters of type ` file_name ` from the corresponding file . If the file does not exist the parameters are generated and written to a new file with name ` file_name ` .
fn load_params(file_name: &str) -> Parameters<Bls12> {
    match File::open(format!("{}.params", file_name)) {
        Ok(file) => Parameters::read(BufReader::new(file), false).expect("Cannot read from file."),
        Err(_) => {
            let params = match file_name {
                "cred" => {
                    let time_start = Instant::now();
                    let params = credential::generator::generate_random_parameters()
                        .expect("Parameter generation should not fail.");
                    let duration = time_start.elapsed();
                    println!(
                        "CREDENTIAL parameter generation took {} seconds",
                        duration.as_secs_f64()
                    );
                    params
                }
                "c_to" => {
                    let time_start = Instant::now();
                    let params = convert_to::generator::generate_random_parameters()
                        .expect("Parameter generation should not fail.");
                    let duration = time_start.elapsed();
                    println!(
                        "CONVERT_TO parameter generation took {} seconds",
                        duration.as_secs_f64()
                    );
                    params
                }
                "c_from" => {
                    let time_start = Instant::now();
                    let params = convert_from::generator::generate_random_parameters()
                        .expect("Parameter generation should not fail.");
                    let duration = time_start.elapsed();
                    println!(
                        "CONVERT_FROM parameter generation took {} seconds",
                        duration.as_secs_f64()
                    );
                    params
                }
                "transfer" => {
                    let time_start = Instant::now();
                    let (params, saver_keys) = transfer::generator::generate_random_parameters()
                        .expect("Parameter generation should not fail.");
                    let duration = time_start.elapsed();
                    println!(
                        "TRANSFER parameter generation (incl. SAVER) took {} seconds",
                        duration.as_secs_f64()
                    );
                    let mut file = BufWriter::new(
                        File::create(format!("{}.saver", file_name)).expect("Cannot create file."),
                    );
                    saver_keys
                        .write(file.by_ref())
                        .expect("Cannot write to file.");
                    file.flush().expect("Cannot flush buffer to file.");
                    params
                }
                _ => panic!("Unknown parameter type."),
            };
            let mut file = BufWriter::new(
                File::create(format!("{}.params", file_name)).expect("Cannot create file."),
            );
            params.write(file.by_ref()).expect("Cannot write to file.");
            file.flush().expect("Cannot flush buffer to file.");
            params
        }
    }
}
fn load_params ( file_name : & str ) -> Parameters < Bls12 > { match File :: open ( format ! ( " " file_name ) ) { Ok ( file ) => Parameters :: read ( BufReader :: new ( file ) , false ) . expect ( " " ) , Err ( _ ) => { let params = match file_name { " " => { let time_start = Instant :: now ( ) ; let params = credential :: generator :: generate_random_parameters ( ) . expect ( " " ) ; let duration = time_start . elapsed ( ) ; println ! ( " " duration as_secs_f64 ( ) ) ; params } " " => { let time_start = Instant :: now ( ) ; let params = convert_to :: generator :: generate_random_parameters ( ) . expect ( " " ) ; let duration = time_start . elapsed ( ) ; println ! ( " " duration as_secs_f64 ( ) ) ; params } " " => { let time_start = Instant :: now ( ) ; let params = convert_from :: generator :: generate_random_parameters ( ) . expect ( " " ) ; let duration = time_start . elapsed ( ) ; println ! ( " " duration as_secs_f64 ( ) ) ; params } " " => { let time_start = Instant :: now ( ) ; let ( params , saver_keys ) = transfer :: generator :: generate_random_parameters ( ) . expect ( " " ) ; let duration = time_start . elapsed ( ) ; println ! ( " " duration as_secs_f64 ( ) ) ; let mut file = BufWriter :: new ( File :: create ( format ! ( " " file_name ) ) . expect ( " " ) , ) ; saver_keys . write ( file . by_ref ( ) ) . expect ( " " ) ; file . flush ( ) . expect ( " " ) ; params } _ => panic ! ( " " ) , } ; let mut file = BufWriter :: new ( File :: create ( format ! ( " " file_name ) ) . expect ( " " ) , ) ; params . write ( file . by_ref ( ) ) . expect ( " " ) ; file . flush ( ) . expect ( " " ) ; params } } }
Function to load the parameters of type `file_name` from the corresponding file.
Function to load the parameters of type ` file_name ` from the corresponding file .
file_name
&str
file_name
&str