48531b9ae13c229a8e230264ec6663050e1cc372
3 * $Id: gfn.h,v 1.1 2004/04/01 21:28:41 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 /*----- Revision history --------------------------------------------------*
33 * Revision 1.1 2004/04/01 21:28:41 mdw
34 * Normal basis support (translates to poly basis internally). Rewrite
35 * EC and prime group table generators in awk, so that they can reuse data
36 * for repeated constants.
40 #ifndef CATACOMB_GFN_H
41 #define CATACOMB_GFN_H
47 /*----- Header files ------------------------------------------------------*/
51 /*----- Data structures ---------------------------------------------------*/
54 size_t n
; /* Number of rows */
55 mp
**r
; /* Array of the rows */
58 /*----- Functions provided ------------------------------------------------*/
60 /* --- @gfn_copy@ --- *
62 * Arguments: @gfn *d@ = where to put the copy
63 * @const gfn *s@ = where the source is
67 * Use: Makes a copy of a translation matrix.
70 extern void gfn_copy(gfn */
*d*/
, const gfn */
*s*/
);
72 /* --- @gfn_destroy@ --- *
74 * Arguments: @gfn *m@ = a transformation matrix to free
78 * Use: Frees up a transformation matrix when it's no longer wanted.
81 extern void gfn_destroy(gfn */
*m*/
);
83 /* --- @gfn_identity@ --- *
85 * Arguments: @gfn *m@ = where to put the matrix
86 * @size_t n@ = size of the matrix
90 * Use: Fills @m@ with an identity matrix.
93 extern void gfn_identity(gfn */
*m*/
, size_t /*n*/);
95 /* --- @gfn_invert@ --- *
97 * Arguments: @gfn *m@ = a transformation matrix
99 * Returns: Zero if successful, nonzero if the matrix was singular.
101 * Use: Inverts a transformation matrix.
104 extern int gfn_invert(gfn */
*m*/
);
106 /* --- @gfn_transform@ --- *
108 * Arguments: @gfn *m@ = conversion matrix to apply
109 * @mp *d@ = destination pointer
110 * @mp *x@ = input value
112 * Returns: The transformed element.
114 * Use: Transforms a field element according to the given matrix.
117 extern mp
*gfn_transform(gfn */
*m*/
, mp */
*d*/
, mp */
*x*/
);
119 /* --- @gfn_create@ --- *
121 * Arguments: @mp *p@ = modulus for polynomial basis
122 * @mp *beta@ = the generator of the normal basis, expressed
123 * relative to the polynomial basis
124 * @gfn *ntop@ = output normal-to-polynomail conversion matrix
125 * @gfn *pton@ = output polynomial-to-normal conversion matrix
127 * Returns: Zero if it worked, nonzero otherwise (e.g., if %$\beta$%
128 * doesn't generate a proper basis).
130 * Use: Constructs conversion matrices between polynomial and normal
131 * basis representations of binary field elements.
134 extern int gfn_create(mp */
*p*/
, mp */
*beta*/
, gfn */
*ntop*/
, gfn */
*pton*/
);
136 /*----- That's all, folks -------------------------------------------------*/