@@ -7,40 +7,77 @@ use poly_commitment::{commitment::CommitmentCurve, srs::SRS};
77use super :: public_input:: scalar_challenge:: ScalarChallenge ;
88use super :: urs_utils;
99
10+ /*
11+ let%bind accumulator_check =
12+ Ipa.Step.accumulator_check
13+ (List.map ts ~f:(fun (T (_, _, _, _, _, T t)) ->
14+ ( t.statement.proof_state.messages_for_next_wrap_proof
15+ .challenge_polynomial_commitment
16+ , Ipa.Step.compute_challenges
17+ t.statement.proof_state.deferred_values.bulletproof_challenges ) )
18+ )
19+
20+
21+ let accumulator_check comm_chals =
22+ let chals =
23+ Array.concat
24+ @@ List.map comm_chals ~f:(fun (_, chals) -> Vector.to_array chals)
25+ in
26+ let comms =
27+ Array.of_list_map comm_chals ~f:(fun (comm, _) ->
28+ Or_infinity.Finite comm )
29+ in
30+ let urs = Backend.Tick.Keypair.load_urs () in
31+ Promise.run_in_thread (fun () ->
32+ Kimchi_bindings.Protocol.SRS.Fp.batch_accumulator_check urs
33+ (Array.map comms ~f:or_infinite_conv)
34+ chals )
35+ */
36+
1037pub fn accumulator_check (
1138 urs : & SRS < Vesta > ,
12- proof : & PicklesProofProofsVerified2ReprStableV2 ,
39+ proofs : & [ & PicklesProofProofsVerified2ReprStableV2 ] ,
1340) -> Result < bool , InvalidBigInt > {
1441 // accumulator check
1542 // Note:
1643 // comms: statement.proof_state.messages_for_next_wrap_proof.challenge_polynomial_commitment
1744 // chals: statement.proof_state.deferred_values.bulletproof_challenges
1845
19- let deferred_values = & proof. statement . proof_state . deferred_values ;
20- let bulletproof_challenges = & deferred_values. bulletproof_challenges ;
21- let bulletproof_challenges: Vec < Fp > = bulletproof_challenges
22- . iter ( )
23- . map ( |chal| {
24- let prechallenge = & chal. prechallenge . inner ;
25- let prechallenge: [ u64 ; 2 ] = prechallenge. each_ref ( ) . map ( |c| c. as_u64 ( ) ) ;
26-
27- ScalarChallenge :: limbs_to_field ( & prechallenge)
28- } )
29- . collect ( ) ;
30-
31- let of_coord =
32- |( x, y) : & ( BigInt , BigInt ) | Ok ( Vesta :: of_coordinates ( x. to_field ( ) ?, y. to_field ( ) ?) ) ;
33-
34- // statement.proof_state.messages_for_next_wrap_proof.challenge_polynomial_commitment
35- let acc_comm = & proof
36- . statement
37- . proof_state
38- . messages_for_next_wrap_proof
39- . challenge_polynomial_commitment ;
40- let acc_comm: Vesta = of_coord ( acc_comm) ?;
41-
42- let acc_check =
43- urs_utils:: batch_dlog_accumulator_check ( urs, & [ acc_comm] , & bulletproof_challenges) ;
46+ let mut comms = Vec :: with_capacity ( proofs. len ( ) ) ;
47+ let mut bulletproof_challenges = vec ! [ ] ;
48+
49+ for proof in proofs {
50+ let bp_chals = & proof
51+ . statement
52+ . proof_state
53+ . deferred_values
54+ . bulletproof_challenges ;
55+ let mut bp_chals: Vec < Fp > = bp_chals
56+ . iter ( )
57+ . map ( |chal| {
58+ let prechallenge = & chal. prechallenge . inner ;
59+ let prechallenge: [ u64 ; 2 ] = prechallenge. each_ref ( ) . map ( |c| c. as_u64 ( ) ) ;
60+
61+ ScalarChallenge :: limbs_to_field ( & prechallenge)
62+ } )
63+ . collect ( ) ;
64+ bulletproof_challenges. append ( & mut bp_chals) ;
65+
66+ let of_coord =
67+ |( x, y) : & ( BigInt , BigInt ) | Ok ( Vesta :: of_coordinates ( x. to_field ( ) ?, y. to_field ( ) ?) ) ;
68+
69+ // statement.proof_state.messages_for_next_wrap_proof.challenge_polynomial_commitment
70+ let acc_comm = & proof
71+ . statement
72+ . proof_state
73+ . messages_for_next_wrap_proof
74+ . challenge_polynomial_commitment ;
75+ let acc_comm: Vesta = of_coord ( acc_comm) ?;
76+
77+ comms. push ( acc_comm) ;
78+ }
79+
80+ let acc_check = urs_utils:: batch_dlog_accumulator_check ( urs, & comms, & bulletproof_challenges) ;
4481
4582 if !acc_check {
4683 println ! ( "accumulator_check failed" ) ;
0 commit comments