ec.c, field.c, group.c: Allow exponents and scalars from prime fields.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 24 Nov 2019 00:41:52 +0000 (00:41 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 25 Nov 2019 17:51:32 +0000 (17:51 +0000)
commit3317491a2bc28732f805c8521777aafa52038793
tree73bc4f32f419c42a37bd2e991c256525337cfef7
parent7032ee7c4d3ed206be5b972a9274dab27bbd2936
ec.c, field.c, group.c: Allow exponents and scalars from prime fields.

The idea is that the unit group of a finite field, and the point group
of an elliptic curve, can usefully be viewed as modules over a suitable
integer quotient ring; and, even more so, prime-order subgroups of these
can be considered as one-dimensional vector spaces over prime-order
fields.  It's therefore helpful to allow elements of the appropriate
field as exponents or scalar multipliers as appropriate.  Unfortunately
it's annoying to check whether we have the /right/ scalar field; we
could check, but that does a lot of computation for little benefit.  So
allow any prime-field element in these positions.

I don't (currently) allow a prime-field element as the exponent in `pow'
applied to `MP' or `GF'; I'm open to representation on whether this is a
good idea.  They are permitted in the exponentiation functions attached
to the various modular-reduction classes, because the exponent operand
in those cases is subject to explicit conversion.
ec.c
field.c
group.c
t/t-ec.py