libfhe
|
Go to the source code of this file.
Data Structures | |
struct | bgv_t |
Main BGV type used to instantiate the scheme. More... | |
struct | bgv_keypair_t |
Generic key pair wraps a pair of polynomials. More... | |
struct | bgv_key_t |
BGV key pair used to encrypt, decrypt, and relinearize a ciphertext. More... | |
struct | bgv_ct_t |
BGV Ciphertext consists of ![]() ![]() | |
Typedefs | |
typedef struct bgv_t | bgv_t |
Main BGV type used to instantiate the scheme. | |
typedef struct bgv_keypair_t | bgv_keypair_t |
Generic key pair wraps a pair of polynomials. | |
typedef struct bgv_key_t | bgv_key_t |
BGV key pair used to encrypt, decrypt, and relinearize a ciphertext. | |
typedef struct bgv_ct_t | bgv_ct_t |
BGV Ciphertext consists of ![]() ![]() | |
Functions | |
int | bgv_init (bgv_t *b, size_t lgd, size_t lgq, size_t lgm, size_t t) |
Initialize BGV scheme parameters. More... | |
void | bgv_keygen (const bgv_t *const b, bgv_key_t *k) |
Generate a BGV key pair. More... | |
void | bgv_key_serialize (unsigned char *buf, const bgv_key_t *const k) |
Serialize a BGV key pair. More... | |
void | bgv_key_deserialize (const ring_t *const r, bgv_key_t *k, const unsigned char *const buf) |
Deserialize a BGV key pair. More... | |
void | bgv_encrypt (const bgv_t *const b, bgv_ct_t *c, const bgv_keypair_t *const k, const poly_t *const m) |
Encrypt a polynomial using the BGV scheme. More... | |
void | bgv_decrypt (poly_t *m, const bgv_ct_t *const c, const poly_t *const s) |
Decrypt a BGV ciphertext. More... | |
void | bgv_free (bgv_t *b) |
Destroy a BGV struct. Free any memory allocated by the context. More... | |
void | bgv_key_free (bgv_key_t *k) |
Destroy a BGV key pair Free any memory allocated by the key generation process. More... | |
void | bgv_key_zero (const ring_t *const r, bgv_key_t *k) |
Initialize an empty key pair. More... | |
int | bgv_key_cmp (const bgv_key_t *const a, const bgv_key_t *const b) |
Test two keys for equality. Returns 1 if keys are equal, 0 otherwise. More... | |
int | bgv_ct_init (const ring_t *const r, bgv_ct_t *c, size_t n) |
Initialize an empty BGV ciphertext. More... | |
void | bgv_ct_add (bgv_ct_t *c, const bgv_ct_t *const a, const bgv_ct_t *const b) |
Add two BGV ciphertexts. More... | |
void | bgv_ct_mul (bgv_ct_t *c, const bgv_keypair_t *e, const bgv_ct_t *const a, const bgv_ct_t *const b) |
Multiply two BGV ciphertexts. More... | |
void | bgv_ct_relin (bgv_ct_t *c, const bgv_keypair_t *const k) |
Relinearize a BGV ciphertext in place. More... | |
void | bgv_ct_serialize (unsigned char *buf, const bgv_ct_t *const c) |
Serialize a BGV ciphertext into a byte stream. More... | |
void | bgv_ct_deserialize (const ring_t *const r, bgv_ct_t *c, const unsigned char *buf) |
Deserialize a BGV ciphertext from a byte stream. More... | |
void | bgv_ct_free (bgv_ct_t *c) |
Destroy a BGV ciphertext Free any memory allocated by the encryption process. More... | |
This file contains the declaration of the bgv_t type, which implements the Brakerski-Gentry-Vaikuntanathan encryption scheme.
BGV Ciphertext consists of polynomials over the ciphertext ring
.
Note: The Ciphertext size increases by one after every multiplication.
Add two BGV ciphertexts.
[out] | c | The encryption of a + b |
a | BGV ciphertext addend | |
b | BGV ciphertext addend |
Note: Any of a, b, or c may overlap
Deserialize a BGV ciphertext from a byte stream.
r | Polynomial ring | |
[out] | c | Deserialized ciphertext |
buf | Serialized ciphertext byte stream |
void bgv_ct_free | ( | bgv_ct_t * | c | ) |
Destroy a BGV ciphertext Free any memory allocated by the encryption process.
c | BGV ciphertext |
Initialize an empty BGV ciphertext.
r | Polynomial ring | |
[out] | c | Initialized ciphertext |
n | The ciphertext length (number of underlying polynomials) |
void bgv_ct_mul | ( | bgv_ct_t * | c, |
const bgv_keypair_t * | e, | ||
const bgv_ct_t *const | a, | ||
const bgv_ct_t *const | b | ||
) |
Multiply two BGV ciphertexts.
[out] | c | The encryption of a * b |
e | BGV evaluation key used for auto-relinearization | |
a | BGV ciphertext addend | |
b | BGV ciphertext addend |
Note: c will be overwritten by this function and SHOULD NOT overlap with neither the multiplier nor the multiplicand.
void bgv_ct_relin | ( | bgv_ct_t * | c, |
const bgv_keypair_t *const | k | ||
) |
Relinearize a BGV ciphertext in place.
[out] | c | The relinearized ciphertext |
k | The relinierization key |
Note: c will be overwritten by this function.
void bgv_ct_serialize | ( | unsigned char * | buf, |
const bgv_ct_t *const | c | ||
) |
Serialize a BGV ciphertext into a byte stream.
[out] | buf | Serialized ciphertext byte stream |
c | Ciphertext to be serialized |
Decrypt a BGV ciphertext.
[out] | m | Resulting plaintext |
c | BGV ciphertext to be decrypted | |
s | BGV secret key with which to decrypt |
void bgv_encrypt | ( | const bgv_t *const | b, |
bgv_ct_t * | c, | ||
const bgv_keypair_t *const | k, | ||
const poly_t *const | m | ||
) |
Encrypt a polynomial using the BGV scheme.
b | BGV context | |
[out] | c | Resulting ciphertext |
k | BGV public key used for encryption | |
m | Plaintext message used for encryption |
void bgv_free | ( | bgv_t * | b | ) |
Destroy a BGV struct. Free any memory allocated by the context.
b | BGV context |
int bgv_init | ( | bgv_t * | b, |
size_t | lgd, | ||
size_t | lgq, | ||
size_t | lgm, | ||
size_t | t | ||
) |
Initialize BGV scheme parameters.
b | BGV context |
lgd | where d is the polynomial ring degree (power of 2) |
lgq | the bitlength of the ciphertext modulus q |
lgm | the bitlength of the residues in the CRT representation of q |
t | the plaintext modulus |
Test two keys for equality. Returns 1 if keys are equal, 0 otherwise.
a | BGV Key |
b | BGV Key |
Deserialize a BGV key pair.
r | Polynomial ring | |
[out] | k | Deserialized key pair |
buf | Serialized key pair |
void bgv_key_free | ( | bgv_key_t * | k | ) |
Destroy a BGV key pair Free any memory allocated by the key generation process.
k | BGV key |
void bgv_key_serialize | ( | unsigned char * | buf, |
const bgv_key_t *const | k | ||
) |
Serialize a BGV key pair.
[out] | buf | Serialized key pair byte stream |
k | Key pair to be serialized |
Initialize an empty key pair.
r | Polynomial ring | |
[out] | k | Empty key pair |