EncryptedArray.h
A smart pointer that clones the object it holds when it is copied.
Definition: ClonedPtr.h:101
const T * get() const
Get the pointer managed by ClonedPtr object.
Definition: ClonedPtr.h:235
const EncryptedArray & getView() const
Getter method returning the default view object of the created context.
Definition: Context.h:416
long getPhiM() const
Getter method for the phi(m) of the created context.
Definition: Context.h:264
double noiseBoundForUniform(double magBound, long degBound) const
Definition: Context.h:474
Implementing polynomials (elements in the ring R_Q) in double-CRT form.
Definition: DoubleCRT.h:76
Definition: EncodedPtxt.h:143
void resetBGV(const zzX &poly, long ptxtSpace, const Context &context)
Definition: EncodedPtxt.h:164
virtual class for data-movement operations on arrays of slots
Definition: EncryptedArray.h:120
virtual void decode(std::vector< NTL::ZZX > &array, const NTL::ZZX &ptxt) const =0
virtual void rawDecrypt(const Ctxt &ctxt, const SecKey &sKey, std::vector< cx_double > &ptxt) const =0
virtual void decryptReal(const Ctxt &ctxt, const SecKey &sKey, PlaintextArray &ptxt, OptLong prec=OptLong()) const =0
long coordinate(long i, long k) const
returns coordinate of index k along the i'th dimension
Definition: EncryptedArray.h:369
virtual void buildLinPolyCoeffs(std::vector< NTL::ZZX > &C, const std::vector< NTL::ZZX > &L) const =0
Linearized polynomials. L describes a linear map M by describing its action on the standard power bas...
virtual void shift1D(Ctxt &ctxt, long i, long k) const =0
Right shift k positions along the i'th dimension with zero fill.
virtual void decrypt(const Ctxt &ctxt, const SecKey &sKey, PlaintextArray &ptxt, OptLong prec=OptLong()) const =0
virtual double defaultScale(UNUSED double err, UNUSED OptLong prec=OptLong()) const
Definition: EncryptedArray.h:218
virtual void decrypt(const Ctxt &ctxt, const SecKey &sKey, std::vector< cx_double > &ptxt, OptLong prec=OptLong()) const =0
virtual void decrypt(const Ctxt &ctxt, const SecKey &sKey, std::vector< double > &ptxt, OptLong prec=OptLong()) const =0
bool nativeDimension(long i) const
Is rotations in given dimension a "native" operation?
Definition: EncryptedArray.h:366
virtual void restoreContext() const
Definition: EncryptedArray.h:351
virtual long getDegree() const =0
virtual void rotate1D(Ctxt &ctxt, long i, long k, bool dc=false) const =0
right-rotate k positions along the i'th dimension
virtual ~EncryptedArrayBase()
Definition: EncryptedArray.h:122
void decrypt1Slot(NTL::ZZX &slot, const Ctxt &ctxt, const SecKey &sKey, long i) const
Definition: EncryptedArray.h:326
virtual void encode(EncodedPtxt &eptxt, const std::vector< bool > &array) const =0
virtual void encode(EncodedPtxt &eptxt, const std::vector< cx_double > &array, double mag=-1, OptLong prec=OptLong()) const =0
virtual long getP2R() const =0
virtual void rawDecryptReal(const Ctxt &ctxt, const SecKey &sKey, PlaintextArray &ptxt) const =0
virtual void encode(NTL::ZZX &ptxt, const std::vector< NTL::ZZX > &array) const =0
virtual void decrypt(const Ctxt &ctxt, const SecKey &sKey, std::vector< long > &ptxt) const =0
virtual void random(std::vector< NTL::ZZX > &array) const =0
long dimension() const
Number of dimensions of hypercube.
Definition: EncryptedArray.h:360
virtual PA_tag getTag() const =0
virtual void encode(zzX &ptxt, const std::vector< zzX > &array) const =0
virtual void encode(EncodedPtxt &eptxt, const std::vector< NTL::ZZX > &array) const =0
long size() const
Total size (# of slots) of hypercube.
Definition: EncryptedArray.h:357
virtual void encode(NTL::ZZX &ptxt, const std::vector< long > &array) const =0
virtual void encode(EncodedPtxt &eptxt, const std::vector< long > &array) const =0
virtual void shift(Ctxt &ctxt, long k) const =0
Non-cyclic right shift with zero fill E.g., shifting ctxt=Enc(1 2 3 ... n) by k=1 gives Enc(0 1 2....
virtual void decode(PlaintextArray &array, const NTL::ZZX &ptxt) const =0
long sizeOfDimension(long i) const
Size of given dimension.
Definition: EncryptedArray.h:363
virtual void encode(zzX &ptxt, const PlaintextArray &array) const =0
virtual void encode(zzX &ptxt, const std::vector< long > &array) const =0
virtual const Context & getContext() const =0
virtual void encode(EncodedPtxt &eptxt, const std::vector< double > &array, double mag=-1, OptLong prec=OptLong()) const =0
virtual void decode(std::vector< long > &array, const NTL::ZZX &ptxt) const =0
virtual void rotate(Ctxt &ctxt, long k) const =0
Right rotation as a linear array. E.g., rotating ctxt=Enc(1 2 3 ... n) by k=1 gives Enc(n 1 2 ....
virtual void encodeUnitSelector(EncodedPtxt &eptxt, long i) const =0
long decode1Slot(const NTL::ZZX &ptxt, long i) const
Definition: EncryptedArray.h:245
long decrypt1Slot(const Ctxt &ctxt, const SecKey &sKey, long i) const
Definition: EncryptedArray.h:320
virtual void rawDecrypt(const Ctxt &ctxt, const SecKey &sKey, std::vector< double > &ptxt) const =0
void decode1Slot(NTL::ZZX &slot, const NTL::ZZX &ptxt, long i) const
Definition: EncryptedArray.h:251
virtual void encode(zzX &ptxt, const std::vector< NTL::ZZX > &array) const =0
virtual void rawDecrypt(const Ctxt &ctxt, const SecKey &sKey, PlaintextArray &ptxt) const =0
virtual void rawDecryptComplex(const Ctxt &ctxt, const SecKey &sKey, PlaintextArray &ptxt) const =0
virtual void encode(EncodedPtxt &eptxt, const PlaintextArray &array, double mag=-1, OptLong prec=OptLong()) const =0
virtual void decrypt(const Ctxt &ctxt, const SecKey &sKey, std::vector< NTL::ZZX > &ptxt) const =0
virtual void restoreContextForG() const
Definition: EncryptedArray.h:352
virtual void encodeUnitSelector(zzX &ptxt, long i) const =0
Encodes a std::vector with 1 at position i and 0 everywhere else.
virtual const PAlgebra & getPAlgebra() const =0
virtual void decryptComplex(const Ctxt &ctxt, const SecKey &sKey, PlaintextArray &ptxt, OptLong prec=OptLong()) const =0
virtual void random(std::vector< long > &array) const =0
void rotate1D(std::vector< U > &out, const std::vector< U > &in, long i, long offset) const
rotate an array by offset in the i'th dimension (output should not alias input)
Definition: EncryptedArray.h:383
virtual double defaultErr() const
Definition: EncryptedArray.h:224
long addCoord(long i, long k, long offset) const
adds offset to index k in the i'th dimension
Definition: EncryptedArray.h:375
virtual void encode(NTL::ZZX &ptxt, const PlaintextArray &array) const =0
virtual EncryptedArrayBase * clone() const =0
A different derived class to be used for the approximate-numbers scheme.
Definition: EncryptedArray.h:880
PA_tag getTag() const override
Definition: EncryptedArray.h:915
virtual void encode(EncodedPtxt &eptxt, const std::vector< bool > &array) const override
Definition: EncryptedArray.h:1216
void decode(std::vector< cx_double > &array, const NTL::ZZX &ptxt, double scaling) const
Definition: EncryptedArray.h:1355
void encode(UNUSED NTL::ZZX &ptxt, UNUSED const std::vector< NTL::ZZX > &array) const override
Unimplemented encode function for BGV. It will always throw helib::LogicError.
Definition: EncryptedArray.h:989
void encodeUnitSelector(zzX &ptxt, long i) const override
Encodes a std::vector with 1 at position i and 0 everywhere else.
Definition: EncryptedArray.h:1278
virtual double defaultScale(double err, OptLong prec=OptLong()) const override
Definition: EncryptedArray.h:1331
const Context & getContext() const override
Definition: EncryptedArray.h:916
void decrypt(const Ctxt &ctxt, const SecKey &sKey, Ptxt< Scheme > &ptxt, OptLong prec=OptLong()) const
Decrypt ciphertext to a plaintext relative to a specific scheme.
Definition: EncryptedArray.h:1466
void decode(UNUSED PlaintextArray &array, UNUSED const NTL::ZZX &ptxt) const override
Unimplemented decode function for BGV. It will always throw helib::LogicError.
Definition: EncryptedArray.h:1041
void extractImPart(Ptxt< Scheme > &p) const
Extract the imaginary part of a CKKS plaintext.
Definition: EncryptedArray.h:1495
EncryptedArrayBase * clone() const override
Definition: EncryptedArray.h:909
void encode(UNUSED NTL::ZZX &ptxt, UNUSED const std::vector< long > &array) const override
Unimplemented encode function for BGV. It will always throw helib::LogicError.
Definition: EncryptedArray.h:956
static double roundedSize(double x)
Definition: EncryptedArray.h:888
long getP2R() const override
Definition: EncryptedArray.h:925
void encode(UNUSED zzX &ptxt, UNUSED const std::vector< NTL::ZZX > &array) const override
Definition: EncryptedArray.h:1006
void encode(UNUSED zzX &ptxt, UNUSED const std::vector< zzX > &array) const override
Unimplemented encode function for BGV. It will always throw helib::LogicError.
Definition: EncryptedArray.h:967
double encode(NTL::ZZX &ptxt, const PTXT &pt, double useThisSize=-1, long precision=-1) const
Function for encoding a double into a zzX.
Definition: EncryptedArray.h:1169
virtual void encode(UNUSED EncodedPtxt &eptxt, UNUSED const std::vector< long > &array) const override
Definition: EncryptedArray.h:1188
virtual double defaultErr() const override
Definition: EncryptedArray.h:1315
virtual void encode(EncodedPtxt &eptxt, const std::vector< double > &array, double mag=-1, OptLong prec=OptLong()) const override
Definition: EncryptedArray.h:1200
void decode(std::vector< double > &array, const NTL::ZZX &ptxt, double scaling) const
Definition: EncryptedArray.h:1371
void decrypt(UNUSED const Ctxt &ctxt, UNUSED const SecKey &sKey, UNUSED std::vector< NTL::ZZX > &ptxt) const override
Unimplemented decrypt function for BGV. It will always throw helib::LogicError.
Definition: EncryptedArray.h:1079
double encodeRoundingError() const
Definition: EncryptedArray.h:1287
void encode(UNUSED zzX &ptxt, UNUSED const PlaintextArray &array) const override
Unimplemented encode function for BGV. It will always throw helib::LogicError.
Definition: EncryptedArray.h:978
const PAlgebraModCx getTab() const
Definition: EncryptedArray.h:929
void rawDecrypt(const Ctxt &ctxt, const SecKey &sKey, PlaintextArray &ptxt) const override
Definition: EncryptedArray.h:1424
virtual void encode(UNUSED EncodedPtxt &eptxt, UNUSED const std::vector< NTL::ZZX > &array) const override
Definition: EncryptedArray.h:1182
void decrypt(UNUSED const Ctxt &ctxt, UNUSED const SecKey &sKey, UNUSED std::vector< long > &ptxt) const override
Unimplemented decrypt function for BGV. It will always throw helib::LogicError.
Definition: EncryptedArray.h:1066
void random(std::vector< double > &array, double rad=1.0) const
Definition: EncryptedArray.h:1385
EncryptedArrayDerived(const Context &_context, const PAlgebraModCx &_alMod)
Definition: EncryptedArray.h:903
void buildLinPolyCoeffs(UNUSED std::vector< NTL::ZZX > &C, UNUSED const std::vector< NTL::ZZX > &L) const override
Unimplemented buildLinPolyCoeffs function for BGV. It will always throw helib::LogicError.
Definition: EncryptedArray.h:1093
long encodeScalingFactor(long precision=-1, double roundErr=-1.0) const
Definition: EncryptedArray.h:1299
long getDegree() const override
Definition: EncryptedArray.h:918
void decrypt(const Ctxt &ctxt, const SecKey &sKey, PlaintextArray &ptxt, OptLong prec=OptLong()) const override
Definition: EncryptedArray.h:1416
void decode(UNUSED std::vector< NTL::ZZX > &array, UNUSED const NTL::ZZX &ptxt) const override
Unimplemented decode function for BGV. It will always throw helib::LogicError.
Definition: EncryptedArray.h:1030
virtual void encodeUnitSelector(EncodedPtxt &eptxt, long i) const override
Definition: EncryptedArray.h:1224
double encode(zzX &ptxt, const std::vector< long > &array, double useThisSize, long precision=-1) const
Definition: EncryptedArray.h:1116
void encode(UNUSED zzX &ptxt, UNUSED const std::vector< long > &array) const override
Unimplemented encode function for BGV. It will always throw helib::LogicError.
Definition: EncryptedArray.h:945
void encrypt(Ctxt &ctxt, const PubKey &key, const PTXT &ptxt) const
Definition: EncryptedArray.h:1270
void rotate1D(Ctxt &ctxt, long i, long k, bool dc=false) const override
right-rotate k positions along the i'th dimension
void extractRealPart(Ptxt< Scheme > &p) const
Extract the real part of a CKKS plaintext.
Definition: EncryptedArray.h:1484
const PAlgebra & getPAlgebra() const override
Definition: EncryptedArray.h:917
void decode(UNUSED std::vector< long > &array, UNUSED const NTL::ZZX &ptxt) const override
Unimplemented decode function for BGV. It will always throw helib::LogicError.
Definition: EncryptedArray.h:1019
double encode(zzX &out, const Ptxt< Scheme > &ptxt, double useThisSize, long precision=-1) const
Encode a Ptxt object into a zzX.
Definition: EncryptedArray.h:1136
double encode(zzX &ptxt, const std::vector< double > &array, double useThisSize, long precision=-1) const
Definition: EncryptedArray.h:1107
void random(UNUSED std::vector< NTL::ZZX > &array) const override
Unimplemented random function for BGV. It will always throw helib::LogicError.
Definition: EncryptedArray.h:1053
void random(std::vector< long > &array) const override
Definition: EncryptedArray.h:1391
void encode(UNUSED NTL::ZZX &ptxt, UNUSED const PlaintextArray &array) const override
Unimplemented encode function for BGV. It will always throw helib::LogicError.
Definition: EncryptedArray.h:1000
void encrypt(Ctxt &ctxt, const PubKey &key, const PTXT &ptxt, double useThisSize, long precision=-1) const
Definition: EncryptedArray.h:1253
void dispatch(Args &&... args) const
Definition: EncryptedArray.h:932
void decode(std::vector< double > &array, const zzX &ptxt, double scaling) const
Definition: EncryptedArray.h:1364
void encryptOneNum(Ctxt &ctxt, const PubKey &key, double num, double useThisSize=-1, long precision=-1) const
Definition: EncryptedArray.h:1234
EncryptedArrayDerived(const Context &_context)
Definition: EncryptedArray.h:898
Derived concrete implementation of EncryptedArrayBase.
Definition: EncryptedArray.h:403
void rawDecrypt(UNUSED const Ctxt &ctxt, UNUSED const SecKey &sKey, UNUSED std::vector< double > &ptxt) const override
Definition: EncryptedArray.h:555
virtual void encode(UNUSED EncodedPtxt &eptxt, UNUSED const std::vector< double > &array, UNUSED double mag=-1, UNUSED OptLong prec=OptLong()) const override
Definition: EncryptedArray.h:662
void decrypt(UNUSED const Ctxt &ctxt, UNUSED const SecKey &sKey, UNUSED std::vector< double > &ptxt, UNUSED OptLong prec=OptLong()) const override
Unimplemented decrypt function for CKKS. It will always throw helib::LogicError.
Definition: EncryptedArray.h:522
void dispatch(Args &&... args) const
Definition: EncryptedArray.h:455
void decryptReal(UNUSED const Ctxt &ctxt, UNUSED const SecKey &sKey, UNUSED PlaintextArray &ptxt, UNUSED OptLong prec=OptLong()) const override
Definition: EncryptedArray.h:584
virtual void random(std::vector< long > &array) const override
Definition: EncryptedArray.h:716
virtual long getDegree() const override
Definition: EncryptedArray.h:489
virtual void rotate(Ctxt &ctxt, long k) const override
Right rotation as a linear array. E.g., rotating ctxt=Enc(1 2 3 ... n) by k=1 gives Enc(n 1 2 ....
Definition: EncryptedArray.cpp:181
virtual PA_tag getTag() const override
Definition: EncryptedArray.h:451
void decrypt(const Ctxt &ctxt, const SecKey &sKey, std::vector< RX > &ptxt) const
Definition: EncryptedArray.h:797
virtual void encode(EncodedPtxt &eptxt, const std::vector< NTL::ZZX > &array) const override
Definition: EncryptedArray.h:638
void rawDecrypt(UNUSED const Ctxt &ctxt, UNUSED const SecKey &sKey, UNUSED PlaintextArray &ptxt) const override
Definition: EncryptedArray.h:562
virtual void restoreContextForG() const override
Definition: EncryptedArray.h:479
const NTL::Mat< R > & getNormalBasisMatrixInverse() const
Definition: EncryptedArray.h:469
virtual void encode(zzX &ptxt, const std::vector< zzX > &array) const override
Definition: EncryptedArray.h:617
void decryptComplex(UNUSED const Ctxt &ctxt, UNUSED const SecKey &sKey, UNUSED PlaintextArray &ptxt, UNUSED OptLong prec=OptLong()) const override
Definition: EncryptedArray.h:569
void rotate1D(std::vector< U > &out, const std::vector< U > &in, long i, long offset) const
Definition: EncryptedArray.h:503
virtual void shift(Ctxt &ctxt, long k) const override
Non-cyclic right shift with zero fill E.g., shifting ctxt=Enc(1 2 3 ... n) by k=1 gives Enc(0 1 2....
Definition: EncryptedArray.cpp:288
void rawDecryptComplex(UNUSED const Ctxt &ctxt, UNUSED const SecKey &sKey, UNUSED PlaintextArray &ptxt) const override
Definition: EncryptedArray.h:577
void initNormalBasisMatrix() const
Definition: EncryptedArray.cpp:488
void rawDecryptReal(UNUSED const Ctxt &ctxt, UNUSED const SecKey &sKey, UNUSED PlaintextArray &ptxt) const override
Definition: EncryptedArray.h:592
virtual void decrypt(const Ctxt &ctxt, const SecKey &sKey, std::vector< long > &ptxt) const override
Definition: EncryptedArray.h:727
const NTL::Mat< R > & getNormalBasisMatrix() const
Definition: EncryptedArray.h:462
virtual void decrypt(const Ctxt &ctxt, const SecKey &sKey, std::vector< NTL::ZZX > &ptxt) const override
Definition: EncryptedArray.h:739
virtual void encode(zzX &ptxt, const std::vector< NTL::ZZX > &array) const override
Definition: EncryptedArray.h:628
virtual void encodeUnitSelector(zzX &ptxt, long i) const override
Encodes a std::vector with 1 at position i and 0 everywhere else.
Definition: EncryptedArray.cpp:417
EncryptedArrayDerived(const Context &_context, const RX &_G, const PAlgebraMod &_tab)
Definition: EncryptedArray.cpp:57
virtual void encode(zzX &ptxt, const std::vector< long > &array) const override
Definition: EncryptedArray.h:606
virtual void encode(NTL::ZZX &ptxt, const std::vector< NTL::ZZX > &array) const override
Definition: EncryptedArray.h:611
virtual void restoreContext() const override
Definition: EncryptedArray.h:478
const PAlgebraModDerived< type > & getTab() const
Definition: EncryptedArray.h:490
virtual void decrypt(const Ctxt &ctxt, const SecKey &sKey, PlaintextArray &ptxt, OptLong prec=OptLong()) const override
Definition: EncryptedArray.h:751
virtual void random(std::vector< NTL::ZZX > &array) const override
Definition: EncryptedArray.h:722
virtual void encode(EncodedPtxt &eptxt, const std::vector< long > &array) const override
Definition: EncryptedArray.h:646
virtual void encode(UNUSED EncodedPtxt &eptxt, UNUSED const std::vector< cx_double > &array, UNUSED double mag=-1, UNUSED OptLong prec=OptLong()) const override
Definition: EncryptedArray.h:654
virtual void encodeUnitSelector(EncodedPtxt &eptxt, long i) const override
Definition: EncryptedArray.h:690
virtual void encode(EncodedPtxt &eptxt, const std::vector< bool > &array) const override
Definition: EncryptedArray.h:682
EncryptedArrayDerived(const EncryptedArrayDerived &other)
Definition: EncryptedArray.h:429
virtual void decode(std::vector< NTL::ZZX > &array, const NTL::ZZX &ptxt) const override
Definition: EncryptedArray.h:705
EncryptedArrayDerived & operator=(const EncryptedArrayDerived &)=delete
void decrypt(UNUSED const Ctxt &ctxt, UNUSED const SecKey &sKey, UNUSED std::vector< cx_double > &ptxt, UNUSED OptLong prec=OptLong()) const override
Unimplemented decrypt function for CKKS. It will always throw helib::LogicError.
Definition: EncryptedArray.h:539
virtual void shift1D(Ctxt &ctxt, long i, long k) const override
Right shift k positions along the i'th dimension with zero fill.
Definition: EncryptedArray.cpp:130
virtual void rotate1D(Ctxt &ctxt, long i, long k, bool dc=false) const override
right-rotate k positions along the i'th dimension
Definition: EncryptedArray.cpp:67
virtual void buildLinPolyCoeffs(std::vector< NTL::ZZX > &C, const std::vector< NTL::ZZX > &L) const override
Linearized polynomials. L describes a linear map M by describing its action on the standard power bas...
Definition: EncryptedArray.cpp:746
virtual void encode(EncodedPtxt &eptxt, const PlaintextArray &array, double mag=-1, OptLong prec=OptLong()) const override
Definition: EncryptedArray.h:670
void random(std::vector< RX > &array) const
Definition: EncryptedArray.h:790
virtual EncryptedArrayBase * clone() const override
Definition: EncryptedArray.h:446
virtual const Context & getContext() const override
Definition: EncryptedArray.h:484
virtual const PAlgebra & getPAlgebra() const override
Definition: EncryptedArray.h:485
void rawDecrypt(UNUSED const Ctxt &ctxt, UNUSED const SecKey &sKey, UNUSED std::vector< cx_double > &ptxt) const override
Definition: EncryptedArray.h:548
virtual void decode(std::vector< long > &array, const NTL::ZZX &ptxt) const override
Definition: EncryptedArray.h:699
virtual void encode(NTL::ZZX &ptxt, const std::vector< long > &array) const override
Definition: EncryptedArray.h:600
A simple wrapper for a smart pointer to an EncryptedArrayBase. This is the interface that higher-leve...
Definition: EncryptedArray.h:1583
EncryptedArray(const Context &context, const PAlgebraMod &_alMod)
constructor: G defaults to F0, PAlgebraMod explicitly given
Definition: EncryptedArray.h:1595
void encode(zzX &ptxt, const std::vector< NTL::ZZX > &array) const
Definition: EncryptedArray.h:1710
void encode(NTL::ZZX &ptxt, const PlaintextArray &array) const
Definition: EncryptedArray.h:1705
void encodeUnitSelector(zzX &ptxt, long i) const
Definition: EncryptedArray.h:1763
void encode(EncodedPtxt &eptxt, const PlaintextArray &array, double mag=-1, OptLong prec=OptLong()) const
Definition: EncryptedArray.h:1743
long sizeOfDimension(long i) const
Definition: EncryptedArray.h:1945
void encrypt(Ctxt &ctxt, const PubKey &key, const std::vector< long > &array) const
Definition: EncryptedArray.h:1800
void decryptReal(const Ctxt &ctxt, const SecKey &sKey, PlaintextArray &ptxt, OptLong prec=OptLong()) const
Definition: EncryptedArray.h:1919
void encrypt(Ctxt &ctxt, const std::vector< NTL::ZZX > &array) const
Definition: EncryptedArray.h:1795
void encrypt(Ctxt &ctxt, const PlaintextArray &array, double mag=-1, OptLong prec=OptLong()) const
Definition: EncryptedArray.h:1873
void restoreContextForG() const
Definition: EncryptedArray.h:1941
void rotate1D(std::vector< U > &out, const std::vector< U > &in, long i, long offset) const
rotate an array by offset in the i'th dimension (output should not alias input)
Definition: EncryptedArray.h:1956
EncryptedArray(const Context &context, const NTL::ZZX &G=NTL::ZZX(1, 1))
constructor: G defaults to the monomial X, PAlgebraMod from context
Definition: EncryptedArray.h:1590
void encode(zzX &ptxt, const PlaintextArray &array) const
Definition: EncryptedArray.h:1695
void rawDecryptReal(const Ctxt &ctxt, const SecKey &sKey, PlaintextArray &ptxt) const
Definition: EncryptedArray.h:1927
void encrypt(Ctxt &ctxt, const std::vector< cx_double > &array, UNUSED double mag, OptLong prec=OptLong()) const
Definition: EncryptedArray.h:1828
EncryptedArray & operator=(const EncryptedArray &other)=delete
void decryptComplex(const Ctxt &ctxt, const SecKey &sKey, PlaintextArray &ptxt, OptLong prec=OptLong()) const
Definition: EncryptedArray.h:1904
void encode(zzX &ptxt, const std::vector< long > &array) const
Definition: EncryptedArray.h:1680
void encode(EncodedPtxt &eptxt, const std::vector< bool > &array) const
Definition: EncryptedArray.h:1751
void random(std::vector< T > &array) const
Definition: EncryptedArray.h:1775
void encode(NTL::ZZX &ptxt, const std::vector< long > &array) const
Definition: EncryptedArray.h:1685
long addCoord(long i, long k, long offset) const
Definition: EncryptedArray.h:1948
void encode(EncodedPtxt &eptxt, const std::vector< long > &array) const
Definition: EncryptedArray.h:1722
void encrypt(Ctxt &ctxt, const PubKey &key, const std::vector< cx_double > &array, double mag, OptLong prec=OptLong()) const
Definition: EncryptedArray.h:1815
void decode(ARRAY &array, const PTXT &ptxt) const
Definition: EncryptedArray.h:1769
void buildLinPolyCoeffs(std::vector< NTL::ZZX > &C, const std::vector< NTL::ZZX > &L) const
Definition: EncryptedArray.h:1934
void encode(EncodedPtxt &eptxt, const std::vector< NTL::ZZX > &array) const
Definition: EncryptedArray.h:1717
void decrypt(const Ctxt &ctxt, const SecKey &sKey, T &ptxt) const
Definition: EncryptedArray.h:1884
void encode(EncodedPtxt &eptxt, const std::vector< cx_double > &array, double mag=-1, OptLong prec=OptLong()) const
Definition: EncryptedArray.h:1727
const EncryptedArrayDerived< type > & getDerived(type) const
downcast operator example: const EncryptedArrayDerived<PA_GF2>& rep = ea.getDerived(PA_GF2());
Definition: EncryptedArray.h:1625
void rawDecryptComplex(const Ctxt &ctxt, const SecKey &sKey, PlaintextArray &ptxt) const
Definition: EncryptedArray.h:1912
const PAlgebra & getPAlgebra() const
Definition: EncryptedArray.h:1670
long coordinate(long i, long k) const
Definition: EncryptedArray.h:1947
void encrypt(Ctxt &ctxt, const PubKey &key, const PlaintextArray &array, double mag=-1, OptLong prec=OptLong()) const
Definition: EncryptedArray.h:1858
void encrypt(Ctxt &ctxt, const std::vector< long > &array) const
Definition: EncryptedArray.h:1809
void dispatch(Args &&... args) const
Definition: EncryptedArray.h:1642
void encrypt(Ctxt &ctxt, const std::vector< double > &array, double mag, OptLong prec=OptLong()) const
Definition: EncryptedArray.h:1849
void encrypt(Ctxt &ctxt, const PubKey &key, const std::vector< NTL::ZZX > &array) const
Definition: EncryptedArray.h:1786
void encode(EncodedPtxt &eptxt, const std::vector< double > &array, double mag=-1, OptLong prec=OptLong()) const
Definition: EncryptedArray.h:1735
void shift1D(Ctxt &ctxt, long i, long k) const
Definition: EncryptedArray.h:1678
void rawDecrypt(const Ctxt &ctxt, const SecKey &sKey, T &ptxt) const
Definition: EncryptedArray.h:1899
const PAlgebraMod & getAlMod() const
Definition: EncryptedArray.h:1669
const Context & getContext() const
Definition: EncryptedArray.h:1668
void decrypt(const Ctxt &ctxt, const SecKey &sKey, T &ptxt, OptLong prec) const
Definition: EncryptedArray.h:1890
void rotate1D(Ctxt &ctxt, long i, long k, bool dc=false) const
Definition: EncryptedArray.h:1674
void encode(NTL::ZZX &ptxt, const std::vector< NTL::ZZX > &array) const
Definition: EncryptedArray.h:1700
void encode(zzX &ptxt, const std::vector< zzX > &array) const
Definition: EncryptedArray.h:1690
void encrypt(Ctxt &ctxt, const PubKey &key, const std::vector< double > &array, double mag, OptLong prec=OptLong()) const
Definition: EncryptedArray.h:1836
long nativeDimension(long i) const
Definition: EncryptedArray.h:1946
void encodeUnitSelector(EncodedPtxt &eptxt, long i) const
Definition: EncryptedArray.h:1756
Represents the set of long int's plus a distinguished value that can be used to denote "undefined"....
Definition: NumbTh.h:998
long genToPow(long i, long j) const
the i'th generator to the power j mod m
Definition: PAlgebra.cpp:606
bool SameOrd(long i) const
Is ord(i'th generator) the same as its order in (Z/mZ)^*?
Definition: PAlgebra.h:224
long getNSlots() const
The number of plaintext slots = phi(m)/ord(p)
Definition: PAlgebra.h:188
long numOfGens() const
The prime-power factorization of m.
Definition: PAlgebra.h:203
long OrderOf(long i) const
The order of i'th generator (if any)
Definition: PAlgebra.h:218
long addCoord(long i, long k, long offset) const
adds offset to index k in the i'th dimension
Definition: PAlgebra.h:274
long coordinate(long i, long k) const
Returns coordinate of index k along the i'th dimension.
Definition: PAlgebra.h:258
Definition: PAlgebra.h:770
const PAlgebra & getZMStar() const override
Returns reference to underlying PAlgebra object.
Definition: PAlgebra.h:789
long getR() const override
The value r.
Definition: PAlgebra.h:790
long getPPowR() const override
The value p^r.
Definition: PAlgebra.h:791
virtual void restoreContext() const override
Restores the NTL context for p^r.
Definition: PAlgebra.h:637
virtual const PAlgebra & getZMStar() const override
Returns reference to underlying PAlgebra object.
Definition: PAlgebra.h:622
Definition: EncryptedArray.h:1992
virtual void print(std::ostream &s) const =0
virtual ~PlaintextArrayBase()
Definition: EncryptedArray.h:1994
Definition: EncryptedArray.h:2000
virtual void print(std::ostream &s) const
Definition: EncryptedArray.h:2006
Definition: EncryptedArray.h:2016
PlaintextArray(const PlaintextArray &other)
Definition: EncryptedArray.h:2041
const std::vector< typename type::RX > & getData() const
Definition: EncryptedArray.h:2055
PlaintextArray & operator=(const PlaintextArray &other)
Definition: EncryptedArray.h:2042
std::vector< typename type::RX > & getData()
Definition: EncryptedArray.h:2049
PlaintextArray(const EncryptedArray &ea)
Definition: EncryptedArray.h:2036
Definition: EncryptedArray.h:2167
void encrypt(Ctxt &ctxt, double mag=-1, OptLong prec=OptLong()) const
Definition: EncryptedArray.h:2233
void rawDecrypt(const Ctxt &ctxt, const SecKey &sKey)
Definition: EncryptedArray.h:2253
PtxtArray(const PtxtArray &)=default
void rawDecryptReal(const Ctxt &ctxt, const SecKey &sKey)
Definition: EncryptedArray.h:2277
void store(std::vector< long > &array) const
Definition: EncryptedArray.h:2385
void store(std::vector< NTL::ZZX > &array) const
Definition: EncryptedArray.h:2387
PtxtArray(const EncryptedArray &ea, const T &t)
Definition: EncryptedArray.h:2190
void rawDecryptComplex(const Ctxt &ctxt, const SecKey &sKey)
Definition: EncryptedArray.h:2265
void store(std::vector< double > &array) const
Definition: EncryptedArray.h:2391
void decrypt(const Ctxt &ctxt, const SecKey &sKey, OptLong prec=OptLong())
Definition: EncryptedArray.h:2245
void store(std::vector< cx_double > &array) const
Definition: EncryptedArray.h:2389
void load(const std::vector< cx_double > &array)
Definition: EncryptedArray.h:2305
void load(const std::vector< NTL::ZZX > &array)
Definition: EncryptedArray.h:2300
static constexpr std::string_view typeName
Class label to be added to JSON serialization as object type information.
Definition: EncryptedArray.h:2173
void encode(EncodedPtxt &eptxt, double mag=-1, OptLong prec=OptLong()) const
Definition: EncryptedArray.h:2223
PtxtArray & operator=(const PtxtArray &other)
Definition: EncryptedArray.h:2201
void decryptComplex(const Ctxt &ctxt, const SecKey &sKey, OptLong prec=OptLong())
Definition: EncryptedArray.h:2258
friend std::istream & operator>>(std::istream &is, PtxtArray &pa)
Definition: EncryptedArray.cpp:681
friend std::ostream & operator<<(std::ostream &os, const PtxtArray &pa)
Definition: EncryptedArray.cpp:687
PtxtArray(const Context &context, const T &t)
Definition: EncryptedArray.h:2196
void load(const std::vector< double > &array)
Definition: EncryptedArray.h:2310
static PtxtArray readFromJSON(std::istream &is, const Context &context)
Definition: EncryptedArray.cpp:594
void decryptReal(const Ctxt &ctxt, const SecKey &sKey, OptLong prec=OptLong())
Definition: EncryptedArray.h:2270
An object that mimics the functionality of the Ctxt object, and acts as a convenient entry point for ...
Definition: Ptxt.h:188
const std::vector< SlotType > & getSlotRepr() const
Get the data held in the slots as a std::vector<SlotType>.
Definition: Ptxt.cpp:190
void setData(const std::vector< SlotType > &data)
Set the data.
Definition: Ptxt.cpp:107
long Encrypt(Ctxt &ciphertxt, const NTL::ZZX &plaintxt, long ptxtSpace, bool highNoise) const
Definition: keys.cpp:351
void CKKSencrypt(Ctxt &ciphertxt, const NTL::ZZX &plaintxt, double ptxtSize=1.0, double scaling=0.0) const
Definition: keys.cpp:494
Definition: apiAttributes.h:21
void mul(const EncryptedArray &ea, PlaintextArray &pa, const PlaintextArray &other)
Definition: EncryptedArray.cpp:1612
double NextPow2(double x)
Compute next power of two in floating point NextPow2(x) returns 1 if x < 1, and otherwise returns 2^(...
Definition: NumbTh.cpp:1803
void applyLinPolyLL(Ctxt &ctxt, const std::vector< P > &encodedC, long d)
Definition: EncryptedArray.cpp:855
void sub(const EncryptedArray &ea, PlaintextArray &pa, const PlaintextArray &other)
Definition: EncryptedArray.cpp:1565
void project_and_round(std::vector< long > &out, const std::vector< std::complex< double >> &in)
Definition: NumbTh.h:484
void random(const EncryptedArray &ea, PlaintextArray &pa)
Definition: EncryptedArray.cpp:1256
void add(const EncryptedArray &ea, PlaintextArray &pa, const PlaintextArray &other)
Definition: EncryptedArray.cpp:1537
void totalSums(const EncryptedArray &ea, PlaintextArray &pa)
Definition: EncryptedArray.cpp:1974
void applyLinPoly1(const EncryptedArray &ea, Ctxt &ctxt, const std::vector< NTL::ZZX > &C)
Definition: EncryptedArray.cpp:802
PtxtArray & operator-=(PtxtArray &a, const PtxtArray &b)
Definition: EncryptedArray.h:2453
void Warning(const char *msg)
Function for logging a warning message.
Definition: log.h:114
void negate(Ctxt &ctxt)
negate: free function version of negate method
Definition: Ctxt.h:1551
void conjugate(Ctxt &ctxt)
conjugate: free function that is equivalent to frobeniusAutomorph(ctxt, 1)
Definition: Ctxt.h:1539
void decode(const EncryptedArray &ea, std::vector< long > &array, const PlaintextArray &pa)
Definition: EncryptedArray.cpp:1382
bool operator==(const PtxtArray &a, const PtxtArray &b)
Definition: EncryptedArray.h:2426
bool equals(const EncryptedArray &ea, const PlaintextArray &pa, const PlaintextArray &other)
Definition: EncryptedArray.cpp:1489
EncryptedArrayDerived< PA_cx > EncryptedArrayCx
Definition: EncryptedArray.h:1530
void applyLinPolyMany(const EncryptedArray &ea, Ctxt &ctxt, const std::vector< std::vector< NTL::ZZX >> &Cvec)
Definition: EncryptedArray.cpp:826
double Distance(const EncryptedArray &ea, const PlaintextArray &pa, const PlaintextArray &other)
Definition: EncryptedArray.cpp:1943
void rotate1D(Ctxt &ctxt, long i, long k, bool dc=false)
Definition: EncryptedArray.h:1979
void randomComplex(const EncryptedArray &ea, PlaintextArray &pa)
Definition: EncryptedArray.cpp:1295
void incrementalZeroTest(Ctxt *res[], const EncryptedArray &ea, const Ctxt &ctxt, long n)
Definition: eqtesting.cpp:95
void assertTrue(const T &value, const std::string &message)
Definition: assertions.h:61
void frobeniusAutomorph(Ctxt &ctxt, long j)
frobeniusAutomorph: free function version of frobeniusAutomorph method
Definition: Ctxt.h:1533
std::ostream & operator<<(std::ostream &os, const ContextBuilder< SCHEME > &cb)
ostream operator for serializing the ContextBuilder object.
void encode(const EncryptedArray &ea, PlaintextArray &pa, const std::vector< long > &array)
Definition: EncryptedArray.cpp:1116
EncryptedArrayBase * buildEncryptedArray(const Context &context, const PAlgebraMod &alMod, const NTL::ZZX &G=NTL::ZZX::zero())
A "factory" for building EncryptedArrays.
Definition: EncryptedArray.cpp:26
PtxtArray & operator+=(PtxtArray &a, const PtxtArray &b)
Definition: EncryptedArray.h:2438
void randomReal(const EncryptedArray &ea, PlaintextArray &pa)
Definition: EncryptedArray.cpp:1218
void power(Ctxt &ctxt, long e)
power: free function version of power method
Definition: Ctxt.h:1548
void applyPerm(const EncryptedArray &ea, PlaintextArray &pa, const NTL::Vec< long > &pi)
Definition: EncryptedArray.cpp:1838
long lsize(const std::vector< T > &v)
Size of STL vector as a long (rather than unsigned long)
Definition: NumbTh.h:701
void PolyRed(NTL::ZZX &out, const NTL::ZZX &in, long q, bool abs=false)
Reduce all the coefficients of a polynomial modulo q.
Definition: NumbTh.cpp:772
void assertEq(const T &a, const T &b, const std::string &message)
Definition: assertions.h:108
void plaintextAutomorph(RX &bb, const RX &a, long k, long m, const RXModulus &PhimX)
Definition: EncryptedArray.h:1534
void project(std::vector< double > &out, const std::vector< std::complex< double >> &in)
Definition: NumbTh.h:475
void rem(NTL::zz_pX &r, const NTL::zz_pX &a, const zz_pXModulus1 &ff)
Definition: NumbTh.cpp:1764
PtxtArray & operator*=(PtxtArray &a, const PtxtArray &b)
Definition: EncryptedArray.h:2468
bool operator!=(const PtxtArray &a, const PtxtArray &b)
Definition: EncryptedArray.h:2432
double Norm(const EncryptedArray &ea, const PlaintextArray &pa)
Definition: EncryptedArray.cpp:1936
void runningSums(const EncryptedArray &ea, PlaintextArray &pa)
Definition: EncryptedArray.cpp:1996
Definition: io.h:50
Definition: JsonWrapper.h:9