[BROKEN] Trying to get elliptic curve working, which is much too slow at the moment.

This commit is contained in:
2018-05-31 18:37:18 +01:00
parent dde1092f49
commit bdf7f81b20
16 changed files with 99817 additions and 19350 deletions

View File

@@ -8,14 +8,16 @@ use hmac::Hmac;
#[allow(non_snake_case)]
#[derive(Clone,Debug,PartialEq)]
pub struct ECDSAPublic {
pub(crate) curve: EllipticCurve,
pub(crate) curve: &'static EllipticCurve,
pub(crate) Q: ECCPoint
}
impl ECDSAPublic {
pub fn new(curve: &EllipticCurve, point: &ECCPoint) -> ECDSAPublic {
pub fn new(curve: &'static EllipticCurve, point: &ECCPoint)
-> ECDSAPublic
{
ECDSAPublic {
curve: curve.clone(),
curve: curve,
Q: point.clone()
}
}
@@ -49,11 +51,12 @@ impl ECDSAPublic {
let u2 = (&sig.r * &c) % n;
let x = point_add_two_muls(&u1, &ECCPoint::default(&self.curve),
&u2, &self.Q);
let xx = x.get_x();
if x.x.is_negative() {
if xx.is_negative() {
return false;
}
(x.x.value % n) == sig.r
(xx.value % n) == sig.r
}
}