Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit 79153a9

Browse files
committed
chunk-prover: check proof after generated
1 parent 8f17df8 commit 79153a9

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

prover/src/zkevm/prover.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use eth_types::l2_types::BlockTrace;
1414
pub struct Prover {
1515
// Make it public for testing with inner functions (unnecessary for FFI).
1616
pub inner: common::Prover,
17+
verifier: super::verifier::Verifier,
1718
raw_vk: Option<Vec<u8>>,
1819
}
1920

@@ -30,7 +31,13 @@ impl Prover {
3031
);
3132
}
3233

33-
Self { inner, raw_vk }
34+
let verifier = super::verifier::Verifier::from_dirs(params_dir, assets_dir);
35+
36+
Self {
37+
inner,
38+
raw_vk,
39+
verifier,
40+
}
3441
}
3542

3643
pub fn get_vk(&self) -> Option<Vec<u8>> {
@@ -73,7 +80,9 @@ impl Prover {
7380

7481
self.check_and_clear_raw_vk();
7582

76-
match output_dir.and_then(|output_dir| ChunkProof::from_json_file(output_dir, &name).ok()) {
83+
let chunk_proof = match output_dir
84+
.and_then(|output_dir| ChunkProof::from_json_file(output_dir, &name).ok())
85+
{
7786
Some(proof) => Ok(proof),
7887
None => {
7988
let chunk_hash = ChunkHash::from_witness_block(&witness_block, false);
@@ -87,7 +96,13 @@ impl Prover {
8796

8897
result
8998
}
99+
}?;
100+
101+
if !self.verifier.verify_chunk_proof(chunk_proof.clone()) {
102+
anyhow::bail!("chunk prover cannot generate valid proof");
90103
}
104+
105+
Ok(chunk_proof)
91106
}
92107

93108
fn check_and_clear_raw_vk(&mut self) {

0 commit comments

Comments
 (0)