Skip to content

Commit

Permalink
fix-different-dk: make sure to use a different key in negative test (#…
Browse files Browse the repository at this point in the history
…540)

Co-authored-by: Aurélien Nicolas <[email protected]>
  • Loading branch information
naure and Aurélien Nicolas authored Jul 17, 2024
1 parent 2ea62c9 commit 276318e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/zkp/pilog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,16 @@ mod tests {
Ok(())
}

fn new_different_decryption_key(rng: &mut StdRng, dk: &DecryptionKey) -> Result<DecryptionKey> {
for _ in 0..10 {
let (other_dk, _, _) = DecryptionKey::new(rng).unwrap();
if other_dk != *dk {
return Ok(other_dk);
}
}
Err(InternalError::InternalInvariantFailed)
}

#[test]
fn pilog_proof_with_different_setup_parameters() -> Result<()> {
let mut rng = init_testing();
Expand All @@ -444,7 +454,7 @@ mod tests {
let input = CommonInput::new(&ciphertext, &dlog_commit, setup_params.scheme(), &pk, &g);

// Generate a random encryption key
let (bad_decryption_key, _, _) = DecryptionKey::new(&mut rng).unwrap();
let bad_decryption_key = new_different_decryption_key(&mut rng, &decryption_key)?;
let bad_pk = bad_decryption_key.encryption_key();
let bad_input = CommonInput::new(
&ciphertext,
Expand Down

0 comments on commit 276318e

Please sign in to comment.