Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{r1cs_to_qap::R1CSToQAP, Groth16};

use super::{PreparedVerifyingKey, Proof, VerifyingKey};

use ark_relations::gr1cs::Result as R1CSResult;
use ark_relations::gr1cs::{Result as R1CSResult, SynthesisError};

use core::ops::{AddAssign, Neg};

Expand All @@ -26,6 +26,12 @@ impl<E: Pairing, QAP: R1CSToQAP> Groth16<E, QAP> {
pvk: &PreparedVerifyingKey<E>,
public_inputs: &[E::ScalarField],
) -> R1CSResult<E::G1> {
// Ensure the number of provided public inputs matches the verification key query length.
// Expected: gamma_abc_g1 has 1 extra element accounting for the constant term.
if public_inputs.len() + 1 != pvk.vk.gamma_abc_g1.len() {
return Err(SynthesisError::AssignmentMissing);
}

let mut g_ic = pvk.vk.gamma_abc_g1[0].into_group();
for (i, b) in public_inputs.iter().zip(pvk.vk.gamma_abc_g1.iter().skip(1)) {
g_ic.add_assign(&b.mul_bigint(i.into_bigint()));
Expand Down