aboutsummaryrefslogtreecommitdiff
path: root/src/math/poly.h
blob: 7fd36fdfa5d03e848015d3f1608a4487b209df5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * ecgen, tool for generating Elliptic curve domain parameters
 * Copyright (C) 2017-2018 J08nY
 */
/**
 * @file poly.h
 */
#ifndef ECGEN_MATH_POLY_H
#define ECGEN_MATH_POLY_H

#include <pari/pari.h>
#include <stdbool.h>

/**
 * @brief
 */
typedef struct {
	unsigned int m;
	unsigned int e1;
	unsigned int e2;
	unsigned int e3;
} polynomial_t;

/**
 * @brief Whether a polynomial exists in the polynomial data with degree
 * <code>m</code>.
 *
 * @param m the degree of the polynomial searched
 * @return whether it exists
 */
bool poly_exists(unsigned long m);

/**
 * @brief Find a polynomial of degree <code>m</code> in the polynomial dataset.
 *
 * @param m the degree of the polynomial searched
 * @return the polynomial_t * inside the polynomial dataset
 */
const polynomial_t *poly_find(unsigned long m);

/**
 * @brief Turn a polynomial_t into a GEN.
 *
 * @param polynomial the polynomial_t to convert
 * @return a t_POL equal to the polynomial
 */
GEN poly_gen(const polynomial_t *polynomial);

/**
 * @brief Find a polynomial of degree <code>m</code> and turn it into a GEN.
 *
 * @see poly_gen
 * @param m the degree of the polynomial searched
 * @return a t_POL equal to the polynomial
 */
GEN poly_find_gen(unsigned long m);

#endif  // ECGEN_MATH_POLY_H