Skip to content

Commit

Permalink
fix: output block proof to array format (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
atanmarko authored Aug 23, 2024
1 parent 6c455ec commit b5124fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 6 additions & 4 deletions zero_bin/prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ pub async fn prove(
// or alternatively return proof as function result.
let return_proof: Option<GeneratedBlockProof> =
if let Some(output_dir) = proof_output_dir {
write_proof_to_dir(output_dir, &proof).await?;
write_proof_to_dir(output_dir, proof.clone()).await?;
None
} else {
Some(proof.clone())
Expand All @@ -259,7 +259,7 @@ pub async fn prove(
// or alternatively return proof as function result.
let return_proof: Option<GeneratedBlockProof> =
if let Some(output_dir) = proof_output_dir {
write_proof_to_dir(output_dir, &proof).await?;
write_proof_to_dir(output_dir, proof.clone()).await?;
None
} else {
Some(proof.clone())
Expand All @@ -285,11 +285,13 @@ pub async fn prove(
}

/// Write the proof to the `output_dir` directory.
async fn write_proof_to_dir(output_dir: PathBuf, proof: &GeneratedBlockProof) -> Result<()> {
let proof_serialized = serde_json::to_vec(proof)?;
async fn write_proof_to_dir(output_dir: PathBuf, proof: GeneratedBlockProof) -> Result<()> {
let block_proof_file_path =
generate_block_proof_file_name(&output_dir.to_str(), proof.b_height);

// Serialize as a single element array to match the expected format.
let proof_serialized = serde_json::to_vec(&vec![proof])?;

if let Some(parent) = block_proof_file_path.parent() {
tokio::fs::create_dir_all(parent).await?;
}
Expand Down
3 changes: 1 addition & 2 deletions zero_bin/tools/prove_rpc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ if [ "$RUN_VERIFICATION" = true ]; then

proof_file_name=$PROOF_OUTPUT_DIR/b$END_BLOCK.zkproof
echo "Verifying the proof of the latest block in the interval:" $proof_file_name
echo [ > $PROOF_OUTPUT_DIR/proofs.json && cat $proof_file_name >> $PROOF_OUTPUT_DIR/proofs.json && echo ] >> $PROOF_OUTPUT_DIR/proofs.json
cargo r --release --bin verifier -- -f $PROOF_OUTPUT_DIR/proofs.json > $PROOF_OUTPUT_DIR/verify.out 2>&1
cargo r --release --bin verifier -- -f $proof_file_name > $PROOF_OUTPUT_DIR/verify.out 2>&1

if grep -q 'All proofs verified successfully!' $PROOF_OUTPUT_DIR/verify.out; then
echo "All proofs verified successfully!";
Expand Down

0 comments on commit b5124fa

Please sign in to comment.