Use default_curve in all BigNum classmethods

pull/51/head
tuxxy 2018-02-08 02:00:08 -07:00
parent eda7d9992f
commit da4f22b57c
1 changed files with 4 additions and 2 deletions

View File

@ -50,10 +50,11 @@ class BigNum(object):
return BigNum(new_rand_bn, curve_nid, group, order) return BigNum(new_rand_bn, curve_nid, group, order)
@classmethod @classmethod
def from_int(cls, num, curve): def from_int(cls, num, curve: ec.EllipticCurve=None):
""" """
Returns a BigNum object from a given integer on a curve. Returns a BigNum object from a given integer on a curve.
""" """
curve = curve if curve is not None else default_curve()
try: try:
curve_nid = backend._elliptic_curve_to_nid(curve) curve_nid = backend._elliptic_curve_to_nid(curve)
except AttributeError: except AttributeError:
@ -82,11 +83,12 @@ class BigNum(object):
return BigNum(bignum, curve_nid, group, order) return BigNum(bignum, curve_nid, group, order)
@classmethod @classmethod
def from_bytes(cls, data, curve): def from_bytes(cls, data, curve: ec.EllipticCurve=None):
""" """
Returns a BigNum object from the given byte data that's within the size Returns a BigNum object from the given byte data that's within the size
of the provided curve's order. of the provided curve's order.
""" """
curve = curve if curve is not None else default_curve()
num = int.from_bytes(data, 'big') num = int.from_bytes(data, 'big')
return BigNum.from_int(num, curve) return BigNum.from_int(num, curve)