Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add better error messages/docs for catching empty inputs #18

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions snark-verifier-sdk/src/halo2/aggregation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ pub type Halo2Loader<'chip> = loader::halo2::Halo2Loader<G1Affine, BaseFieldEccC
/// Returns the assigned instances of previous snarks and the new final pair that needs to be verified in a pairing check.
/// For each previous snark, we concatenate all instances into a single vector. We return a vector of vectors,
/// one vector per snark, for convenience.
///
/// # Assumptions
/// * `snarks` is not empty
pub fn aggregate<'a, AS>(
svk: &Svk,
loader: &Rc<Halo2Loader<'a>>,
Expand All @@ -76,6 +79,7 @@ where
VerifyingKey = KzgAsVerifyingKey,
>,
{
assert!(!snarks.is_empty(), "trying to aggregate 0 snarks");
let assign_instances = |instances: &[Vec<Fr>]| {
instances
.iter()
Expand Down
2 changes: 1 addition & 1 deletion snark-verifier/src/loader/evm/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ where
_ => ec_point.loader.ec_point_scalar_mul(ec_point, scalar),
})
.reduce(|acc, ec_point| acc.loader.ec_point_add(&acc, &ec_point))
.unwrap()
.expect("pairs should not be empty")
}
}

Expand Down
1 change: 1 addition & 0 deletions snark-verifier/src/loader/halo2/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ impl<C: CurveAffine, EccChip: EccInstructions<C>> EcPointLoader<C> for Rc<Halo2L
fn multi_scalar_multiplication(
pairs: &[(&<Self as ScalarLoader<C::Scalar>>::LoadedScalar, &EcPoint<C, EccChip>)],
) -> EcPoint<C, EccChip> {
assert!(!pairs.is_empty(), "multi_scalar_multiplication: pairs is empty");
let loader = &pairs[0].0.loader;

let (constant, fixed_base, variable_base_non_scaled, variable_base_scaled) =
Expand Down
2 changes: 1 addition & 1 deletion snark-verifier/src/loader/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<C: CurveAffine> EcPointLoader<C> for NativeLoader {
.cloned()
.map(|(scalar, base)| *base * scalar)
.reduce(|acc, value| acc + value)
.unwrap()
.expect("pairs should not be empty")
.to_affine()
}
}
Expand Down