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>
Sat, 11 Apr 2020 11:49:31 +0000 (12:49 +0100)
commitdc55f697f51c4e66ac8c7fd4cb8917afc1f34d6a
tree3af0c0cc49a6b44227c1a7ddfe93056940341fd5
parente7d2e2e29042a980933261a173d96c71982514fa
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