[PYTHON-CRYPTO] purpose of list
Bram Cohen
bram at GAWTH.COM
Fri Dec 7 21:04:10 CET 2001
On Fri, 7 Dec 2001, Eric Johnson wrote:
> Conventionally mathematicians use + for Abelian groups and * for
> non-Abelian
> groups. So I think a mathematician would expect
> 3 + x = x + 3
> but
> 3 * x != x * 3
Dan Bonez, a mathematician who's done some important work in crypto,
showed me an example in which he used * for the group operation in ECC, so
it has at least some use.
> I used to think that overloading operators was a good thing and once
> did C++ code that could do a Euclidean gcd algorithm on polynomials
> with overloaded + and * operators.
>
> However, I know think it is a terrible thing and leads to more
> confusion and a loss of clarity. It is very tempting to write x ** 3
> to when x is a point on the curve but we're going to have x1 ** 3 in
> other places where x1 is an integer and we can never be quite sure of
> the semantics of the operators whereas a method name can be better.
> The other problem one encounters is how to overload * when working in
> both Zq* and Zp* -- just which field are we using? In ECC systems with
> more than one curve which one is associated with the * operator?
Yes, the received wisdom is to generally not use operator overloading, and
it's true that you can shoot yourself in the foot with it incredibly
easily, although once in a great while it does increase redability. For
example, I once wrote a VersionNumber class which implemented standard
a.b.c style versioning and implemented __cmp__, __str__ and __repr__
methods, which worked pretty well. Although, that was the only case where
I used overloading in python, and it could have worked just fine as a
bunch of functions.
-Bram Cohen
"Markets can remain irrational longer than you can remain solvent"
-- John Maynard Keynes
More information about the python-crypto
mailing list