The public key. More...
#include <keys.h>
  
Public Member Functions | |
| PubKey () | |
| This constructor thorws run-time error if activeContext=nullptr.  More... | |
| PubKey (const Context &_context) | |
| PubKey (const PubKey &other) | |
| Copy constructor.  More... | |
| virtual | ~PubKey ()=default | 
| Default destructor.  More... | |
| virtual void | clear () | 
| Clear all public-key data.  More... | |
| bool | operator== (const PubKey &other) const | 
| bool | operator!= (const PubKey &other) const | 
| const Context & | getContext () const | 
| long | getPtxtSpace () const | 
| bool | keyExists (long keyID) const | 
| double | getSKeyBound (long keyID=0) const | 
| The size of the secret key.  More... | |
| 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 (KeySwitchMap)  More... | |
| void | setKeySwitchMap (long keyId=0) | 
| Compute the reachability graph of key-switching matrices See Section 3.2.2 in the design document (KeySwitchMap)  More... | |
| long | getKSStrategy (long dim) const | 
| get KS strategy for dimension dim dim == -1 is Frobenius  More... | |
| void | setKSStrategy (long dim, int val) | 
| set KS strategy for dimension dim dim == -1 is Frobenius  More... | |
| long | Encrypt (Ctxt &ciphertxt, const NTL::ZZX &plaintxt, long ptxtSpace, bool highNoise) const | 
| long | Encrypt (Ctxt &ciphertxt, const zzX &plaintxt, long ptxtSpace, bool highNoise) const | 
| void | CKKSencrypt (Ctxt &ciphertxt, const NTL::ZZX &plaintxt, double ptxtSize=1.0, double scaling=0.0) const | 
| void | CKKSencrypt (Ctxt &ciphertxt, const zzX &plaintxt, double ptxtSize=1.0, double scaling=0.0) const | 
| virtual long | Encrypt (Ctxt &ciphertxt, const NTL::ZZX &plaintxt, long ptxtSpace=0) const | 
| virtual long | Encrypt (Ctxt &ciphertxt, const zzX &plaintxt, long ptxtSpace=0) const | 
| template<typename Scheme > | |
| long | Encrypt (Ctxt &ciphertxt, const Ptxt< Scheme > &plaintxt, long ptxtSpace=0) const | 
| Encrypts a plaintext into a ciphertext.  More... | |
| double | securityLevel () const | 
| An estimate for the security level. The estimated security level for the "worst" secret-key associated with this public-key object. The security estimate is determined by the key's weight and the context parameters.  More... | |
| bool | isCKKS () const | 
| bool | isBootstrappable () const | 
| void | reCrypt (Ctxt &ctxt) const | 
| void | thinReCrypt (Ctxt &ctxt) const | 
| friend | void ::helib::writePubKeyBinary (std::ostream &str, const PubKey &pk) | 
| friend | void ::helib::readPubKeyBinary (std::istream &str, PubKey &pk) | 
| void | hackPtxtSpace (long p2r) | 
| template<> | |
| long | Encrypt (Ctxt &ciphertxt, const Ptxt< BGV > &plaintxt, long ptxtSpace) const | 
| template<> | |
| long | Encrypt (Ctxt &ciphertxt, const Ptxt< CKKS > &plaintxt, UNUSED long ptxtSpace) const | 
Find key-switching matrices  | |
| const std::vector< KeySwitch > & | keySWlist () const | 
| 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 toKeyID==-1.  More... | |
| const KeySwitch & | getKeySWmatrix (long fromSPower, long fromXPower, long fromID=0, long toID=0) const | 
| bool | haveKeySWmatrix (const SKHandle &from, long toID=0) const | 
| bool | haveKeySWmatrix (long fromSPower, long fromXPower, long fromID=0, long toID=0) const | 
| const KeySwitch & | getAnyKeySWmatrix (const SKHandle &from) const | 
| Is there a matrix from this key to any base key?  More... | |
| bool | haveAnyKeySWmatrix (const SKHandle &from) const | 
| 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.  More... | |
Static Public Member Functions | |
| static long | ePlusR (long p) | 
Friends | |
| class | SecKey | 
| std::ostream & | operator<< (std::ostream &str, const PubKey &pk) | 
| std::istream & | operator>> (std::istream &str, PubKey &pk) | 
Detailed Description
The public key.
Constructor & Destructor Documentation
◆ PubKey() [1/3]
| helib::PubKey::PubKey | ( | ) | 
This constructor thorws run-time error if activeContext=nullptr.
◆ PubKey() [2/3]
      
  | 
  explicit | 
