use ntrulp::key::priv_key::PrivKey;
use ntrulp::key::pub_key::PubKey;
use ntrulp::poly::r3::R3;
use ntrulp::poly::rq::Rq;
use ntrulp::rng::{random_small, short_random};
fn main() {
let mut rng = rand::rng();
let f: Rq = Rq::from(short_random(&mut rng).unwrap());
let mut g: R3;
let sk = loop {
g = R3::from(random_small(&mut rng));
match PrivKey::compute(&f, &g) {
Ok(s) => break s,
Err(_) => continue,
};
};
let pk = PubKey::compute(&f, &g).unwrap();
let imported_pk = PubKey::from_sk(&sk).unwrap();
let pk_bytes = imported_pk.to_bytes();
let from_bytes: PubKey = pk_bytes.into();
assert_eq!(from_bytes.coeffs, pk.coeffs);
}