Skip to content

Commit 6a167f5

Browse files
committed
Verify with null app_state
1 parent e490db3 commit 6a167f5

1 file changed

Lines changed: 27 additions & 7 deletions

File tree

  • operator/mina/lib/src/openmina_block_verifier
Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,39 @@
1+
use kimchi::mina_curves::pasta::Fp;
2+
use mina_tree::{
3+
proofs::{
4+
verification::verify_block,
5+
verifier_index::{get_verifier_index, VerifierKind},
6+
},
7+
verifier::get_srs,
8+
};
9+
use protocol_state_proof::parse_base64;
10+
111
mod protocol_state_proof;
212

3-
pub fn parse_query_to_mina_block_header(mina_state_proof_vk_query: &str) {
4-
todo!()
13+
pub fn verify_protocol_state_proof(
14+
mina_protocol_state_proof_base64_query: &str,
15+
) -> Result<bool, String> {
16+
let protocol_state_proof = parse_base64(mina_protocol_state_proof_base64_query)?;
17+
let verifier_index = get_verifier_index(VerifierKind::Blockchain);
18+
let srs = get_srs::<Fp>();
19+
let srs = srs.lock().unwrap();
20+
21+
Ok(verify_block(&protocol_state_proof, &verifier_index, &srs))
522
}
623

724
#[cfg(test)]
825
mod test {
9-
use super::parse_query_to_mina_block_header;
26+
use super::verify_protocol_state_proof;
1027

11-
const MINA_STATE_PROOF_VK_QUERY: &str = include_str!(
12-
"../../../../../batcher/aligned/test_files/mina/mina_state_proof_vk_query.json"
28+
const MINA_PROTOCOL_STATE_PROOF_BASE64_QUERY: &str = include_str!(
29+
"../../../../../batcher/aligned/test_files/mina/mina_protocol_state_proof_base64.json"
1330
);
1431

1532
#[test]
16-
fn test_parse_query_to_mina_block_header() {
17-
parse_query_to_mina_block_header(MINA_STATE_PROOF_VK_QUERY);
33+
fn test_verify_protocol_state_proof() {
34+
assert!(
35+
verify_protocol_state_proof(MINA_PROTOCOL_STATE_PROOF_BASE64_QUERY).unwrap(),
36+
"proof isn't valid!"
37+
);
1838
}
1939
}

0 commit comments

Comments
 (0)