◆ PubKey() [3/3]
| helib::PubKey::PubKey | ( | const PubKey & | other | ) | 
Copy constructor.
◆ ~PubKey()
      
  | 
  virtualdefault | 
Default destructor.
Member Function Documentation
◆ CKKSencrypt() [1/2]
| void helib::PubKey::CKKSencrypt | ( | Ctxt & | ciphertxt, | 
| const NTL::ZZX & | plaintxt, | ||
| double | ptxtSize = 1.0,  | 
        ||
| double | scaling = 0.0  | 
        ||
| ) | const | 
◆ CKKSencrypt() [2/2]
| void helib::PubKey::CKKSencrypt | ( | Ctxt & | ciphertxt, | 
| const zzX & | plaintxt, | ||
| double | ptxtSize = 1.0,  | 
        ||
| double | scaling = 0.0  | 
        ||
| ) | const | 
◆ clear()
      
  | 
  virtual | 
Clear all public-key data.
Reimplemented in helib::SecKey.
◆ Encrypt() [1/7]
| long helib::PubKey::Encrypt | ( | Ctxt & | ciphertxt, | 
| const NTL::ZZX & | plaintxt, | ||
| long | ptxtSpace, | ||
| bool | highNoise | ||
| ) | const | 
Encrypts plaintext, result returned in the ciphertext argument. When called with highNoise=true, returns a ciphertext with noise level approximately q/8. For BGV, ptxtSpace is the intended plaintext space, which cannot be co-prime with pubEncrKey.ptxtSpace. The returned value is the plaintext-space for the resulting ciphertext, which is GCD(ptxtSpace, pubEncrKey.ptxtSpace). For CKKS, ptxtSpace is a bound on the size of the complex plaintext elements that are encoded in ptxt (before scaling), it is assumed that they are scaled by context.alMod.encodeScalingFactor(). The VJS-FIXME: this comment must mean alMod.getCx()...check returned value is the same as the argument ptxtSpace.
◆ Encrypt() [2/7]
      
  | 
  virtual | 
Reimplemented in helib::SecKey.
◆ Encrypt() [3/7]
| long helib::PubKey::Encrypt | ( | Ctxt & | ciphertxt, | 
| const Ptxt< BGV > & | plaintxt, | ||
| long | ptxtSpace | ||
| ) | const | 
◆ Encrypt() [4/7]
| long helib::PubKey::Encrypt | ( | Ctxt & | ciphertxt, | 
| const Ptxt< CKKS > & | plaintxt, | ||
| UNUSED long | ptxtSpace | ||
| ) | const | 
◆ Encrypt() [5/7]
◆ Encrypt() [6/7]
| long helib::PubKey::Encrypt | ( | Ctxt & | ciphertxt, | 
| const zzX & | plaintxt, | ||
| long | ptxtSpace, | ||
| bool | highNoise | ||
| ) | const | 
◆ Encrypt() [7/7]
      
  | 
  virtual | 
Reimplemented in helib::SecKey.
◆ ePlusR()
      
  | 
  static | 
