Skip to content

Commit

Permalink
Add pre-verification of Mina state
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbosio committed Sep 23, 2024
1 parent 2fe0dac commit 50ed685
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
28 changes: 28 additions & 0 deletions batcher/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions batcher/aligned-batcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ ciborium = "=0.2.2"
base64 = "0.22.1"
bs58 = "0.5.1"
priority-queue = "2.1.0"
mina-state-verifier-ffi = { path = "../../operator/mina/lib" }
24 changes: 19 additions & 5 deletions batcher/aligned-batcher/src/zk_utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::gnark::verify_gnark;
use crate::halo2::ipa::verify_halo2_ipa;
use crate::halo2::kzg::verify_halo2_kzg;
use crate::risc_zero::verify_risc_zero_proof;
use crate::sp1::verify_sp1_proof;
use crate::{gnark::verify_gnark, mina::verify_proof_integrity};
use aligned_sdk::core::types::{ProvingSystemId, VerificationData};
use log::{debug, warn};
use mina_state_verifier_ffi::verify_mina_state_ffi;

pub(crate) async fn verify(verification_data: &VerificationData) -> bool {
let verification_data = verification_data.clone();
Expand Down Expand Up @@ -114,10 +115,23 @@ fn verify_internal(verification_data: &VerificationData) -> bool {
.pub_input
.as_ref()
.expect("Public input is required");
verify_proof_integrity(&verification_data.proof, pub_input)
// TODO(xqft): add Pickles aggregator checks which are run alongside the Kimchi
// verifier. These checks are fast and if they aren't successful then the Pickles proof
// isn't valid.

const MAX_PROOF_SIZE: usize = 48 * 1024;
const MAX_PUB_INPUT_SIZE: usize = 6 * 1024;

let mut proof_buffer = [0; MAX_PROOF_SIZE];
for (buffer_item, proof_item) in proof_buffer.iter_mut().zip(&verification_data.proof) {
*buffer_item = *proof_item;
}
let proof_len = verification_data.proof.len();

let mut pub_input_buffer = [0; MAX_PUB_INPUT_SIZE];
for (buffer_item, pub_input_item) in pub_input_buffer.iter_mut().zip(pub_input) {
*buffer_item = *pub_input_item;
}
let pub_input_len = pub_input.len();

verify_mina_state_ffi(&proof_buffer, proof_len, &pub_input_buffer, pub_input_len)
}
ProvingSystemId::MinaAccount => {
verification_data
Expand Down

0 comments on commit 50ed685

Please sign in to comment.