Skip to content

Commit

Permalink
Merge pull request #424 from deltadevsde/fix-wasm
Browse files Browse the repository at this point in the history
fix: add deserialize function and change types to RV32IHyraxProof in wasm-related code
  • Loading branch information
sragss authored Jul 22, 2024
2 parents c3a8f52 + 25ef98a commit 80af41c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions jolt-core/src/jolt/vm/rv32i_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,19 @@ impl RV32IHyraxProof {
let file = File::open(path.into())?;
Ok(RV32IHyraxProof::deserialize_compressed(file)?)
}

/// Serializes the proof to a byte vector
pub fn serialize_to_bytes(&self) -> Result<Vec<u8>> {
let mut buffer = Vec::new();
self.serialize_compressed(&mut buffer)?;
Ok(buffer)
}

/// Deserializes a proof from a byte vector
pub fn deserialize_from_bytes(bytes: &[u8]) -> Result<Self> {
let cursor = std::io::Cursor::new(bytes);
Ok(RV32IHyraxProof::deserialize_compressed(cursor)?)
}
}

// ==================== TEST ====================
Expand Down
4 changes: 2 additions & 2 deletions jolt-sdk/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,10 @@ impl MacroBuilder {
#[wasm_bindgen]
#[cfg(all(target_arch = "wasm32", not(feature = "guest")))]
pub fn #verify_wasm_fn_name(preprocessing_data: &[u8], proof_bytes: &[u8]) -> bool {
use jolt::{Jolt, Proof, RV32IJoltVM};
use jolt::{Jolt, RV32IHyraxProof, RV32IJoltVM};

let decoded_preprocessing_data: DecodedData = deserialize_from_bin(preprocessing_data).unwrap();
let proof = Proof::deserialize_from_bytes(proof_bytes).unwrap();
let proof = RV32IHyraxProof::deserialize_from_bytes(proof_bytes).unwrap();

let preprocessing = RV32IJoltVM::preprocess(
decoded_preprocessing_data.bytecode,
Expand Down

0 comments on commit 80af41c

Please sign in to comment.