use curve256::nist_p256::{Point, ShortWeierstrass};
pub use curve256::nist_p256::AffinePoint;
pub use field256::a_256::A256;

mod field256;
mod curve256;

pub fn gen_keys(rnd: [u32; 8]) -> (A256, AffinePoint) {
    let key_prv = A256 { r: [rnd[0], rnd[1], rnd[2], rnd[3], rnd[4], rnd[5], rnd[6], rnd[7]] };
    let key_pub = Point::to_affine(ShortWeierstrass::mul(key_prv, AffinePoint::to_projective(ShortWeierstrass::P256.g)));
    return (key_prv, key_pub);
}

pub fn gen_secret(key_prv: A256, key_pub: AffinePoint) -> A256 {
    return Point::to_affine(ShortWeierstrass::mul(key_prv, AffinePoint::to_projective(key_pub))).x;
}
