1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use p256_curve::{Point, ShortWeierstrass};
pub use p256_curve::AffinePoint;
pub use p256_field::a_256::A256;
mod p256_field;
mod p256_curve;
#[cfg(test)]
mod p256_field_test;
#[cfg(test)]
mod p256_curve_test;
pub fn gen_keys(rnd: [u32; 8]) -> (A256, AffinePoint) {
let key_prv = A256::new(rnd);
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;
}