From cdb64733f43dbe0c77091ed035d4d26ffab2d4c9 Mon Sep 17 00:00:00 2001 From: Jseam Date: Mon, 18 Dec 2023 23:48:04 +0800 Subject: [PATCH] fix: append 0x to proof (#668) --- src/execute.rs | 4 ++-- src/pfsys/mod.rs | 4 ++-- src/python.rs | 3 ++- src/wasm.rs | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/execute.rs b/src/execute.rs index 57f99fc90..046c22116 100644 --- a/src/execute.rs +++ b/src/execute.rs @@ -965,8 +965,8 @@ pub(crate) fn print_proof_hex(proof_path: PathBuf) -> Result>(); dict.set_item("instances", field_elems).unwrap(); let hex_proof = hex::encode(&self.proof); - dict.set_item("proof", hex_proof).unwrap(); + dict.set_item("proof", format!("0x{}", hex_proof)).unwrap(); dict.set_item("transcript_type", self.transcript_type) .unwrap(); dict.to_object(py) @@ -527,7 +527,7 @@ where &mut transcript, )?; let proof = transcript.finalize(); - let hex_proof = hex::encode(&proof); + let hex_proof = format!("0x{}", hex::encode(&proof)); let checkable_pf = Snark::new( protocol, diff --git a/src/python.rs b/src/python.rs index 059a496ed..61beedcd2 100644 --- a/src/python.rs +++ b/src/python.rs @@ -1015,7 +1015,8 @@ fn print_proof_hex(proof_path: PathBuf) -> Result { let proof = Snark::load::>(&proof_path) .map_err(|_| PyIOError::new_err("Failed to load proof"))?; - Ok(hex::encode(proof.proof)) + let hex_str = hex::encode(proof.proof); + Ok(format!("0x{}", hex_str)) } // Python Module diff --git a/src/wasm.rs b/src/wasm.rs index 6534a3cad..b58c1583b 100644 --- a/src/wasm.rs +++ b/src/wasm.rs @@ -388,7 +388,8 @@ pub fn prove( pub fn printProofHex(proof: wasm_bindgen::Clamped>) -> Result { let proof: crate::pfsys::Snark = serde_json::from_slice(&proof[..]) .map_err(|e| JsError::new(&format!("Failed to deserialize proof: {}", e)))?; - Ok(hex::encode(proof.proof)) + let hex_str = hex::encode(proof.proof); + Ok(format!("0x{}", hex_str)) } // VALIDATION FUNCTIONS