Class BinFHEScheme

Page Contents

Class Documentation

class lbcrypto::BinFHEScheme

Ring GSW accumulator schemes described in https://eprint.iacr.org/2014/816, https://eprint.iacr.org/2020/086 and https://eprint.iacr.org/2022/198.

Public Functions

BinFHEScheme() = default
inline explicit BinFHEScheme(BINFHE_METHOD method)
RingGSWBTKey KeyGen(const std::shared_ptr<BinFHECryptoParams> &params, ConstLWEPrivateKey &LWEsk, KEYGEN_MODE keygenMode) const

Generates a refresh key

Parameters
  • params – a shared pointer to RingGSW scheme parameters

  • LWEsk – a shared pointer to the secret key of the underlying additive

  • keygenMode – enum to indicate generation of secret key only (SYM_ENCRYPT) or secret key, public key pair (PUB_ENCRYPT)

Returns

a shared pointer to the refresh key

LWECiphertext EvalBinGate(const std::shared_ptr<BinFHECryptoParams> &params, BINGATE gate, const RingGSWBTKey &EK, ConstLWECiphertext &ct1, ConstLWECiphertext &ct2) const

Evaluates a binary gate (calls bootstrapping as a subroutine)

Parameters
  • params – a shared pointer to RingGSW scheme parameters

  • gate – the gate; can be AND, OR, NAND, NOR, XOR, or XOR

  • EK – a shared pointer to the bootstrapping keys

  • ct1 – first ciphertext

  • ct2 – second ciphertext

Returns

a shared pointer to the resulting ciphertext

LWECiphertext EvalBinGate(const std::shared_ptr<BinFHECryptoParams> &params, BINGATE gate, const RingGSWBTKey &EK, const std::vector<LWECiphertext> &ctvector) const

Evaluates a binary gate on a vector of ciphertexts (calls bootstrapping as a subroutine). The evaluation of the gates in this function is specific to 3 input and 4 input

Parameters
  • params – a shared pointer to RingGSW scheme parameters

  • gate – the gate; can be for 3-input: AND3, OR3, MAJORITY, CMUX, for 4-input: AND4, OR4

  • EK – a shared pointer to the bootstrapping keys

  • ctvector – vector of ciphertexts

Returns

a shared pointer to the resulting ciphertext

LWECiphertext EvalNOT(const std::shared_ptr<BinFHECryptoParams> &params, ConstLWECiphertext &ct) const

Evaluates NOT gate

Parameters
  • params – a shared pointer to RingGSW scheme parameters

  • ct1 – the input ciphertext

Returns

a shared pointer to the resulting ciphertext

LWECiphertext Bootstrap(const std::shared_ptr<BinFHECryptoParams> &params, const RingGSWBTKey &EK, ConstLWECiphertext &ct) const

Bootstraps a fresh ciphertext

Parameters
  • params – a shared pointer to RingGSW scheme parameters

  • EK – a shared pointer to the bootstrapping keys

  • ct1 – input ciphertext

Returns

a shared pointer to the resulting ciphertext

LWECiphertext EvalFunc(const std::shared_ptr<BinFHECryptoParams> &params, const RingGSWBTKey &EK, ConstLWECiphertext &ct, const std::vector<NativeInteger> &LUT, const NativeInteger &beta) const

Evaluate an arbitrary function

Parameters
  • params – a shared pointer to RingGSW scheme parameters

  • EK – a shared pointer to the bootstrapping keys

  • ct – input ciphertext

  • LUT – the look-up table of the to-be-evaluated function

  • beta – the error bound

Returns

a shared pointer to the resulting ciphertext

LWECiphertext EvalFloor(const std::shared_ptr<BinFHECryptoParams> &params, const RingGSWBTKey &EK, ConstLWECiphertext &ct, const NativeInteger &beta, uint32_t roundbits = 0) const

Evaluate a round down function

Parameters
  • params – a shared pointer to RingGSW scheme parameters

  • EK – a shared pointer to the bootstrapping keys

  • ct – input ciphertext

  • beta – the error bound

  • roundbits – by how many bits to round down

Returns

a shared pointer to the resulting ciphertext

LWECiphertext EvalSign(const std::shared_ptr<BinFHECryptoParams> &params, const std::map<uint32_t, RingGSWBTKey> &EKs, ConstLWECiphertext &ct, const NativeInteger &beta, bool schemeSwitch = false) const

Evaluate a sign function over large precision

Parameters
  • params – a shared pointer to RingGSW scheme parameters

  • EK – a shared pointer to the bootstrapping keys map

  • ct – input ciphertext

  • beta – the error bound

  • schemeSwitch – flag that indicates if it should be compatible to scheme switching

Returns

a shared pointer to the resulting ciphertext

std::vector<LWECiphertext> EvalDecomp(const std::shared_ptr<BinFHECryptoParams> &params, const std::map<uint32_t, RingGSWBTKey> &EKs, ConstLWECiphertext &ct, const NativeInteger &beta) const

Evaluate digit decomposition over a large precision LWE ciphertext

Parameters
  • params – a shared pointer to RingGSW scheme parameters

  • EKs – a shared pointer to the bootstrapping keys map

  • ct – input ciphertext

  • beta – the error bound

Returns

a shared pointer to the resulting ciphertext

Protected Attributes

std::shared_ptr<LWEEncryptionScheme> LWEscheme = {std::make_shared<LWEEncryptionScheme>()}
std::shared_ptr<RingGSWAccumulator> ACCscheme = {nullptr}

Protected Static Functions

static inline uint32_t checkInputFunction(const std::vector<NativeInteger> &lut, NativeInteger mod)

Checks type of input function

Parameters
  • lut – look up table for the input function

  • mod – modulus over which the function is defined

Returns

the function type: 0 for negacyclic, 1 for periodic, 2 for arbitrary