Skip to content

Commit

Permalink
adds encap decap test
Browse files Browse the repository at this point in the history
  • Loading branch information
supinie committed May 23, 2024
1 parent a3362ed commit a2670ea
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/tests/kem.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#![allow(warnings)]
#[cfg(test)]
mod kem_tests {
use crate::kem::*;
use proptest::prelude::*;

prop_compse! {
fn new_keypair()
(k in 2..=4)
-> (PublicKey, PrivateKey) {
generate_key_pair(None, k).unwrap()
}
}

proptest! {
#[test]
fn encapsulate_decapsulate((pk, sk) in new_keypair()) {
let (ciphertext, shared_secret) = pk.encapsulate().unwrap();

let decap_secret = sk.decapsulate(ciphertext).unwrap();

assert_eq!(shared_secret, decap_secret);
}
}
}

0 comments on commit a2670ea

Please sign in to comment.