Skip to content

Commit

Permalink
feat: add assert for non-empty accumulators in decide_all (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpwang authored May 22, 2023
1 parent 739c1f7 commit b38400a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
1 change: 1 addition & 0 deletions snark-verifier/src/pcs/ipa/decider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ mod native {
dk: &Self::DecidingKey,
accumulators: Vec<IpaAccumulator<C, NativeLoader>>,
) -> Result<(), Error> {
assert!(!accumulators.is_empty());
accumulators
.into_iter()
.map(|accumulator| Self::decide(dk, accumulator))
Expand Down
18 changes: 5 additions & 13 deletions snark-verifier/src/pcs/kzg/decider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ impl<M: MultiMillerLoop> KzgDecidingKey<M> {
g2: M::G2Affine,
s_g2: M::G2Affine,
) -> Self {
Self {
svk: svk.into(),
g2,
s_g2,
_marker: PhantomData,
}
Self { svk: svk.into(), g2, s_g2, _marker: PhantomData }
}
}

Expand Down Expand Up @@ -67,19 +62,16 @@ mod native {
KzgAccumulator { lhs, rhs }: KzgAccumulator<M::G1Affine, NativeLoader>,
) -> Result<(), Error> {
let terms = [(&lhs, &dk.g2.into()), (&rhs, &(-dk.s_g2).into())];
bool::from(
M::multi_miller_loop(&terms)
.final_exponentiation()
.is_identity(),
)
.then_some(())
.ok_or_else(|| Error::AssertionFailure("e(lhs, g2)·e(rhs, -s_g2) == O".to_string()))
bool::from(M::multi_miller_loop(&terms).final_exponentiation().is_identity())
.then_some(())
.ok_or_else(|| Error::AssertionFailure("e(lhs, g2)·e(rhs, -s_g2) == O".to_string()))
}

fn decide_all(
dk: &Self::DecidingKey,
accumulators: Vec<KzgAccumulator<M::G1Affine, NativeLoader>>,
) -> Result<(), Error> {
assert!(!accumulators.is_empty());
accumulators
.into_iter()
.map(|accumulator| Self::decide(dk, accumulator))
Expand Down

0 comments on commit b38400a

Please sign in to comment.