3 * $Id: gfn.h,v 1.2 2004/04/08 01:36:15 mdw Exp $
5 * Normal-basis translation for binary fields
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 #ifndef CATACOMB_GFN_H
31 #define CATACOMB_GFN_H
37 /*----- Header files ------------------------------------------------------*/
41 /*----- Data structures ---------------------------------------------------*/
44 size_t n
; /* Number of rows */
45 mp
**r
; /* Array of the rows */
48 /*----- Functions provided ------------------------------------------------*/
50 /* --- @gfn_copy@ --- *
52 * Arguments: @gfn *d@ = where to put the copy
53 * @const gfn *s@ = where the source is
57 * Use: Makes a copy of a translation matrix.
60 extern void gfn_copy(gfn */
*d*/
, const gfn */
*s*/
);
62 /* --- @gfn_destroy@ --- *
64 * Arguments: @gfn *m@ = a transformation matrix to free
68 * Use: Frees up a transformation matrix when it's no longer wanted.
71 extern void gfn_destroy(gfn */
*m*/
);
73 /* --- @gfn_identity@ --- *
75 * Arguments: @gfn *m@ = where to put the matrix
76 * @size_t n@ = size of the matrix
80 * Use: Fills @m@ with an identity matrix.
83 extern void gfn_identity(gfn */
*m*/
, size_t /*n*/);
85 /* --- @gfn_invert@ --- *
87 * Arguments: @gfn *m@ = a transformation matrix
89 * Returns: Zero if successful, nonzero if the matrix was singular.
91 * Use: Inverts a transformation matrix.
94 extern int gfn_invert(gfn */
*m*/
);
96 /* --- @gfn_transform@ --- *
98 * Arguments: @gfn *m@ = conversion matrix to apply
99 * @mp *d@ = destination pointer
100 * @mp *x@ = input value
102 * Returns: The transformed element.
104 * Use: Transforms a field element according to the given matrix.
107 extern mp
*gfn_transform(gfn */
*m*/
, mp */
*d*/
, mp */
*x*/
);
109 /* --- @gfn_create@ --- *
111 * Arguments: @mp *p@ = modulus for polynomial basis
112 * @mp *beta@ = the generator of the normal basis, expressed
113 * relative to the polynomial basis
114 * @gfn *ntop@ = output normal-to-polynomail conversion matrix
115 * @gfn *pton@ = output polynomial-to-normal conversion matrix
117 * Returns: Zero if it worked, nonzero otherwise (e.g., if %$\beta$%
118 * doesn't generate a proper basis).
120 * Use: Constructs conversion matrices between polynomial and normal
121 * basis representations of binary field elements.
124 extern int gfn_create(mp */
*p*/
, mp */
*beta*/
, gfn */
*ntop*/
, gfn */
*pton*/
);
126 /*----- That's all, folks -------------------------------------------------*/