Intel HEXL
Intel Homomorphic Encryption Acceleration Library, accelerating the modular arithmetic operations used in homomorphic encryption.
Classes | Enumerations | Functions
intel::hexl Namespace Reference

Classes

class  NTT
 Performs negacyclic forward and inverse number-theoretic transform (NTT), commonly used in RLWE cryptography. More...
 

Enumerations

enum  CMPINT {
  CMPINT::EQ = 0, CMPINT::LT = 1, CMPINT::LE = 2, CMPINT::FALSE = 3,
  CMPINT::NE = 4, CMPINT::NLT = 5, CMPINT::NLE = 6, CMPINT::TRUE = 7
}
 Represents binary operations between two boolean values. More...
 

Functions

void EltwiseAddMod (uint64_t *result, const uint64_t *operand1, const uint64_t *operand2, uint64_t n, uint64_t modulus)
 Adds two vectors elementwise with modular reduction. More...
 
void EltwiseCmpAdd (uint64_t *result, const uint64_t *operand1, CMPINT cmp, uint64_t bound, uint64_t diff, uint64_t n)
 Computes element-wise conditional addition. More...
 
void EltwiseCmpSubMod (uint64_t *result, const uint64_t *operand1, CMPINT cmp, uint64_t bound, uint64_t diff, uint64_t modulus, uint64_t n)
 Computes element-wise conditional modular subtraction. More...
 
void EltwiseFMAMod (uint64_t *result, const uint64_t *arg1, uint64_t arg2, const uint64_t *arg3, uint64_t n, uint64_t modulus, uint64_t input_mod_factor)
 Computes fused multiply-add (arg1 * arg2 + arg3) mod modulus element-wise, broadcasting scalars to vectors. More...
 
void EltwiseMultMod (uint64_t *result, const uint64_t *operand1, const uint64_t *operand2, uint64_t n, uint64_t modulus, uint64_t input_mod_factor)
 Multiplies two vectors elementwise with modular reduction. More...
 
void EltwiseReduceMod (uint64_t *result, const uint64_t *operand, uint64_t modulus, uint64_t n, uint64_t input_mod_factor, uint64_t output_mod_factor)
 Performs elementwise modular reduction. More...
 
CMPINT Not (CMPINT cmp)
 Returns the logical negation of a binary operation. More...
 

Enumeration Type Documentation

◆ CMPINT

enum intel::hexl::CMPINT
strong

Represents binary operations between two boolean values.

Enumerator
EQ 

Equal.

LT 

Less than.

LE 

Less than or equal.

FALSE 

False.

NE 

Not equal.

NLT 

Not less than.

NLE 

Not less than or equal.

TRUE 

True.

Function Documentation

◆ EltwiseAddMod()

void intel::hexl::EltwiseAddMod ( uint64_t *  result,
const uint64_t *  operand1,
const uint64_t *  operand2,
uint64_t  n,
uint64_t  modulus 
)

Adds two vectors elementwise with modular reduction.

Parameters
[out]resultStores result
[in]operand1Vector of elements to add. Each element must be less than the modulus
[in]operand2Vector of elements to add. Each element must be less than the modulus
[in]nNumber of elements in each vector
[in]modulusModulus with which to perform modular reduction. Must be in the range \([2, 2^{63} - 1]\)

Computes \( operand1[i] = (operand1[i] + operand2[i]) \mod modulus \) for \( i=0, ..., n-1\).

◆ EltwiseCmpAdd()

void intel::hexl::EltwiseCmpAdd ( uint64_t *  result,
const uint64_t *  operand1,
CMPINT  cmp,
uint64_t  bound,
uint64_t  diff,
uint64_t  n 
)

Computes element-wise conditional addition.

Parameters
[out]resultStores the result
[in]operand1Vector of elements to compare; stores result
[in]cmpComparison operation
[in]boundScalar to compare against
[in]diffScalar to conditionally add
[in]nNumber of elements in operand1

Computes result[i] = cmp(operand1[i], bound) ? operand1[i] + diff : operand1[i] for all \(i=0, ..., n-1\).

◆ EltwiseCmpSubMod()

void intel::hexl::EltwiseCmpSubMod ( uint64_t *  result,
const uint64_t *  operand1,
CMPINT  cmp,
uint64_t  bound,
uint64_t  diff,
uint64_t  modulus,
uint64_t  n 
)

Computes element-wise conditional modular subtraction.

Parameters
[out]resultStores the result
[in]operand1Vector of elements to compare
[in]cmpComparison function
[in]boundScalar to compare against
[in]diffScalar to subtract by
[in]modulusModulus to reduce by
[in]nNumber of elements in operand1

Computes operand1[i] = (cmp(operand1, bound)) ? (operand1 - diff) mod modulus : operand1 for all i=0, ..., n-1

◆ EltwiseFMAMod()

void intel::hexl::EltwiseFMAMod ( uint64_t *  result,
const uint64_t *  arg1,
uint64_t  arg2,
const uint64_t *  arg3,
uint64_t  n,
uint64_t  modulus,
uint64_t  input_mod_factor 
)

Computes fused multiply-add (arg1 * arg2 + arg3) mod modulus element-wise, broadcasting scalars to vectors.

Parameters
[out]resultStores the result
[in]arg1Vector to multiply
[in]arg2Scalar to multiply
[in]arg3Vector to add. Will not add if arg3 == nullptr
[in]nNumber of elements in each vector
[in]modulusModulus with which to perform modular reduction. Must be in the range \( [2, 2^{61} - 1]\)
[in]input_mod_factorAssumes input elements are in [0, input_mod_factor * p). Must be 1, 2, 4, or 8.

◆ EltwiseMultMod()

void intel::hexl::EltwiseMultMod ( uint64_t *  result,
const uint64_t *  operand1,
const uint64_t *  operand2,
uint64_t  n,
uint64_t  modulus,
uint64_t  input_mod_factor 
)

Multiplies two vectors elementwise with modular reduction.

Parameters
[in]resultResult of element-wise multiplication
[in]operand1Vector of elements to multiply. Each element must be less than the modulus.
[in]operand2Vector of elements to multiply. Each element must be less than the modulus.
[in]nNumber of elements in each vector
[in]modulusModulus with which to perform modular reduction
[in]input_mod_factorAssumes input elements are in [0, input_mod_factor * p) Must be 1, 2 or 4.

Computes result[i] = (operand1[i] * operand2[i]) mod modulus for i=0, ..., n - 1

◆ EltwiseReduceMod()

void intel::hexl::EltwiseReduceMod ( uint64_t *  result,
const uint64_t *  operand,
uint64_t  modulus,
uint64_t  n,
uint64_t  input_mod_factor,
uint64_t  output_mod_factor 
)

Performs elementwise modular reduction.

Parameters
[out]resultStores the result
[in]operand
[in]nNumber of elements in operand
[in]modulusModulus with which to perform modular reduction
[in]input_mod_factorAssumes input elements are in [0, input_mod_factor * p) Must be 0, 1, 2 or 4. input_mod_factor=0 means, no knowledge of input range. Barrett reduction will be used in this case. input_mod_factor >= output_mod_factor unless input_mod_factor == 0
[in]output_mod_factoroutput elements will be in [0, output_mod_factor
  • p) Must be 1 or 2. for input_mod_factor=0, output_mod_factor will be set to 1.

◆ Not()

CMPINT intel::hexl::Not ( CMPINT  cmp)
inline

Returns the logical negation of a binary operation.

Parameters
[in]cmpThe binary operation to negate