use curve256::AffinePoint;
pub use field256::A256;
pub use curve256::Point;

mod field256;
mod curve256;

pub fn gen_keys(rnd: u32) -> (A256, AffinePoint) {
    let key_prv = A256 { r: [rnd, rnd, rnd, rnd, rnd, rnd, rnd, rnd] };
    let key_pub = curve256::Point::to_affine(curve256::ShortWeierstrass::mul(key_prv, curve256::AffinePoint::to_projective(curve256::ShortWeierstrass::P256.g)));
    return (key_prv, key_pub);
}

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