chiark / gitweb /
mp: Be more restrictive about implicit conversions.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 5 Apr 2006 11:20:57 +0000 (12:20 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 5 Apr 2006 11:20:57 +0000 (12:20 +0100)
commitbf8910bde6a430a64868ef70319f94e94114c82c
tree64706fd3982943a35c6184ee676d8763cfcffaa2
parentc62f9ebfe16a96a771af2343c2358d49668e31b0
mp: Be more restrictive about implicit conversions.

Implicit conversions, e.g., for binary operators, used to be quite
promiscuous.  In particular, if P is a curve point and x is an MP, then
P * x was a point multiplication, but x * P converted P to an integer
(by discarding the y coordinate) and multiplied in integers.  This is
clearly insane.

The new code is pickier about converting things to MPs or GFs.  Explicit
conversions can still be given.  And there will still be great confusion
if you mix Catacomb types with other numeric types.  But things seem
more logical now, at least.

The actual implicit conversion rules are as follows:

  * An MP and any type with a `long' conversion /except/ for GF, FE,
    ECPt or GE may convert to MP.

  * A GF and any type with a `long' conversion /except/ for MP, FE, ECPt
    or GE may convert to GF.

  * Anything which can convert to `long' may convert to FE.  This will
    lead to confusion if you mix FEs and ECPts, but I think that's
    asking for trouble anyway.

  * There are no implicit conversions to ECPt or GE.  However, ECPt can
    be multiplied by anything with a `long' conversion.

I hope this is right.  If not, I'll fiddle some more.
mp.c