ghash.h: Fix GH_HASHSTR64*.
[u/mdw/catacomb] / gfn.h
CommitLineData
4edc47b8 1/* -*-c-*-
2 *
b817bfc6 3 * $Id: gfn.h,v 1.2 2004/04/08 01:36:15 mdw Exp $
4edc47b8 4 *
5 * Normal-basis translation for binary fields
6 *
7 * (c) 2004 Straylight/Edgeware
8 */
9
45c0fd36 10/*----- Licensing notice --------------------------------------------------*
4edc47b8 11 *
12 * This file is part of Catacomb.
13 *
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.
45c0fd36 18 *
4edc47b8 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.
45c0fd36 23 *
4edc47b8 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,
27 * MA 02111-1307, USA.
28 */
29
4edc47b8 30#ifndef CATACOMB_GFN_H
31#define CATACOMB_GFN_H
32
33#ifdef __cplusplus
34 extern "C" {
35#endif
36
37/*----- Header files ------------------------------------------------------*/
38
39#include "gf.h"
40
41/*----- Data structures ---------------------------------------------------*/
42
43typedef struct gfn {
44 size_t n; /* Number of rows */
45 mp **r; /* Array of the rows */
46} gfn;
47
48/*----- Functions provided ------------------------------------------------*/
49
50/* --- @gfn_copy@ --- *
51 *
52 * Arguments: @gfn *d@ = where to put the copy
53 * @const gfn *s@ = where the source is
54 *
55 * Returns: ---
56 *
57 * Use: Makes a copy of a translation matrix.
58 */
59
60extern void gfn_copy(gfn */*d*/, const gfn */*s*/);
61
62/* --- @gfn_destroy@ --- *
63 *
64 * Arguments: @gfn *m@ = a transformation matrix to free
65 *
66 * Returns: ---
67 *
68 * Use: Frees up a transformation matrix when it's no longer wanted.
69 */
70
71extern void gfn_destroy(gfn */*m*/);
72
73/* --- @gfn_identity@ --- *
74 *
75 * Arguments: @gfn *m@ = where to put the matrix
76 * @size_t n@ = size of the matrix
77 *
78 * Returns: ---
79 *
80 * Use: Fills @m@ with an identity matrix.
81 */
82
83extern void gfn_identity(gfn */*m*/, size_t /*n*/);
84
85/* --- @gfn_invert@ --- *
86 *
87 * Arguments: @gfn *m@ = a transformation matrix
88 *
89 * Returns: Zero if successful, nonzero if the matrix was singular.
90 *
91 * Use: Inverts a transformation matrix.
92 */
93
94extern int gfn_invert(gfn */*m*/);
95
96/* --- @gfn_transform@ --- *
97 *
98 * Arguments: @gfn *m@ = conversion matrix to apply
99 * @mp *d@ = destination pointer
100 * @mp *x@ = input value
101 *
102 * Returns: The transformed element.
103 *
104 * Use: Transforms a field element according to the given matrix.
105 */
106
107extern mp *gfn_transform(gfn */*m*/, mp */*d*/, mp */*x*/);
108
109/* --- @gfn_create@ --- *
110 *
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
116 *
117 * Returns: Zero if it worked, nonzero otherwise (e.g., if %$\beta$%
118 * doesn't generate a proper basis).
119 *
120 * Use: Constructs conversion matrices between polynomial and normal
121 * basis representations of binary field elements.
122 */
123
124extern int gfn_create(mp */*p*/, mp */*beta*/, gfn */*ntop*/, gfn */*pton*/);
125
126/*----- That's all, folks -------------------------------------------------*/
127
128#ifdef __cplusplus
129 }
130#endif
131
132#endif