libfhe
|
#include "fhe_ring.h"
Go to the source code of this file.
Data Structures | |
struct | poly_t |
Main Polynomial type used to represent polynomials over ![]() ![]() | |
Typedefs | |
typedef struct poly_t | poly_t |
Main Polynomial type used to represent polynomials over ![]() ![]() | |
Functions | |
int | poly_zero (const ring_t *const r, poly_t *p) |
Initialize the zero polynomial. More... | |
void | poly_encode (const ring_t *const r, const uint_t *const u, poly_t *p) |
Encode a polynomial into its CRT representation. More... | |
void | poly_decode (uint_t *out, const poly_t *const p, uint_t t) |
Decode a polynomial into its original form. More... | |
void | poly_ntt (poly_t *p) |
Convert to NTT form. More... | |
void | poly_intt (poly_t *p) |
Convert back from NTT form. More... | |
void | poly_clone (poly_t *dst, const poly_t *const src) |
Clone a polynomial. More... | |
void | poly_cmul (poly_t *out, const poly_t *const in, int_t c) |
Constant multiplication. More... | |
void | poly_rand (const ring_t *const r, poly_t *out, DISTRIBUTION d) |
Sample a random polynomial. More... | |
void | poly_neg (poly_t *p) |
Negate a polynomial. More... | |
void | poly_add (poly_t *c, const poly_t *const a, const poly_t *const b) |
Polynomial addition. More... | |
void | poly_sub (poly_t *c, const poly_t *const a, const poly_t *const b) |
Polynomial subtraction. More... | |
void | poly_mul (poly_t *c, const poly_t *const a, const poly_t *const b) |
Polynomial multiplication. More... | |
void | poly_serialize (unsigned char *buf, const poly_t *const p) |
Serialize a polynomial into a byte stream. More... | |
void | poly_deserialize (poly_t *p, const unsigned char *const buf) |
Deserialize a polynomial from a byte stream. More... | |
int | poly_cmp (const poly_t *const a, const poly_t *const b) |
Test two polynomials for equality Returns 1 if polynomials are equal, 0 otherwise. More... | |
void | poly_free (poly_t *p) |
Destroy a Polynomial Free any memory allocated by the polynomial. More... | |
This file contains the declaration of the poly_t type, which implements arithmetic over the cyclotomic polynomial ring for a generic modulus
.
Main Polynomial type used to represent polynomials over for a generic modulus
.
Polynomials are represented using the ring isomorphism provided by the Chinese Remainder Theorem.
Namely, a polynomial with coefficients mod is decomposed into
polynomials with coefficients mod
of degree
where
.
Residues are pairwise coprime word-sized integers (typically between 32-60 bits)
Polynomial addition.
[out] | c | Resulting sum |
a | Addend | |
b | Addend |
Clone a polynomial.
[out] | dst | Destination polynomial |
src | Source polynomial |
Test two polynomials for equality Returns 1 if polynomials are equal, 0 otherwise.
a | Polynomial |
b | Polynomial |
Constant multiplication.
[out] | out | Resulting polynomial |
in | Input polynomial | |
c | Constant multiplier |
Decode a polynomial into its original form.
[out] | out | decoded polynomial |
p | encoded polynomial | |
t | modulus |
void poly_deserialize | ( | poly_t * | p, |
const unsigned char *const | buf | ||
) |
Deserialize a polynomial from a byte stream.
[out] | p | Deserialized polynomial |
buf | Serialized polynomial |
Encode a polynomial into its CRT representation.
r | Underlying ring | |
u | Polynomial coefficients | |
[out] | p | Encoded polynomial |
void poly_free | ( | poly_t * | p | ) |
Destroy a Polynomial Free any memory allocated by the polynomial.
p | Polynomial |
void poly_intt | ( | poly_t * | p | ) |
Convert back from NTT form.
p | Polynomial |
Polynomial multiplication.
[out] | c | Resulting product |
a | multiplicand | |
b | multiplier |
void poly_neg | ( | poly_t * | p | ) |
Negate a polynomial.
p | Polynomial |
void poly_ntt | ( | poly_t * | p | ) |
Convert to NTT form.
p | Polynomial |
void poly_rand | ( | const ring_t *const | r, |
poly_t * | out, | ||
DISTRIBUTION | d | ||
) |
Sample a random polynomial.
r | Base ring | |
[out] | out | Random polynomial |
d | Sampling distribution |
void poly_serialize | ( | unsigned char * | buf, |
const poly_t *const | p | ||
) |
Serialize a polynomial into a byte stream.
[out] | buf | Serialized polynomial |
p | Polynomial to be serialized |
Polynomial subtraction.
[out] | c | Resulting difference |
a | Minuend | |
b | Subtrahend |