This is library with circuits and cryptography of ZeroPool.
Description of protocol https://hackmd.io/_Xm5DjqUTyykcBtDgMxLwA
JS binding available at https://github.com/zeropoolnetwork/libzeropool-rs
bash
cargo test --release -- --nocapture test_circuit_tx_setup_and_prove
Benchmark result on Intel Core i9-9880H
Time elapsed in setup() is: 48.573000645s
Time elapsed in prove() is: 6.915143894s
Time elapsed in verify() is: 5.104347ms
Example of key generation of keys and proof
```rust
fn testcircuittxsetupandprove() {
fn circuit
let mut rng = thread_rng();
let state = State::random_sample_state(&mut rng, &*POOL_PARAMS);
let (public, secret) = state.random_sample_transfer(&mut rng, &*POOL_PARAMS);
let ts_setup = Instant::now();
let params = setup::<Bn256, _, _, _>(circuit);
let duration = ts_setup.elapsed();
println!("Time elapsed in setup() is: {:?}", duration);
let ts_prove = Instant::now();
let (inputs, snark_proof) = prover::prove(¶ms, &public, &secret, circuit);
let duration = ts_prove.elapsed();
println!("Time elapsed in prove() is: {:?}", duration);
let ts_verify = Instant::now();
let res = verifier::verify(¶ms.get_vk(), &snark_proof, &inputs);
let duration = ts_verify.elapsed();
println!("Time elapsed in verify() is: {:?}", duration);
assert!(res, "Verifier result should be true");
}
```
```rust
fn testencryption() {
let mut rng = threadrng();
let sendereta = rng.gen();
let receivereta = rng.gen();
let mut account: Account
assert!(result_out.is_some(), "Could not decrypt outgoing data.");
let (account_out, note_out) = result_out.unwrap();
assert!(note.len()==note_out.len() &&
note.iter().zip(note_out.iter()).all(|(l,r)| l==r) &&
account == account_out, "Wrong outgoing data decrypted");
let result_out = cipher::decrypt_in(receiver_eta, &ciphertext, &*POOL_PARAMS);
assert!(result_out.len()==2 && result_out[0].is_some() && result_out[0].unwrap()==note[0] && result_out[1].is_none(), "Wrong incoming data decrypted");
}
```