From 852cbee819137f4296974c0df15fbb3a1c28b46c Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sun, 10 Mar 2013 19:26:17 +0100 Subject: [PATCH] small changes --- ecdsa.h | 2 ++ num.h | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ecdsa.h b/ecdsa.h index 334acb2..f0c837e 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 89f06a6..7910de7 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() {