mina_tree/proofs/
accumulator_check.rs1use mina_curves::pasta::{Fp, Vesta};
2use mina_p2p_messages::{
3 bigint::{BigInt, InvalidBigInt},
4 v2::PicklesProofProofsVerified2ReprStableV2,
5};
6use poly_commitment::{commitment::CommitmentCurve, ipa::SRS};
7
8use super::{public_input::scalar_challenge::ScalarChallenge, urs_utils};
9
10pub fn accumulator_check(
11 urs: &SRS<Vesta>,
12 proofs: &[&PicklesProofProofsVerified2ReprStableV2],
13) -> Result<bool, InvalidBigInt> {
14 let mut comms = Vec::with_capacity(proofs.len());
23 let mut bulletproof_challenges = vec![];
24
25 for proof in proofs {
26 let chals = &proof
27 .statement
28 .proof_state
29 .deferred_values
30 .bulletproof_challenges;
31 let mut chals: Vec<Fp> = chals
32 .iter()
33 .map(|chal| {
34 let prechallenge = &chal.prechallenge.inner;
35 let prechallenge: [u64; 2] = prechallenge.each_ref().map(|c| c.as_u64());
36
37 ScalarChallenge::limbs_to_field(&prechallenge)
38 })
39 .collect();
40
41 bulletproof_challenges.append(&mut chals);
42
43 let of_coord =
44 |(x, y): &(BigInt, BigInt)| Ok(Vesta::of_coordinates(x.to_field()?, y.to_field()?));
45
46 let acc_comm = &proof
48 .statement
49 .proof_state
50 .messages_for_next_wrap_proof
51 .challenge_polynomial_commitment;
52 let acc_comm: Vesta = of_coord(acc_comm)?;
53
54 comms.push(acc_comm);
55 }
56
57 let acc_check = urs_utils::batch_dlog_accumulator_check(urs, &comms, &bulletproof_challenges);
58
59 if !acc_check {
60 println!("accumulator_check failed");
61 }
62
63 Ok(acc_check)
64}