zkcrypto / bellman

zk-SNARK library.
Other
989 stars 534 forks source link

How to export params to JSON file #34

Open drbh opened 5 years ago

drbh commented 5 years ago

I am a bit confused about saving the params, proofs and pvk as JSON files so I can move them between machines.

I've followed the example repo at https://github.com/arcalinea/bellman-examples/blob/master/src/cube.rs#L154 and also see a write implementation on the proof structure here: https://github.com/zkcrypto/bellman/blob/master/src/groth16/mod.rs#L43

Can someone help me export these variables?

drewstone commented 5 years ago

Not JSON but mayne this helps? Use whatever circuit instead of what I've provided.

use std::fs;
let params = generate_random_parameters::<Bn256, _, _>(
    MerkleTreeCircuit {
        params: j_params,
        nullifier: None,
        secret: None,
        proof: vec![],
    },
    rng,
)?;

let mut v = vec![];
params.write(&mut v)?;

fs::write("test/test.params", hex::encode(&v[..]).unwrap();