Parse and print JSON WitnessInput

This commit is contained in:
Oskar Thoren 2022-03-02 13:43:56 +08:00
parent e197f285ea
commit 7c856fd1b1
No known key found for this signature in database
GPG Key ID: B2ECCFD3BC2EF77E
2 changed files with 25 additions and 0 deletions

View File

@ -38,3 +38,7 @@ color-eyre = "0.5"
# tracing
tracing = "0.1"
tracing-subscriber = "0.2"
# json
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
serde_json = "1.0.48"

View File

@ -12,6 +12,23 @@ use tracing::{span, event, Level};
use ark_relations::r1cs::{ConstraintTrace, ConstraintLayer, ConstraintSystem, TracingMode};
use tracing_subscriber::layer::SubscriberExt;
// JSON
use serde::Deserialize;
use serde_json;
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
struct WitnessInput {
root: String,
nullifier_hash: String,
recipient: String,
relayer: String,
//fee: String,
fee: i32,
nullifier: String,
path_elements: Vec<String>,
path_indices: Vec<i32>,
}
fn groth16_proof_example() -> Result<()> {
println!("Circom 1");
@ -68,6 +85,10 @@ fn groth16_proof_example() -> Result<()> {
"pathIndices":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}
"#;
let witness : WitnessInput = serde_json::from_str(input_json_str).expect("JSON was not well-formatted");
println!("JSON: {:?}", witness);
println!("Circom 3");
// XXX Here - probably is inputs don't match,
// but would like the tracing to tell me this