@@ -29,6 +29,11 @@ impl Verifier {
29
29
FieldElement < F > : ByteConversion ,
30
30
<F as IsField >:: BaseType : Send + Sync + Copy ,
31
31
{
32
+ // The proof should haver one layer-proof for each circuit layer.
33
+ if proof. layer_proofs . len ( ) != circuit. layers ( ) . len ( ) {
34
+ println ! ( "The proof has an invalid number of proof layers" ) ;
35
+ return Ok ( false ) ;
36
+ }
32
37
// Fiat-Shamir heuristic:
33
38
// Both parties need to to append to the transcript the circuit, the inputs and the outputs.
34
39
// See https://eprint.iacr.org/2025/118.pdf, Sections 2.1 and 2.2
@@ -57,6 +62,16 @@ impl Verifier {
57
62
58
63
// For each layer, verify the sumcheck proof and calculate the next layer's challenges and claimed sum.
59
64
for ( layer_idx, layer_proof) in proof. layer_proofs . iter ( ) . enumerate ( ) {
65
+ // The number of sumcheck round polynomials `g_j` should be `2 * k_{i+1}`,
66
+ // where `k_{i+1} = next_num_vars` is the number of variables in the next layer.
67
+ let next_num_vars = circuit
68
+ . num_vars_at ( layer_idx + 1 )
69
+ . ok_or ( VerifierError :: InvalidProof ) ?;
70
+ if layer_proof. sumcheck_proof . round_polynomials . len ( ) != 2 * next_num_vars {
71
+ println ! ( "The proof has an invalid number of sumcheck round polynomials at layer {layer_idx}" ) ;
72
+ return Ok ( false ) ;
73
+ }
74
+
60
75
// Sumcheck verification.
61
76
let ( sumcheck_verified, sumcheck_challenges) = gkr_sumcheck_verify (
62
77
claimed_sum. clone ( ) ,
0 commit comments