implement copy_json in rust
This commit is contained in:
parent
4d9afd031c
commit
8f7f1f44f8
30
phase2/src/bin/copy_json.rs
Normal file
30
phase2/src/bin/copy_json.rs
Normal file
@ -0,0 +1,30 @@
|
||||
extern crate exitcode;
|
||||
extern crate serde_json;
|
||||
|
||||
use std::fs;
|
||||
use serde_json::*;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
if args.len() != 4 {
|
||||
println!("Usage: \n<reference_key.json> <in_key.json> <out_key.json>");
|
||||
std::process::exit(exitcode::USAGE);
|
||||
}
|
||||
let ref_file = &args[1];
|
||||
let in_file = &args[2];
|
||||
let out_file = &args[3];
|
||||
|
||||
let in_json: Map<String, Value> = serde_json::from_str(&fs::read_to_string(in_file).unwrap()).unwrap();
|
||||
let mut reference_json: Map<String, Value> = serde_json::from_str(&fs::read_to_string(ref_file).unwrap()).unwrap();
|
||||
|
||||
for (key, value) in &in_json {
|
||||
reference_json[key] = value.clone();
|
||||
}
|
||||
|
||||
if reference_json.contains_key("vk_alfabeta_12") {
|
||||
reference_json.remove("vk_alfabeta_12").unwrap();
|
||||
}
|
||||
|
||||
fs::write(out_file, serde_json::to_string(&reference_json).unwrap().as_bytes()).unwrap();
|
||||
println!("Done");
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
import json
|
||||
|
||||
f = json.load(open('proving_key.json'))
|
||||
f2 = json.load(open('pk.json'))
|
||||
|
||||
for k in f2:
|
||||
f[k] = f2[k]
|
||||
|
||||
f3 = open('transformed_pk.json', 'w')
|
||||
f3.write(json.dumps(f))
|
||||
f3.close()
|
||||
|
||||
f = json.load(open('verification_key.json'))
|
||||
f2 = json.load(open('vk.json'))
|
||||
|
||||
for k in f2:
|
||||
f[k] = f2[k]
|
||||
|
||||
del f['vk_alfabeta_12']
|
||||
|
||||
f3 = open('transformed_vk.json', 'w')
|
||||
f3.write(json.dumps(f))
|
||||
f3.close()
|
Loading…
Reference in New Issue
Block a user