◆ getAnyKeySWmatrix()
Is there a matrix from this key to any base key?
◆ getContext()
| const Context & helib::PubKey::getContext | ( | ) | const | 
◆ getKeySWmatrix() [1/2]
Find a key-switching matrix by its indexes. If no such matrix exists it returns a dummy matrix with toKeyID==-1.
◆ getKeySWmatrix() [2/2]
| const KeySwitch & helib::PubKey::getKeySWmatrix | ( | long | fromSPower, | 
| long | fromXPower, | ||
| long | fromID = 0,  | 
        ||
| long | toID = 0  | 
        ||
| ) | const | 
◆ getKSStrategy()
| long helib::PubKey::getKSStrategy | ( | long | dim | ) | const | 
get KS strategy for dimension dim dim == -1 is Frobenius
◆ getNextKSWmatrix()
| const KeySwitch & helib::PubKey::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.
◆ getPtxtSpace()
| long helib::PubKey::getPtxtSpace | ( | ) | const | 
◆ getSKeyBound()
| double helib::PubKey::getSKeyBound | ( | long | keyID = 0 | ) | const | 
The size of the secret key.
◆ hackPtxtSpace()
      
  | 
  inline | 
◆ haveAnyKeySWmatrix()
| bool helib::PubKey::haveAnyKeySWmatrix | ( | const SKHandle & | from | ) | const | 
◆ haveKeySWmatrix() [1/2]
| bool helib::PubKey::haveKeySWmatrix | ( | const SKHandle & | from, | 
| long | toID = 0  | 
        ||
| ) | const | 
◆ haveKeySWmatrix() [2/2]
| bool helib::PubKey::haveKeySWmatrix | ( | long | fromSPower, | 
| long | fromXPower, | ||
| long | fromID = 0,  | 
        ||
| long | toID = 0  | 
        ||
| ) | const | 
◆ isBootstrappable()
| bool helib::PubKey::isBootstrappable | ( | ) | const | 
◆ isCKKS()
| bool helib::PubKey::isCKKS | ( | ) | const | 
◆ isReachable()
| bool helib::PubKey::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 (KeySwitchMap)
◆ keyExists()
| bool helib::PubKey::keyExists | ( | long | keyID | ) | const | 
◆ keySWlist()
| const std::vector< KeySwitch > & helib::PubKey::keySWlist | ( | ) | const | 
◆ operator!=()
| bool helib::PubKey::operator!= | ( | const PubKey & | other | ) | const | 
◆ operator==()
| bool helib::PubKey::operator== | ( | const PubKey & | other | ) | const | 
◆ reCrypt()
| void helib::PubKey::reCrypt | ( | Ctxt & | ctxt | ) | const | 
◆ securityLevel()
      
  | 
  inline | 
An estimate for the security level. The estimated security level for the "worst" secret-key associated with this public-key object. The security estimate is determined by the key's weight and the context parameters.
- Returns
 - The estimate for the security level.
 
◆ setKeySwitchMap()
| void helib::PubKey::setKeySwitchMap | ( | long | keyId = 0 | ) | 
Compute the reachability graph of key-switching matrices See Section 3.2.2 in the design document (KeySwitchMap)
◆ setKSStrategy()
| void helib::PubKey::setKSStrategy | ( | long | dim, | 
| int | val | ||
| ) | 
set KS strategy for dimension dim dim == -1 is Frobenius
◆ thinReCrypt()
| void helib::PubKey::thinReCrypt | ( | Ctxt & | ctxt | ) | const | 
◆ void ::helib::readPubKeyBinary()
| helib::PubKey::void ::helib::readPubKeyBinary | ( | std::istream & | str, | 
| PubKey & | pk | ||
| ) | 
◆ void ::helib::writePubKeyBinary()
| helib::PubKey::void ::helib::writePubKeyBinary | ( | std::ostream & | str, | 
| const PubKey & | pk | ||
| ) | 
Friends And Related Function Documentation
◆ operator<<
      
  | 
  friend | 
◆ operator>>
      
  | 
  friend | 
◆ SecKey
      
  | 
  friend | 
 1.8.19