Skip to content

Commit

Permalink
chore: remove gen_circuit_settings wasm bindings (zkonduit#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-crypto authored Jul 31, 2023
1 parent 113452b commit a23d75a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 81 deletions.
16 changes: 0 additions & 16 deletions src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,6 @@ pub fn elgamal_decrypt_wasm(
serde_json::to_vec(&output).unwrap()
}

/// Generate circuit params in browser
#[wasm_bindgen]
pub fn gen_circuit_settings_wasm(
model_ser: wasm_bindgen::Clamped<Vec<u8>>,
run_args_ser: wasm_bindgen::Clamped<Vec<u8>>,
) -> Vec<u8> {
let run_args: crate::commands::RunArgs = serde_json::from_slice(&run_args_ser[..]).unwrap();

// Read in circuit
let mut reader = std::io::BufReader::new(&model_ser[..]);
let model = crate::graph::Model::new(&mut reader, run_args).unwrap();
let circuit = GraphCircuit::new(model, run_args, crate::circuit::CheckMode::UNSAFE).unwrap();
let circuit_settings = circuit.settings;
serde_json::to_vec(&circuit_settings).unwrap()
}

/// Generate proving key in browser
#[wasm_bindgen]
pub fn gen_pk_wasm(
Expand Down
66 changes: 1 addition & 65 deletions tests/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ mod wasm32 {
use ezkl::circuit::modules::poseidon::spec::{PoseidonSpec, POSEIDON_RATE, POSEIDON_WIDTH};
use ezkl::circuit::modules::poseidon::PoseidonChip;
use ezkl::circuit::modules::Module;
use ezkl::circuit::Tolerance;
use ezkl::commands::RunArgs;
use ezkl::graph::modules::POSEIDON_LEN_GRAPH;
use ezkl::graph::GraphSettings;
use ezkl::pfsys::Snark;
use ezkl::wasm::{
elgamal_decrypt_wasm, elgamal_encrypt_wasm, gen_circuit_settings_wasm, gen_pk_wasm,
elgamal_decrypt_wasm, elgamal_encrypt_wasm, gen_pk_wasm,
gen_vk_wasm, poseidon_hash_wasm, prove_wasm, verify_wasm,
};
use halo2curves::bn256::{Fr, G1Affine};
Expand Down Expand Up @@ -136,34 +133,6 @@ mod wasm32 {
assert!(value);
}

#[wasm_bindgen_test]
async fn gen_circuit_settings_test() {
let run_args = RunArgs {
tolerance: Tolerance::default(),
scale: 7,
bits: 16,
logrows: 17,
batch_size: 1,
input_visibility: "private".into(),
output_visibility: "public".into(),
param_visibility: "private".into(),
allocated_constraints: Some(1000), // assuming an arbitrary value here for the sake of the example
};

let serialized_run_args =
serde_json::to_vec(&run_args).expect("Failed to serialize RunArgs");

let circuit_settings_ser = gen_circuit_settings_wasm(
wasm_bindgen::Clamped(NETWORK.to_vec()),
wasm_bindgen::Clamped(serialized_run_args),
);

assert!(circuit_settings_ser.len() > 0);

let _circuit_settings: GraphSettings =
serde_json::from_slice(&circuit_settings_ser[..]).unwrap();
}

#[wasm_bindgen_test]
async fn gen_pk_test() {
let pk = gen_pk_wasm(
Expand Down Expand Up @@ -191,39 +160,6 @@ mod wasm32 {
assert!(vk.len() > 0);
}

#[wasm_bindgen_test]
async fn circuit_settings_is_valid_test() {
let run_args = RunArgs {
tolerance: Tolerance::default(),
scale: 0,
bits: 5,
logrows: 7,
batch_size: 1,
input_visibility: "private".into(),
output_visibility: "public".into(),
param_visibility: "private".into(),
allocated_constraints: Some(1000), // assuming an arbitrary value here for the sake of the example
};

let serialized_run_args =
serde_json::to_vec(&run_args).expect("Failed to serialize RunArgs");

let circuit_settings_ser = gen_circuit_settings_wasm(
wasm_bindgen::Clamped(NETWORK.to_vec()),
wasm_bindgen::Clamped(serialized_run_args),
);

assert!(circuit_settings_ser.len() > 0);

let pk = gen_pk_wasm(
wasm_bindgen::Clamped(NETWORK.to_vec()),
wasm_bindgen::Clamped(KZG_PARAMS.to_vec()),
wasm_bindgen::Clamped(circuit_settings_ser),
);

assert!(pk.len() > 0);
}

#[wasm_bindgen_test]
async fn pk_is_valid_test() {
let pk = gen_pk_wasm(
Expand Down

0 comments on commit a23d75a

Please sign in to comment.