libfhe
fhe_ring.h
Go to the documentation of this file.
1// libfhe
2//
3// This program is free software: you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15//
16//===----------------------------------------------------------------------===//
23//===----------------------------------------------------------------------===//
24
25#ifndef FHE_RING_H
26#define FHE_RING_H
27
28#include "fhe_config.h"
29#include <gmp.h>
30
34typedef struct ring_t {
35 size_t lgd;
36 size_t d;
37 size_t n;
38 mpz_t M;
39 mpz_t M_half;
40 mpz_t *ms;
48
58int ring_init(ring_t *r, size_t lgd, size_t lgq, size_t lgm);
59
67
68#endif /* FHE_RING_H */
uint64_t uint_t
Default unsigned integer width is 64 bits.
Definition: fhe_config.h:49
int ring_init(ring_t *r, size_t lgd, size_t lgq, size_t lgm)
Initialize a polynomial ring.
void ring_free(ring_t *r)
Destroy a polynomial ring Free any memory allocated by the polynomial ring.
struct ring_t ring_t
Main Ring type used to define a polynomial ring.
Main Ring type used to define a polynomial ring.
Definition: fhe_ring.h:34
size_t d
Polynomial degree.
Definition: fhe_ring.h:36
size_t n
Number of residues in the CRT representation of M.
Definition: fhe_ring.h:37
uint_t * invms
[M / m_i]_{m_i}^-1
Definition: fhe_ring.h:43
uint_t * dinv
[d]_{m_i}^-1
Definition: fhe_ring.h:46
uint_t * m
CRT decomposition of M.
Definition: fhe_ring.h:44
uint_t * roots
Primitive roots of unity.
Definition: fhe_ring.h:41
mpz_t * ms
M/m_i for each CRT residue m_i.
Definition: fhe_ring.h:40
mpz_t M
Multiprecision representation of M.
Definition: fhe_ring.h:38
uint_t * iroots
Inverse primitive roots of unity.
Definition: fhe_ring.h:42
uint_t * minv
[m_i]^-1
Definition: fhe_ring.h:45
size_t lgd
log d where d is the polynomial degree
Definition: fhe_ring.h:35
mpz_t M_half
Multiprecision representation of M/2.
Definition: fhe_ring.h:39