Class SWITCHCKKSRNS
Defined in File ckksrns-schemeswitching.h
Page Contents
Inheritance Relationships
Base Type
public lbcrypto::FHERNS
(Class FHERNS)
Class Documentation
-
class lbcrypto::SWITCHCKKSRNS : public lbcrypto::FHERNS
Inheritence diagram for lbcrypto::SWITCHCKKSRNS:
Collaboration diagram for lbcrypto::SWITCHCKKSRNS:
Public Functions
-
inline virtual ~SWITCHCKKSRNS()
-
virtual LWEPrivateKey EvalCKKStoFHEWSetup(const SchSwchParams ¶ms) override
Sets all parameters for switching from CKKS to FHEW
- Parameters
params – objects holding all necessary paramters
- Returns
the FHEW secret key
-
virtual std::shared_ptr<std::map<usint, EvalKey<DCRTPoly>>> EvalCKKStoFHEWKeyGen(const KeyPair<DCRTPoly> &keyPair, ConstLWEPrivateKey &lwesk) override
Virtual function to define the generation of all keys for scheme switching between CKKS and FHEW: the rotation keys for the baby-step/giant-step strategy, conjugation keys, switching key from CKKS to FHEW
- Parameters
keypair – CKKS key pair
lwesk – FHEW secret key
-
virtual void EvalCKKStoFHEWPrecompute(const CryptoContextImpl<DCRTPoly> &cc, double scale) override
Performs precomputations for the homomorphic decoding in CKKS. Given as a separate method than EvalCKKStoFHEWSetup to allow the user to specify a scale that depends on the CKKS and FHEW cryptocontexts
- Parameters
cc – the CKKS cryptocontext from which to switch
scale – factor with which to scale the matrix in the linear transform
dim1 – baby-step for the linear transform
L – level on which the hom. decoding matrix should be. We want the hom. decoded ciphertext to be on the last level
-
virtual std::vector<std::shared_ptr<LWECiphertextImpl>> EvalCKKStoFHEW(ConstCiphertext<DCRTPoly> ciphertext, uint32_t numCtxts) override
Performs the scheme switching on a CKKS ciphertext
- Parameters
ciphertext – CKKS ciphertext to switch
numCtxts – number of coefficients to extract from the CKKS ciphertext. If it is zero, it defaults to number of slots
- Returns
a vector of LWE ciphertexts of length the numCtxts
Sets all parameters for switching from FHEW to CKKS. The CKKS cryptocontext to switch to is already generated.
- Parameters
ccCKKS – the CKKS cryptocontext to switch to
ccLWE – the FHEW cryptocontext from which to switch
numSlotsCKKS – number of FHEW ciphertexts that becomes the number of slots in CKKS encryption
logQ – the logarithm of a ciphertext modulus in FHEW
-
virtual std::shared_ptr<std::map<usint, EvalKey<DCRTPoly>>> EvalFHEWtoCKKSKeyGen(const KeyPair<DCRTPoly> &keyPair, ConstLWEPrivateKey &lwesk, uint32_t numSlots, uint32_t numCtxts, uint32_t dim1, uint32_t L) override
Generates all keys for scheme switching: the rotation keys for the baby-step/giant-step strategy in the linear transform for the partial decryption, the switching key from FHEW to CKKS
- Parameters
keypair – CKKS key pair
lwesk – FHEW secret key
numSlots – number of slots for the CKKS encryption of the FHEW secret key
numCtxts – number of values to encrypt from the LWE ciphertexts in the new CKKS ciphertext
dim1 – baby-step for the linear transform
L – level on which the hom. decoding matrix should be. We want the hom. decoded ciphertext to be on the last level
Performs the scheme switching on a vector of FHEW ciphertexts
- Parameters
LWECiphertexts – FHEW/LWE ciphertexts to switch
numCtxts – number of values to encrypt from the LWE ciphertexts in the new CKKS ciphertext
numSlots – number of slots to encode in the new CKKS/RLWE ciphertext
p – plaintext modulus to use to decide postscaling, by default p = 4
pmin, pmax – plaintext space of the resulting messages (by default [0,2] assuming the LWE ciphertext had plaintext modulus p = 4 and only bits were encrypted)
dim1 – baby-step for the linear transform, necessary only for argmin
- Returns
a CKKS ciphertext encrypting in its slots the messages in the LWE ciphertexts
-
virtual LWEPrivateKey EvalSchemeSwitchingSetup(const SchSwchParams ¶ms) override
Sets all parameters for switching from CKKS to FHEW and back
- Parameters
params – objects holding all necessary paramters
- Returns
the FHEW secret key TODO: add an overload for when BinFHEContext is already generated and fed as a parameter
-
virtual std::shared_ptr<std::map<usint, EvalKey<DCRTPoly>>> EvalSchemeSwitchingKeyGen(const KeyPair<DCRTPoly> &keyPair, ConstLWEPrivateKey &lwesk) override
Generates all keys for scheme switching: the rotation keys for the baby-step/giant-step strategy in the linear transform for the homomorphic encoding and partial decryption, the switching key from FHEW to CKKS
- Parameters
keypair – CKKS key pair
lwesk – FHEW secret key
-
virtual void EvalCompareSwitchPrecompute(const CryptoContextImpl<DCRTPoly> &ccCKKS, uint32_t pLWE, double scaleSign, bool unit) override
Performs precomputations for the homomorphic decoding in CKKS. Given as a separate method than EvalSchemeSwitchingSetup to allow the user to specify a scale that depends on the CKKS and FHEW cryptocontexts
- Parameters
cc – the CKKS cryptocontext from which to switch
pLWE – the desired plaintext modulus for the new FHEW ciphertexts
scaleSign – factor to multiply the CKKS ciphertext when switching to FHEW in case the messages are too small; the resulting FHEW ciphertexts will encrypt values modulo pLWE, so scaleSign should account for this
unit – whether the input messages are normalized to the unit circle
-
virtual Ciphertext<DCRTPoly> EvalCompareSchemeSwitching(ConstCiphertext<DCRTPoly> ciphertext1, ConstCiphertext<DCRTPoly> ciphertext2, uint32_t numCtxts, uint32_t numSlots, uint32_t pLWE, double scaleSign, bool unit) override
Performs the scheme switching on the difference of two CKKS ciphertexts to compare, evaluates the sign function over the resulting FHEW ciphertexts, then performs the scheme switching back to a CKKS ciphertext
- Parameters
ciphertext1, ciphertext2 – CKKS ciphertexts of messages that need to be compared
numCtxts – number of coefficients to extract from the CKKS ciphertext. If it is zero, it defaults to number of slots
numSlots – number of slots to encode the new CKKS ciphertext with
pLWE – the desired plaintext modulus for the new FHEW ciphertexts. If it is zero, it defaults to the large precision plaintext modulus Q/2beta
scaleSign – factor to multiply the CKKS ciphertext when switching to FHEW in case the messages are too small; the resulting FHEW ciphertexts will encrypt values modulo pLWE, so scaleSign should account for this
unit – whether the input messages are normalized to the unit circle
- Returns
a CKKS ciphertext encrypting in its slots the sign of messages in the LWE ciphertexts
-
virtual std::vector<Ciphertext<DCRTPoly>> EvalMinSchemeSwitching(ConstCiphertext<DCRTPoly> ciphertext, PublicKey<DCRTPoly> publicKey, uint32_t numValues, uint32_t numSlots, uint32_t pLWE, double scaleSign) override
Computes the minimum and argument of the first numValues packed in a CKKS ciphertext via repeated scheme switchings to FHEW and back.
- Parameters
ciphertext – CKKS ciphertexts of values that need to be compared
publicKey – public key of the CKKS cryptocontext
numValues – number of values to extract from the CKKS ciphertext. We always assume for the moment numValues is a power of two
numSlots – number of slots to encode the new CKKS ciphertext with
pLWE – the desired plaintext modulus for the new FHEW ciphertexts
scaleSign – factor to multiply the CKKS ciphertext when switching to FHEW in case the messages are too small; the resulting FHEW ciphertexts will encrypt values modulo pLWE, so scaleSign should account for this pLWE and scaleSign are given here only if the homomorphic decoding matrix is not scaled with the desired values
- Returns
a vector of two CKKS ciphertexts where the first encrypts the minimum value and the second encrypts the index (in the representation specified by oneHot). The ciphertexts have junk after the first slot in the first ciphertext and after numValues in the second ciphertext if oneHot=true and after the first slot if oneHot=false.
-
virtual std::vector<Ciphertext<DCRTPoly>> EvalMinSchemeSwitchingAlt(ConstCiphertext<DCRTPoly> ciphertext, PublicKey<DCRTPoly> publicKey, uint32_t numValues, uint32_t numSlots, uint32_t pLWE, double scaleSign) override
Performs more operations in FHEW than in CKKS. Slightly better precision but slower.
-
virtual std::vector<Ciphertext<DCRTPoly>> EvalMaxSchemeSwitching(ConstCiphertext<DCRTPoly> ciphertext, PublicKey<DCRTPoly> publicKey, uint32_t numValues, uint32_t numSlots, uint32_t pLWE, double scaleSign) override
Computes the maximum and argument of the first numValues packed in a CKKS ciphertext via repeated scheme switchings to FHEW and back.
- Parameters
ciphertext – CKKS ciphertexts of values that need to be compared
publicKey – public key of the CKKS cryptocontext
numValues – number of values to extract from the CKKS ciphertext. We always assume for the moment numValues is a power of two
numSlots – number of slots to encode the new CKKS ciphertext with
pLWE – the desired plaintext modulus for the new FHEW ciphertexts
scaleSign – factor to multiply the CKKS ciphertext when switching to FHEW in case the messages are too small; the resulting FHEW ciphertexts will encrypt values modulo pLWE, so scaleSign should account for this pLWE and scaleSign are given here only if the homomorphic decoding matrix is not scaled with the desired values
- Returns
a vector of two CKKS ciphertexts where the first encrypts the maximum value and the second encrypts the index (in the representation specified by oneHot). The ciphertexts have junk after the first slot in the first ciphertext and after numValues in the second ciphertext if oneHot=true and after the first slot if oneHot=false.
-
virtual std::vector<Ciphertext<DCRTPoly>> EvalMaxSchemeSwitchingAlt(ConstCiphertext<DCRTPoly> ciphertext, PublicKey<DCRTPoly> publicKey, uint32_t numValues, uint32_t numSlots, uint32_t pLWE, double scaleSign) override
Performs more operations in FHEW than in CKKS. Slightly better precision but slower.
-
inline virtual std::shared_ptr<lbcrypto::BinFHEContext> GetBinCCForSchemeSwitch() override
Getter and setter for the binFHE cryptocontext used in scheme switching
-
inline virtual Ciphertext<DCRTPoly> GetSwkFC() override
Getter and setter for the switching key between FHEW to CKKS
-
inline virtual void SetSwkFC(Ciphertext<DCRTPoly> FHEWtoCKKSswk) override
-
inline uint32_t GetNumCtxtsToSwitch()
-
inline NativeInteger GetModulusLWEToSwitch()
-
inline std::string SerializedObjectName() const
-
inline virtual ~SWITCHCKKSRNS()