3 * $Id: gf.h,v 1.3 2004/03/27 17:54:11 mdw Exp $
5 * Arithmetic on binary polynomials
7 * (c) 2004 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Catacomb.
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * Catacomb 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 Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30 /*----- Revision history --------------------------------------------------*
33 * Revision 1.3 2004/03/27 17:54:11 mdw
34 * Standard curves and curve checking.
36 * Revision 1.2 2004/03/21 22:52:06 mdw
37 * Merge and close elliptic curve branch.
39 * Revision 1.1.2.1 2004/03/21 22:39:46 mdw
40 * Elliptic curves on binary fields work.
51 /*----- Header files ------------------------------------------------------*/
57 #ifndef CATACOMB_GFX_H
61 /*----- Functions provided ------------------------------------------------*/
65 * Arguments: @mp *d@ = destination
66 * @mp *a, *b@ = sources
68 * Returns: Result, @a@ added to @b@.
71 extern mp
*gf_add(mp */
*d*/
, mp */
*a*/
, mp */
*b*/
);
76 * Arguments: @mp *d@ = destination
77 * @mp *a, *b@ = sources
79 * Returns: Result, @a@ multiplied by @b@.
82 extern mp
*gf_mul(mp */
*d*/
, mp */
*a*/
, mp */
*b*/
);
86 * Arguments: @mp *d@ = destination
89 * Returns: Result, @a@ squared.
92 extern mp
*gf_sqr(mp */
*d*/
, mp */
*a*/
);
96 * Arguments: @mp **qq, **rr@ = destination, quotient and remainder
97 * @mp *a, *b@ = sources
99 * Use: Calculates the quotient and remainder when @a@ is divided by
100 * @b@. The destinations @*qq@ and @*rr@ must be distinct.
101 * Either of @qq@ or @rr@ may be null to indicate that the
102 * result is irrelevant. (Discarding both results is silly.)
103 * There is a performance advantage if @a == *rr@.
106 extern void gf_div(mp
**/
*qq*/
, mp
**/
*rr*/
, mp */
*a*/
, mp */
*b*/
);
108 /* --- @gf_irreduciblep@ --- *
110 * Arguments: @mp *f@ = a polynomial
112 * Returns: Nonzero if the polynomial is irreducible; otherwise zero.
115 extern int gf_irreduciblep(mp */
*f*/
);
117 /* --- @gf_gcd@ --- *
119 * Arguments: @mp **gcd, **xx, **yy@ = where to write the results
120 * @mp *a, *b@ = sources (must be nonzero)
125 * Use: Calculates @gcd(a, b)@, and two numbers @x@ and @y@ such that
126 * @ax + by = gcd(a, b)@. This is useful for computing modular
130 extern void gf_gcd(mp
**/
*gcd*/
, mp
**/
*xx*/
, mp
**/
*yy*/
,
131 mp */
*a*/
, mp */
*b*/
);
133 /*----- That's all, folks -------------------------------------------------*/