X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/e127f835319e4b5e6dcdc2f0ed9a111a47fcecdf..dedc5483769a86aace92003a3e10f1881e015e35:/catacomb/__init__.py diff --git a/catacomb/__init__.py b/catacomb/__init__.py index dc5ecbb..08ec3d7 100644 --- a/catacomb/__init__.py +++ b/catacomb/__init__.py @@ -275,7 +275,7 @@ def secret_unbox(k, n, c): class BaseRat (object): """Base class implementing fields of fractions over Euclidean domains.""" def __new__(cls, a, b): - a, b = cls.RING(a), cls.RING(b) + a, b = cls.RING._implicit(a), cls.RING._implicit(b) q, r = divmod(a, b) if r == cls.ZERO: return q g = b.gcd(r) @@ -444,6 +444,8 @@ class _tmp: pp.pretty(me.a); pp.text(','); pp.breakable() pp.pretty(me.b) pp.end_group(ind, ')') + def fromstring(str): return _checkend(ECCurve.parse(str)) + fromstring = staticmethod(fromstring) def frombuf(me, s): return ecpt.frombuf(me, s) def fromraw(me, s): @@ -508,6 +510,8 @@ class _tmp: h ^= hash(me.curve) h ^= 2*hash(me.G) & 0xffffffff return h + def fromstring(str): return _checkend(ECInfo.parse(str)) + fromstring = staticmethod(fromstring) def group(me): return ECGroup(me) _augment(ECInfo, _tmp)