diff --git a/src/intraSlot.cpp b/src/intraSlot.cpp index 07632d382..293a1fb41 100644 --- a/src/intraSlot.cpp +++ b/src/intraSlot.cpp @@ -69,10 +69,27 @@ class unpack_pa_impl { static void apply(const EncryptedArrayDerived& ea, const CtPtrs& unpacked, const Ctxt&ctxt,const std::vector& unpackSlotEncoding) { - long d = ea.getDegree(); // size of each slot - - //ctxt.cleanUp(); - + const long d = ea.getDegree(); // size of each slot + const long t = ea.getPAlgebra().getP(); + const long m = ea.getPAlgebra().getM(); + DoubleCRT coeff(unpackSlotEncoding.front(), ctxt.getContext(), ctxt.getPrimeSet()); + Ctxt tmp1(ZeroCtxtLike, ctxt); + for (long i = 0; i < unpacked.size(); i++) { + /// accumulative frobenius: frobenius(v, 2) = frobenius(frobenius(v, 1), 1) + if (i > 0) + coeff.automorph(t % m); + *(unpacked[i]) = ctxt; + unpacked[i]->multByConstant(coeff); + Ctxt origin(*unpacked[i]); + /// TODO use hoisting here + for (long j = 1; j < d; j++) { + tmp1 = origin; + tmp1.frobeniusAutomorph(j); + tmp1.cleanUp(); + *(unpacked[i]) += tmp1; + } + } +#if 0 // Convert the unpack constants to doubleCRT std::vector< std::shared_ptr > coeff_vector(d); for (long i = 0; i < d; i++) { @@ -102,6 +119,7 @@ class unpack_pa_impl { *(unpacked[i]) += tmp1; } } // NOTE: why aren't we using multi-threading here? +#endif } }; //! \endcond