Skip to content

Commit

Permalink
Separate negative tests for invalid grand total and invalid range check
Browse files Browse the repository at this point in the history
  • Loading branch information
alxkzmn committed May 10, 2024
1 parent c9c05b1 commit a2c5584
Showing 1 changed file with 41 additions and 5 deletions.
46 changes: 41 additions & 5 deletions prover/src/circuits/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,57 @@ fn test_summa_hyperplonk() {
};
assert_eq!(result, Ok(()));

let wrong_instances = instances[0]
let invalid_grand_total_instances = instances[0]
.iter()
.map(|instance| *instance + Fp::ONE)
.enumerate()
.map(|(i, element)| {
if i == 0 {
*element
} else {
Fp::random(seeded_std_rng())
}
})
.collect::<Vec<_>>();
let wrong_result = {

let invalid_result = {
let mut transcript = Keccak256Transcript::from_proof((), proof.as_slice());
ProvingBackend::verify(
&verifier_parameters,
&[invalid_grand_total_instances],
&mut transcript,
seeded_std_rng(),
)
};
assert_eq!(
invalid_result,
Err(InvalidSumcheck(
"Consistency failure at round 1".to_string()
))
);

let invalid_range_check_instances = instances[0]
.iter()
.enumerate()
.map(|(i, element)| {
if i == 0 {
Fp::random(seeded_std_rng())
} else {
*element
}
})
.collect::<Vec<_>>();

let invalid_result = {
let mut transcript = Keccak256Transcript::from_proof((), proof.as_slice());
ProvingBackend::verify(
&verifier_parameters,
&[wrong_instances],
&[invalid_range_check_instances],
&mut transcript,
seeded_std_rng(),
)
};
assert_eq!(
wrong_result,
invalid_result,
Err(InvalidSumcheck(
"Consistency failure at round 1".to_string()
))
Expand Down

0 comments on commit a2c5584

Please sign in to comment.