`ECCurve.parse' was inconsistent with the established nomenclature.
Generally, `parse' reads a prefix of some given string, returning the
denoted value and the unprocessed remainder of the input string;
`fromstring' does the same, except that it returns only the value, and
raises an exception if the remainder of the string is not only
whitespace.
Fix `ECCurve.parse' (which unfortunately is an incompatible change), and
add missing `fromstring' methods to `ECCurve' and `ECInfo'.
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):
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)
if (!PyArg_ParseTuple(arg, "s:parse", &p)) goto end;
qd.p = p; qd.e = 0;
if ((c = ec_curveparse(&qd)) == 0) VALERR(qd.e);
- rc = eccurve_pywrap(0, c);
+ rc = Py_BuildValue("(Ns)", eccurve_pywrap(0, c), qd.p);
end:
return (rc);
}
def test_tinycurves(me):
me._test_curve(C.ECInfo(E, 2*P, 13, 2), checkfail = True)
- ei, _ = C.ECInfo.parse("binpoly: 0x13; bin: 0x01, 0x08; 0x02, 0x0c: 5*4")
+ ei = C.ECInfo.fromstring("binpoly: 0x13; bin: 0x01, 0x08; 0x02, 0x0c: 5*4")
me._test_curve(ei, checkfail = True)
TestCurves.generate_testcases((name, C.eccurves[name]) for name in