3 * $Id: gf.h,v 1.1.2.1 2004/03/21 22:39:46 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.1.2.1 2004/03/21 22:39:46 mdw
34 * Elliptic curves on binary fields work.
45 /*----- Header files ------------------------------------------------------*/
51 #ifndef CATACOMB_GFX_H
55 /*----- Functions provided ------------------------------------------------*/
59 * Arguments: @mp *d@ = destination
60 * @mp *a, *b@ = sources
62 * Returns: Result, @a@ added to @b@.
65 extern mp
*gf_add(mp */
*d*/
, mp */
*a*/
, mp */
*b*/
);
70 * Arguments: @mp *d@ = destination
71 * @mp *a, *b@ = sources
73 * Returns: Result, @a@ multiplied by @b@.
76 extern mp
*gf_mul(mp */
*d*/
, mp */
*a*/
, mp */
*b*/
);
80 * Arguments: @mp *d@ = destination
83 * Returns: Result, @a@ squared.
86 extern mp
*gf_sqr(mp */
*d*/
, mp */
*a*/
);
90 * Arguments: @mp **qq, **rr@ = destination, quotient and remainder
91 * @mp *a, *b@ = sources
93 * Use: Calculates the quotient and remainder when @a@ is divided by
94 * @b@. The destinations @*qq@ and @*rr@ must be distinct.
95 * Either of @qq@ or @rr@ may be null to indicate that the
96 * result is irrelevant. (Discarding both results is silly.)
97 * There is a performance advantage if @a == *rr@.
100 extern void gf_div(mp
**/
*qq*/
, mp
**/
*rr*/
, mp */
*a*/
, mp */
*b*/
);
102 /* --- @gf_gcd@ --- *
104 * Arguments: @mp **gcd, **xx, **yy@ = where to write the results
105 * @mp *a, *b@ = sources (must be nonzero)
110 * Use: Calculates @gcd(a, b)@, and two numbers @x@ and @y@ such that
111 * @ax + by = gcd(a, b)@. This is useful for computing modular
115 extern void gf_gcd(mp
**/
*gcd*/
, mp
**/
*xx*/
, mp
**/
*yy*/
,
116 mp */
*a*/
, mp */
*b*/
);
118 /*----- That's all, folks -------------------------------------------------*/