3 * Normal-basis translation for binary fields
5 * (c) 2004 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of Catacomb.
12 * Catacomb is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * Catacomb is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with Catacomb; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 #ifndef CATACOMB_GFN_H
29 #define CATACOMB_GFN_H
35 /*----- Header files ------------------------------------------------------*/
39 /*----- Data structures ---------------------------------------------------*/
42 size_t n; /* Number of rows */
43 mp **r; /* Array of the rows */
46 /*----- Functions provided ------------------------------------------------*/
48 /* --- @gfn_copy@ --- *
50 * Arguments: @gfn *d@ = where to put the copy
51 * @const gfn *s@ = where the source is
55 * Use: Makes a copy of a translation matrix.
58 extern void gfn_copy(gfn */*d*/, const gfn */*s*/);
60 /* --- @gfn_destroy@ --- *
62 * Arguments: @gfn *m@ = a transformation matrix to free
66 * Use: Frees up a transformation matrix when it's no longer wanted.
69 extern void gfn_destroy(gfn */*m*/);
71 /* --- @gfn_identity@ --- *
73 * Arguments: @gfn *m@ = where to put the matrix
74 * @size_t n@ = size of the matrix
78 * Use: Fills @m@ with an identity matrix.
81 extern void gfn_identity(gfn */*m*/, size_t /*n*/);
83 /* --- @gfn_invert@ --- *
85 * Arguments: @gfn *m@ = a transformation matrix
87 * Returns: Zero if successful, nonzero if the matrix was singular.
89 * Use: Inverts a transformation matrix.
92 extern int gfn_invert(gfn */*m*/);
94 /* --- @gfn_transform@ --- *
96 * Arguments: @gfn *m@ = conversion matrix to apply
97 * @mp *d@ = destination pointer
98 * @mp *x@ = input value
100 * Returns: The transformed element.
102 * Use: Transforms a field element according to the given matrix.
105 extern mp *gfn_transform(gfn */*m*/, mp */*d*/, mp */*x*/);
107 /* --- @gfn_create@ --- *
109 * Arguments: @mp *p@ = modulus for polynomial basis
110 * @mp *beta@ = the generator of the normal basis, expressed
111 * relative to the polynomial basis
112 * @gfn *ntop@ = output normal-to-polynomail conversion matrix
113 * @gfn *pton@ = output polynomial-to-normal conversion matrix
115 * Returns: Zero if it worked, nonzero otherwise (e.g., if %$\beta$%
116 * doesn't generate a proper basis).
118 * Use: Constructs conversion matrices between polynomial and normal
119 * basis representations of binary field elements.
122 extern int gfn_create(mp */*p*/, mp */*beta*/, gfn */*ntop*/, gfn */*pton*/);
124 /*----- That's all, folks -------------------------------------------------*/