Răsfoiți Sursa

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

zero 2 ani în urmă
părinte
comite
993587ada7
1 a modificat fișierele cu 19 adăugiri și 1 ștergeri
  1. 19 1
      src/zk/debug.rs

+ 19 - 1
src/zk/debug.rs

@@ -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));