diff --git a/ecdsa.h b/ecdsa.h index 334acb2efb9..f0c837ed362 100644 --- a/ecdsa.h +++ b/ecdsa.h @@ -41,9 +41,11 @@ public: Context ct(ctx); Number sn(ct), u1(ct), u2(ct), xrn(ct); sn.SetModInverse(ct, s, c.order); + // printf("s=%s 1/s=%s\n", s.ToString().c_str(), sn.ToString().c_str()); u1.SetModMul(ct, sn, message, c.order); u2.SetModMul(ct, sn, r, c.order); GroupElemJac pr; ECMult(ct, pr, pubkey, u2, u1); + //GroupElemJac pr = pubkey; if (pr.IsInfinity()) return false; FieldElem xr; pr.GetX(xr); diff --git a/num.h b/num.h index 89f06a64adf..7910de767be 100644 --- a/num.h +++ b/num.h @@ -68,6 +68,9 @@ public: memset(bin,0,len); BN_bn2bin(bn, bin + size - len); } + void SetInt(int x) { + BN_set_word(bn, x); + } void SetModInverse(Context &ctx, const Number &x, const Number &m) { BN_mod_inverse(bn, x.bn, m.bn, ctx); } @@ -89,7 +92,7 @@ public: void SetMod(Context &ctx, const Number &a, const Number &m) { BN_nnmod(bn, m.bn, a.bn, ctx); } - int Compare(const Number &a) { + int Compare(const Number &a) const { return BN_cmp(bn, a.bn); } int GetBits() const { @@ -106,13 +109,13 @@ public: return ret; } // check whether number is 0, - bool IsZero() { + bool IsZero() const { return BN_is_zero(bn); } - bool IsOdd() { + bool IsOdd() const { return BN_is_odd(bn); } - bool IsNeg() { + bool IsNeg() const { return BN_is_negative(bn); } void Negate() {