fn generate_verification_key<C: Circuit<Engine> + Clone, P: AsRef<Path>>(
    circuit: C,
    path: P,
) -> u32 {
    let path = path.as_ref();
    assert!(
        !path.exists(),
        "path for saving verification key exists: {}",
        path.display()
    );
    {
        File::create(path).expect("can't create file at verification key path");
        remove_file(path).unwrap_or_default()
    }

    log::info!("Transpiling circuit");
    let (gates_count, transpilation_hints) =
        transpile_with_gates_count(circuit.clone()).expect("failed to transpile");
    let size_log2 = gates_count.next_power_of_two().trailing_zeros();
    assert!(
        size_log2 <= 26,
        "power of two too big {}, max: 26",
        size_log2
    );

    // exodus circuit is to small for the smallest setup
    let size_log2 = std::cmp::max(20, size_log2);
    log::info!(
        "Reading setup file, gates_count: {}, pow2: {}",
        gates_count,
        size_log2
    );

    let key_monomial_form =
        get_universal_setup_monomial_form(size_log2).expect("Failed to read setup file.");

    log::info!("Generating setup");
    let setup = setup(circuit, &transpilation_hints).expect("failed to make setup");
    log::info!("Generating verification key");
    let verification_key = make_verification_key(&setup, &key_monomial_form)
        .expect("failed to create verification key");
    verification_key
        .write(File::create(path).unwrap())
        .expect("Failed to write verification file."); // unwrap - checked at the function entry
    log::info!("Verification key successfully generated");
    size_log2
}
/// Generates PLONK verification key for given circuit and saves key at the given path.
/// Returns used setup power of two. (e.g. 22)
Generates PLONK verification key for given circuit and saves key at the given path.
Returns used setup power of two.
Generates PLONK verification key for given circuit and saves key at the given path . Returns used setup power of two .
fn generate_verification_key<C: Circuit<Engine> + Clone, P: AsRef<Path>>(
    circuit: C,
    path: P,
) -> u32 {
    let path = path.as_ref();
    assert!(
        !path.exists(),
        "path for saving verification key exists: {}",
        path.display()
    );
    {
        File::create(path).expect("can't create file at verification key path");
        remove_file(path).unwrap_or_default()
    }
    log::info!("Transpiling circuit");
    let (gates_count, transpilation_hints) =
        transpile_with_gates_count(circuit.clone()).expect("failed to transpile");
    let size_log2 = gates_count.next_power_of_two().trailing_zeros();
    assert!(
        size_log2 <= 26,
        "power of two too big {}, max: 26",
        size_log2
    );
    // exodus circuit is to small for the smallest setup
    let size_log2 = std::cmp::max(20, size_log2);
    log::info!(
        "Reading setup file, gates_count: {}, pow2: {}",
        gates_count,
        size_log2
    );
    let key_monomial_form =
        get_universal_setup_monomial_form(size_log2).expect("Failed to read setup file.");
    log::info!("Generating setup");
    let setup = setup(circuit, &transpilation_hints).expect("failed to make setup");
    log::info!("Generating verification key");
    let verification_key = make_verification_key(&setup, &key_monomial_form)
        .expect("failed to create verification key");
    verification_key
        .write(File::create(path).unwrap())
        .expect("Failed to write verification file."); // unwrap - checked at the function entry
    log::info!("Verification key successfully generated");
    size_log2
}
fn generate_verification_key < C : Circuit < Engine > + Clone , P : AsRef < Path > > ( circuit : C , path : P , ) -> u32 { let path = path . as_ref ( ) ; assert ! ( path exists ( ) " " path display ( ) ) ; { File :: create ( path ) . expect ( " " ) ; remove_file ( path ) . unwrap_or_default ( ) } log :: info ! ( " " ) ; let ( gates_count , transpilation_hints ) = transpile_with_gates_count ( circuit . clone ( ) ) . expect ( " " ) ; let size_log2 = gates_count . next_power_of_two ( ) . trailing_zeros ( ) ; assert ! ( size_log2 26 " " size_log2 ) ; // exodus circuit is to small for the smallest setup let size_log2 = std :: cmp :: max ( 20 , size_log2 ) ; log :: info ! ( " " gates_count size_log2 ) ; let key_monomial_form = get_universal_setup_monomial_form ( size_log2 ) . expect ( " " ) ; log :: info ! ( " " ) ; let setup = setup ( circuit , & transpilation_hints ) . expect ( " " ) ; log :: info ! ( " " ) ; let verification_key = make_verification_key ( & setup , & key_monomial_form ) . expect ( " " ) ; verification_key . write ( File :: create ( path ) . unwrap ( ) ) . expect ( " " ) ; // unwrap - checked at the function entry log :: info ! ( " " ) ; size_log2 }
Generates PLONK verification key for given circuit and saves key at the given path.
Generates PLONK verification key for given circuit and saves key at the given path .
circuit
C
path
P