keys.h
Implementing polynomials (elements in the ring R_Q) in double-CRT form.
Definition: DoubleCRT.h:76
Definition: EncodedPtxt.h:21
Definition: EncodedPtxt.h:39
Definition: EncodedPtxt.h:143
Represents the set of long int's plus a distinguished value that can be used to denote "undefined"....
Definition: NumbTh.h:998
An object that mimics the functionality of the Ctxt object, and acts as a convenient entry point for ...
Definition: Ptxt.h:188
long Encrypt(Ctxt &ciphertxt, const NTL::ZZX &plaintxt, long ptxtSpace, bool highNoise) const
Definition: keys.cpp:351
const KeySwitch & getNextKSWmatrix(long fromXPower, long fromID=0) const
Get the next matrix to use for multi-hop automorphism See Section 3.2.2 in the design document.
Definition: keys.cpp:303
static PubKey readFrom(std::istream &str, const Context &context)
Read from the stream the serialized PubKey object in binary format.
Definition: keys.cpp:916
friend std::istream & operator>>(std::istream &str, PubKey &pk)
Definition: keys.cpp:872
const KeySwitch & getKeySWmatrix(const SKHandle &from, long toID=0) const
Find a key-switching matrix by its indexes. If no such matrix exists it returns a dummy matrix with t...
Definition: keys.cpp:167
void setKSStrategy(long dim, int val)
set KS strategy for dimension dim dim == -1 is Frobenius
Definition: keys.cpp:328
void readJSON(std::istream &str)
In-place read from the stream the serialized public key (PubKey) object using JSON format.
Definition: keys.cpp:1008
void writeTo(std::ostream &str) const
Write out the PubKey object in binary format.
Definition: keys.cpp:881
void Encrypt(Ctxt &ciphertxt, const Ptxt< Scheme > &plaintxt) const
Encrypts a plaintext into a ciphertext.
long getKSStrategy(long dim) const
get KS strategy for dimension dim dim == -1 is Frobenius
Definition: keys.cpp:314
bool isReachable(long k, long keyID=0) const
Is it possible to re-linearize the automorphism X -> X^k See Section 3.2.2 in the design document (Ke...
Definition: keys.cpp:309
const KeySwitch & getAnyKeySWmatrix(const SKHandle &from) const
Is there a matrix from this key to any base key?
Definition: keys.cpp:188
bool haveAnyKeySWmatrix(const SKHandle &from) const
Definition: keys.cpp:298
static PubKey readFromJSON(std::istream &str, const Context &context)
Read from the stream the serialized public key (PubKey) object using JSON format.
Definition: keys.cpp:992
void setKeySwitchMap(long keyId=0)
Compute the reachability graph of key-switching matrices See Section 3.2.2 in the design document (Ke...
Definition: keys.cpp:115
friend std::ostream & operator<<(std::ostream &str, const PubKey &pk)
Definition: keys.cpp:866
JsonWrapper writeToJSON() const
Write out the public key (PubKey) object to a JsonWrapper.
Definition: keys.cpp:974
PubKey()=delete
bool haveKeySWmatrix(const SKHandle &from, long toID=0) const
Definition: keys.cpp:285
void CKKSencrypt(Ctxt &ciphertxt, const NTL::ZZX &plaintxt, double ptxtSize=1.0, double scaling=0.0) const
Definition: keys.cpp:494
static long ePlusR(long p)
double getSKeyBound(long keyID=0) const
The size of the secret key.
Definition: keys.cpp:273
static constexpr std::string_view typeName
Class label to be added to JSON serialization as object type information.
Definition: keys.h:77
A handle, describing the secret-key element that "matches" a part, of the form s^r(X^t).
Definition: Ctxt.h:81
void writeTo(std::ostream &str) const
Write out the SecKey object in binary format.
Definition: keys.cpp:1729
JsonWrapper writeToJSON() const
Write out the secret key (SecKey) object to a JsonWrapper.
Definition: keys.cpp:1775
void GenKeySWmatrix(long fromSPower, long fromXPower, long fromKeyIdx=0, long toKeyIdx=0, long ptxtSpace=0)
Definition: keys.cpp:1152
const DoubleCRT & getRecryptKey() const
Getter method for the recryption key.
Definition: keys.h:418
void Decrypt(NTL::ZZX &plaintxt, const Ctxt &ciphertxt) const
Definition: keys.cpp:1251
~SecKey() override=default
static SecKey readFrom(std::istream &str, const Context &context)
Read from the stream the serialized SecKey object in binary format.
Definition: keys.cpp:1745
long Encrypt(Ctxt &ciphertxt, const NTL::ZZX &plaintxt, long ptxtSpace=0) const override
Definition: keys.cpp:1533
long genRecryptData()
Generate bootstrapping data if needed, returns index of key.
Definition: keys.cpp:1671
SecKey()=delete
long GenSecKey(long ptxtSpace=0, long maxDegKswitch=3)
Definition: keys.cpp:1132
friend std::istream & operator>>(std::istream &str, SecKey &sk)
Definition: keys.cpp:1723
long ImportSecKey(const DoubleCRT &sKey, double bound, long ptxtSpace=0, long maxDegKswitch=3)
Definition: keys.cpp:1092
friend std::ostream & operator<<(std::ostream &str, const SecKey &sk)
Definition: keys.cpp:1708
std::ostream & writeSecKeyDerivedASCII(std::ostream &str) const
Definition: keys.cpp:1715
static SecKey readFromJSON(std::istream &str, const Context &context)
Read from the stream the serialized secret key (SecKey) object using JSON format.
Definition: keys.cpp:1786
void readJSON(std::istream &str)
Read from the stream the serialized secret key (SecKey) object using JSON format.
Definition: keys.cpp:1804
long skEncrypt(Ctxt &ctxt, const NTL::ZZX &ptxt, long ptxtSpace, long skIdx) const
Symmetric encryption using the secret key.
Definition: keys.cpp:1417
void Decrypt(Ptxt< Scheme > &plaintxt, const Ctxt &ciphertxt, OptLong prec=OptLong()) const
Decrypt a ciphertext into a plaintext.
static constexpr std::string_view typeName
Class label to be added to JSON serialization as object type information.
Definition: keys.h:322
Definition: apiAttributes.h:21
double RLWE(DoubleCRT &c0, DoubleCRT &c1, const DoubleCRT &s, long p, NTL::ZZ *prgSeed=nullptr)
Definition: keys.cpp:69
double RLWE1(DoubleCRT &c0, const DoubleCRT &c1, const DoubleCRT &s, long p)
Same as RLWE, but assumes that c1 is already chosen by the caller.
Definition: keys.cpp:33
Definition: JsonWrapper.h:9