Skip to content

Commit 57a57ed

Browse files
committed
use zzX instead of ZZX in some places
1 parent 022f10b commit 57a57ed

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/EncryptedArray.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void EncryptedArrayDerived<type>::rotate1D(Ctxt& ctxt, long i, long amt, bool dc
7878
long ival= PowerMod(g, amt-ord, m);
7979

8080
const RX& mask = maskTable[i][ord-amt];
81-
DoubleCRT m1(conv<ZZX>(mask), context, ctxt.getPrimeSet());
81+
DoubleCRT m1(convert<zzX,RX>(mask), context, ctxt.getPrimeSet());
8282
Ctxt tmp(ctxt); // a copy of the ciphertext
8383

8484
tmp.multByConstant(m1); // only the slots in which m1=1
@@ -106,7 +106,7 @@ void EncryptedArrayDerived<type>::shift1D(Ctxt& ctxt, long i, long k) const
106106
long ord = al.OrderOf(i);
107107

108108
if (k <= -ord || k >= ord) {
109-
ctxt.multByConstant(to_ZZX(0));
109+
ctxt.multByConstant(to_ZZ(0));
110110
return;
111111
}
112112

@@ -124,7 +124,7 @@ void EncryptedArrayDerived<type>::shift1D(Ctxt& ctxt, long i, long k) const
124124
mask = 1 - mask;
125125
val = PowerMod(al.ZmStarGen(i), amt, al.getM());
126126
}
127-
DoubleCRT m1(conv<ZZX>(mask), context, ctxt.getPrimeSet());
127+
DoubleCRT m1(convert<zzX,RX>(mask), context, ctxt.getPrimeSet());
128128
ctxt.multByConstant(m1); // zero out slots where mask=0
129129
ctxt.smartAutomorph(val); // shift left by val
130130
FHE_TIMER_STOP;
@@ -178,7 +178,8 @@ void EncryptedArrayDerived<type>::rotate(Ctxt& ctxt, long amt) const
178178
long val = PowerMod(al.ZmStarGen(i), v, al.getM());
179179
long ival = PowerMod(al.ZmStarGen(i), v-ord, al.getM());
180180

181-
DoubleCRT m1(conv<ZZX>(maskTable[i][ord-v]), context, ctxt.getPrimeSet());
181+
DoubleCRT m1(convert<zzX,RX>(maskTable[i][ord-v]),
182+
context, ctxt.getPrimeSet());
182183
tmp = ctxt; // a copy of the ciphertext
183184

184185
tmp.multByConstant(m1); // only the slots in which m1=1
@@ -203,7 +204,7 @@ void EncryptedArrayDerived<type>::rotate(Ctxt& ctxt, long amt) const
203204
for (i--; i >= 0; i--) {
204205
v = al.coordinate(i, amt);
205206

206-
DoubleCRT m1(conv<ZZX>(mask), context, ctxt.getPrimeSet());
207+
DoubleCRT m1(convert<zzX,RX>(mask), context, ctxt.getPrimeSet());
207208
tmp = ctxt;
208209
tmp.multByConstant(m1); // only the slots in which mask=1
209210
ctxt -= tmp; // only the slots in which mask=0
@@ -243,7 +244,7 @@ void EncryptedArrayDerived<type>::shift(Ctxt& ctxt, long k) const
243244

244245
// Shifting by more than the number of slots gives an all-zero cipehrtext
245246
if (k <= -nSlots || k >= nSlots) {
246-
ctxt.multByConstant(to_ZZX(0));
247+
ctxt.multByConstant(to_ZZ(0));
247248
return;
248249
}
249250

@@ -263,7 +264,7 @@ void EncryptedArrayDerived<type>::shift(Ctxt& ctxt, long k) const
263264
for (i--; i >= 0; i--) {
264265
v = al.coordinate(i, amt);
265266

266-
DoubleCRT m1(conv<ZZX>(mask), context, ctxt.getPrimeSet());
267+
DoubleCRT m1(convert<zzX,RX>(mask), context, ctxt.getPrimeSet());
267268
tmp = ctxt;
268269
tmp.multByConstant(m1); // only the slots in which mask=1
269270
ctxt -= tmp; // only the slots in which mask=0
@@ -604,6 +605,7 @@ void applyLinPolyLL(Ctxt& ctxt, const vector<P>& encodedC, long d)
604605
ctxt += tmp1;
605606
}
606607
}
608+
template void applyLinPolyLL(Ctxt& ctxt, const vector<zzX>& encodedC, long d);
607609
template void applyLinPolyLL(Ctxt& ctxt, const vector<ZZX>& encodedC, long d);
608610
template void applyLinPolyLL(Ctxt& ctxt, const vector<DoubleCRT>& encodedC, long d);
609611

@@ -668,17 +670,17 @@ class encode_pa_impl {
668670
public:
669671
PA_INJECT(type)
670672

671-
static void apply(const EncryptedArrayDerived<type>& ea, NewPlaintextArray& pa,
672-
const vector<long>& array)
673+
static void apply(const EncryptedArrayDerived<type>& ea,
674+
NewPlaintextArray& pa, const vector<long>& array)
673675
{
674676
PA_BOILER
675677

676678
assert(lsize(array) == n);
677679
convert(data, array);
678680
}
679681

680-
static void apply(const EncryptedArrayDerived<type>& ea, NewPlaintextArray& pa,
681-
const vector<ZZX>& array)
682+
static void apply(const EncryptedArrayDerived<type>& ea,
683+
NewPlaintextArray& pa, const vector<ZZX>& array)
682684
{
683685
PA_BOILER
684686

0 commit comments

Comments
 (0)