7 # (c) 2001 Straylight/Edgeware
10 #----- Licensing notice -----------------------------------------------------
12 # This file is part of the Perl interface to Catacomb.
14 # Catacomb/Perl is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
19 # Catacomb/Perl is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with Catacomb/Perl; if not, write to the Free Software Foundation,
26 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 MODULE = Catacomb PACKAGE = Catacomb::Field PREFIX = field_
38 field_niceprime(me, p)
52 field_binnorm(me, p, beta)
68 if ((RETVAL = field_parse(&qd)) == 0)
69 croak("bad field spec: %s", qd.e);
70 else if (!qd_eofp(&qd)) {
72 croak("junk at end of field spec");
88 RETVAL = (char *)F_NAME(f);
104 RETVAL = MP_COPY(f->zero);
112 RETVAL = MP_COPY(f->one);
120 RETVAL = MP_COPY(f->m);
141 rand(f, r = &rand_global)
145 RETVAL = F_RAND(f, MP_NEW, r);
154 RETVAL = F_SAMEP(f, ff);
163 RETVAL = F_IN(f, MP_NEW, x);
172 RETVAL = F_OUT(f, MP_NEW, x);
181 RETVAL = F_ZEROP(f, x);
190 RETVAL = F_NEG(f, MP_NEW, x);
200 RETVAL = F_ADD(f, MP_NEW, x, y);
210 RETVAL = F_SUB(f, MP_NEW, x, y);
220 RETVAL = F_MUL(f, MP_NEW, x, y);
229 RETVAL = F_SQR(f, MP_NEW, x);
238 RETVAL = F_INV(f, MP_NEW, x);
247 RETVAL = F_REDUCE(f, MP_NEW, x);
256 RETVAL = F_SQRT(f, MP_NEW, x);
265 if (F_TYPE(f) != FTY_BINARY)
266 croak("quadsolve only works on binary fields");
267 RETVAL = F_QUADSOLVE(f, MP_NEW, x);
276 if (F_TYPE(f) != FTY_PRIME)
277 croak("dbl only works on prime fields");
278 RETVAL = F_DBL(f, MP_NEW, x);
287 if (F_TYPE(f) != FTY_PRIME)
288 croak("tpl only works on prime fields");
289 RETVAL = F_TPL(f, MP_NEW, x);
298 if (F_TYPE(f) != FTY_PRIME)
299 croak("qdl only works on prime fields");
300 RETVAL = F_QDL(f, MP_NEW, x);
309 if (F_TYPE(f) != FTY_PRIME)
310 croak("hlv only works on prime fields");
311 RETVAL = F_HLV(f, MP_NEW, x);