zk/debug: add Uint32 and MerklePath for export_witness_json()

This commit is contained in:
zero
2024-01-10 10:02:42 +01:00
committed by lunar-mining
parent 690b747b26
commit 9a2505c9e1

View File

@@ -22,7 +22,9 @@ use log::error;
#[cfg(feature = "tinyjson")]
use {
std::{collections::HashMap, fs::File, io::Write, path::Path},
tinyjson::JsonValue::{Array as JsonArray, Object as JsonObj, String as JsonStr},
tinyjson::JsonValue::{
Array as JsonArray, Number as JsonNum, Object as JsonObj, String as JsonStr,
},
};
use super::{Witness, ZkCircuit};
@@ -51,6 +53,22 @@ pub fn export_witness_json<P: AsRef<Path>>(
w1
});
}
Witness::Uint32(value) => {
value.map(|w1| {
value_json.insert("Uint32".to_string(), JsonNum(w1.into()));
w1
});
}
Witness::MerklePath(value) => {
let mut path = Vec::new();
value.map(|w1| {
for node in w1 {
path.push(JsonStr(format!("{:?}", node.inner())));
}
w1
});
value_json.insert("MerklePath".to_string(), JsonArray(path));
}
_ => unimplemented!(),
}
witnesses.push(JsonObj(value_json));