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