Intel HEXL
Intel Homomorphic Encryption Acceleration Library, accelerating the modular arithmetic operations used in homomorphic encryption.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Namespaces | Functions
number-theory.hpp File Reference
#include <stdint.h>
#include <iostream>
#include <limits>
#include <vector>
#include "hexl/util/check.hpp"
#include "hexl/util/compiler.hpp"
Include dependency graph for number-theory.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  intel::hexl::MultiplyFactor
 Pre-computes a Barrett factor with which modular multiplication can be performed more efficiently. More...
 

Namespaces

 intel
 
 intel::hexl
 

Functions

bool intel::hexl::IsPowerOfTwo (uint64_t num)
 Returns whether or not num is a power of two. More...
 
uint64_t intel::hexl::Log2 (uint64_t x)
 Returns floor(log2(x)) More...
 
bool intel::hexl::IsPowerOfFour (uint64_t num)
 
uint64_t intel::hexl::MaximumValue (uint64_t bits)
 Returns the maximum value that can be represented using bits bits. More...
 
uint64_t intel::hexl::ReverseBits (uint64_t x, uint64_t bit_width)
 Reverses the bits. More...
 
uint64_t intel::hexl::InverseMod (uint64_t x, uint64_t modulus)
 Returns x^{-1} mod modulus. More...
 
uint64_t intel::hexl::MultiplyMod (uint64_t x, uint64_t y, uint64_t modulus)
 Returns (x * y) mod modulus. More...
 
uint64_t intel::hexl::MultiplyMod (uint64_t x, uint64_t y, uint64_t y_precon, uint64_t modulus)
 Returns (x * y) mod modulus. More...
 
uint64_t intel::hexl::AddUIntMod (uint64_t x, uint64_t y, uint64_t modulus)
 Returns (x + y) mod modulus. More...
 
uint64_t intel::hexl::SubUIntMod (uint64_t x, uint64_t y, uint64_t modulus)
 Returns (x - y) mod modulus. More...
 
uint64_t intel::hexl::PowMod (uint64_t base, uint64_t exp, uint64_t modulus)
 Returns base^exp mod modulus. More...
 
bool intel::hexl::IsPrimitiveRoot (uint64_t root, uint64_t degree, uint64_t modulus)
 Returns whether or not root is a degree-th root of unity mod modulus. More...
 
uint64_t intel::hexl::GeneratePrimitiveRoot (uint64_t degree, uint64_t modulus)
 Tries to return a primitive degree-th root of unity. More...
 
uint64_t intel::hexl::MinimalPrimitiveRoot (uint64_t degree, uint64_t modulus)
 Returns whether or not root is a degree-th root of unity. More...
 
template<int BitShift>
uint64_t intel::hexl::MultiplyModLazy (uint64_t x, uint64_t y_operand, uint64_t y_barrett_factor, uint64_t modulus)
 Computes (x * y) mod modulus, except that the output is in [0, 2 * modulus]. More...
 
template<int BitShift>
uint64_t intel::hexl::MultiplyModLazy (uint64_t x, uint64_t y, uint64_t modulus)
 Computes (x * y) mod modulus, except that the output is in [0, 2 * modulus]. More...
 
unsigned char intel::hexl::AddUInt64 (uint64_t operand1, uint64_t operand2, uint64_t *result)
 Adds two unsigned 64-bit integers. More...
 
bool intel::hexl::IsPrime (uint64_t n)
 Returns whether or not the input is prime. More...
 
std::vector< uint64_t > intel::hexl::GeneratePrimes (size_t num_primes, size_t bit_size, bool prefer_small_primes, size_t ntt_size=1)
 Generates a list of num_primes primes in the range [2^(bit_size),. More...
 
uint64_t intel::hexl::BarrettReduce64 (uint64_t input, uint64_t modulus, uint64_t q_barr)
 Returns input mod modulus, computed via 64-bit Barrett reduction. More...
 
template<int InputModFactor>
uint64_t intel::hexl::ReduceMod (uint64_t x, uint64_t modulus, const uint64_t *twice_modulus=nullptr, const uint64_t *four_times_modulus=nullptr)
 Returns x mod modulus, assuming x < InputModFactor * modulus. More...