|
|
|
@ -316,7 +316,6 @@ namespace crypto
@@ -316,7 +316,6 @@ namespace crypto
|
|
|
|
|
|
|
|
|
|
bool IsOnCurve (const EDDSAPoint& p, BN_CTX * ctx) const |
|
|
|
|
{ |
|
|
|
|
BN_CTX_start (ctx); |
|
|
|
|
BIGNUM * x2 = BN_CTX_get (ctx), * y2 = BN_CTX_get (ctx), * tmp = BN_CTX_get (ctx); |
|
|
|
|
BN_sqr (x2, p.x, ctx); // x^2
|
|
|
|
|
BN_sqr (y2, p.y, ctx); // y^2
|
|
|
|
@ -353,6 +352,7 @@ namespace crypto
@@ -353,6 +352,7 @@ namespace crypto
|
|
|
|
|
BN_mod_mul (x, x, I, q, ctx); |
|
|
|
|
if (BN_is_odd (x)) |
|
|
|
|
BN_sub (x, q, x); |
|
|
|
|
|
|
|
|
|
return x; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -370,7 +370,7 @@ namespace crypto
@@ -370,7 +370,7 @@ namespace crypto
|
|
|
|
|
buf1[0] &= 0x7f; // clear highest bit
|
|
|
|
|
BIGNUM * y = BN_new (); |
|
|
|
|
BN_bin2bn (buf1, EDDSA25519_PUBLIC_KEY_LENGTH, y); |
|
|
|
|
auto x = RecoverX (y, ctx); |
|
|
|
|
BIGNUM * x = RecoverX (y, ctx); |
|
|
|
|
if (BN_is_bit_set (x, 0) != isHighestBitSet) |
|
|
|
|
BN_sub (x, q, x); // x = q - x
|
|
|
|
|
BIGNUM * z = BN_new (), * t = BN_new (); |
|
|
|
|