Skip to content

Commit b178310

Browse files
committed
Merge remote-tracking branch 'public'
2 parents b3d96f5 + d1bef5f commit b178310

15 files changed

+12
-284
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
HElib
22
=====
33

4-
HElib is a software library that implements homomorphic encryption (HE). Currently available is an implementation of the [Brakerski-Gentry-Vaikuntanathan] [1] (BGV) scheme, along with many optimizations to make homomorphic evaluation runs faster, focusing mostly on effective use of the [Smart-Vercauteren] [2] ciphertext packing techniques and the [Gentry-Halevi-Smart] [3] optimizations.
4+
HElib is a software library that implements [homomorphic encryption] [6] (HE). Currently available is an implementation of the [Brakerski-Gentry-Vaikuntanathan] [1] (BGV) scheme, along with many optimizations to make homomorphic evaluation runs faster, focusing mostly on effective use of the [Smart-Vercauteren] [2] ciphertext packing techniques and the [Gentry-Halevi-Smart] [3] optimizations.
55

66
This library is written in C++ and uses the [NTL mathematical library] [4]. It is distributed under the terms of the [GNU General Public License] [5] (GPL).
77

@@ -10,3 +10,4 @@ This library is written in C++ and uses the [NTL mathematical library] [4]. It i
1010
[3]: http://eprint.iacr.org/2012/099 "GHS12"
1111
[4]: http://www.shoup.net/ntl/ "NTL"
1212
[5]: http://www.gnu.org/licenses/gpl.html "GPL"
13+
[6]: http://en.wikipedia.org/wiki/Homomorphic_encryption "Homomorphic encryption"

src/AltCRT.cpp

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ void AltCRT::verify()
2828
assert(map.getIndexSet() <= (context.specialPrimes | context.ctxtPrimes));
2929
}
3030

31-
32-
33-
34-
3531
// Arithmetic operations. Only the "destructive" versions are used,
3632
// i.e., a += b is implemented but not a + b.
3733

@@ -83,10 +79,6 @@ template
8379
AltCRT& AltCRT::Op<AltCRT::SubFun>(const AltCRT &other, SubFun fun,
8480
bool matchIndexSets);
8581

86-
87-
88-
89-
9082
template<class Fun>
9183
AltCRT& AltCRT::Op(const ZZ &num, Fun fun)
9284
{
@@ -115,8 +107,6 @@ AltCRT& AltCRT::Op<AltCRT::AddFun>(const ZZ &num, AddFun fun);
115107
template
116108
AltCRT& AltCRT::Op<AltCRT::SubFun>(const ZZ &num, SubFun fun);
117109

118-
119-
120110
AltCRT& AltCRT::Negate(const AltCRT& other)
121111
{
122112
if (dryRun) return *this;
@@ -139,8 +129,6 @@ AltCRT& AltCRT::Negate(const AltCRT& other)
139129
return *this;
140130
}
141131

142-
143-
144132
// The following is identical to definition in DoubleCRT
145133

146134
template<class Fun>
@@ -154,7 +142,6 @@ AltCRT& AltCRT::Op(const ZZX &poly, Fun fun)
154142
return Op(other, fun);
155143
}
156144

157-
158145
template
159146
AltCRT& AltCRT::Op<AltCRT::MulFun>(const ZZX &poly, MulFun fun);
160147

@@ -164,9 +151,6 @@ AltCRT& AltCRT::Op<AltCRT::AddFun>(const ZZX &poly, AddFun fun);
164151
template
165152
AltCRT& AltCRT::Op<AltCRT::SubFun>(const ZZX &poly, SubFun fun);
166153

167-
168-
169-
170154
// The following is identical to definition in DoubleCRT
171155

172156
// break *this into n digits,according to the primeSets in context.digits
@@ -217,9 +201,6 @@ void AltCRT::breakIntoDigits(vector<AltCRT>& digits, long n) const
217201
FHE_TIMER_STOP;
218202
}
219203

220-
221-
222-
223204
// expand index set by s1.
224205
// it is assumed that s1 is disjoint from the current index set.
225206
void AltCRT::addPrimes(const IndexSet& s1)
@@ -233,7 +214,6 @@ void AltCRT::addPrimes(const IndexSet& s1)
233214
map.insert(s1); // add new rows to the map
234215
if (dryRun) return;
235216

236-
237217
zz_pBak bak; bak.save();
238218

239219
// fill in new rows
@@ -243,11 +223,6 @@ void AltCRT::addPrimes(const IndexSet& s1)
243223
}
244224
}
245225

246-
247-
248-
249-
250-
251226
// Expand index set by s1, and multiply by \prod{q \in s1}. s1 is assumed to
252227
// be disjoint from the current index set. Returns the logarithm of product.
253228
double AltCRT::addPrimesAndScale(const IndexSet& s1)
@@ -264,7 +239,6 @@ double AltCRT::addPrimesAndScale(const IndexSet& s1)
264239
logFactor += log((double)qi);
265240
}
266241

267-
268242
zz_pBak bak; bak.save();
269243

270244
// scale existing rows
@@ -286,10 +260,6 @@ double AltCRT::addPrimesAndScale(const IndexSet& s1)
286260
return logFactor;
287261
}
288262

289-
290-
291-
292-
293263
AltCRT::AltCRT(const ZZX& poly, const FHEcontext &_context, const IndexSet& s)
294264
: context(_context), map(new AltCRTHelper(_context))
295265
{
@@ -306,10 +276,6 @@ AltCRT::AltCRT(const ZZX& poly, const FHEcontext &_context, const IndexSet& s)
306276
}
307277
}
308278

309-
310-
311-
312-
313279
AltCRT::AltCRT(const ZZX& poly, const FHEcontext &_context)
314280
: context(_context), map(new AltCRTHelper(_context))
315281
{
@@ -318,7 +284,6 @@ AltCRT::AltCRT(const ZZX& poly, const FHEcontext &_context)
318284
map.insert(s);
319285
if (dryRun) return;
320286

321-
322287
zz_pBak bak; bak.save();
323288

324289
for (long i = s.first(); i <= s.last(); i = s.next(i)) {
@@ -327,10 +292,6 @@ AltCRT::AltCRT(const ZZX& poly, const FHEcontext &_context)
327292
}
328293
}
329294

330-
331-
332-
333-
334295
AltCRT::AltCRT(const ZZX& poly)
335296
: context(*activeContext), map(new AltCRTHelper(*activeContext))
336297
{
@@ -347,10 +308,6 @@ AltCRT::AltCRT(const ZZX& poly)
347308
}
348309
}
349310

350-
351-
352-
353-
354311
AltCRT::AltCRT(const FHEcontext &_context, const IndexSet& s)
355312
: context(_context), map(new AltCRTHelper(_context))
356313
{
@@ -367,10 +324,6 @@ AltCRT::AltCRT(const FHEcontext &_context, const IndexSet& s)
367324
}
368325
}
369326

370-
371-
372-
373-
374327
AltCRT::AltCRT(const FHEcontext &_context)
375328
: context(_context), map(new AltCRTHelper(_context))
376329
{
@@ -387,9 +340,6 @@ AltCRT::AltCRT(const FHEcontext &_context)
387340
}
388341
}
389342

390-
391-
392-
393343
AltCRT& AltCRT::operator=(const AltCRT& other)
394344
// optimized for the case of matching index sets
395345
{
@@ -413,9 +363,6 @@ AltCRT& AltCRT::operator=(const AltCRT& other)
413363
return *this;
414364
}
415365

416-
417-
418-
419366
AltCRT& AltCRT::operator=(const ZZX&poly)
420367
{
421368
if (dryRun) return *this;
@@ -431,10 +378,6 @@ AltCRT& AltCRT::operator=(const ZZX&poly)
431378
return *this;
432379
}
433380

434-
435-
436-
437-
438381
AltCRT& AltCRT::operator=(const ZZ& num)
439382
{
440383
if (dryRun) return *this;
@@ -451,7 +394,6 @@ AltCRT& AltCRT::operator=(const ZZ& num)
451394
}
452395

453396

454-
455397
// DIRT: I am not sure if this function behaves the same
456398
// as in DoubleCRT if the prime 2 is allowed: the endpoints
457399
// of the interval [-P/2,P/2] may be handled differently.
@@ -474,7 +416,6 @@ void AltCRT::toPoly(ZZX& poly, const IndexSet& s,
474416
ZZ prod;
475417
prod = 1;
476418

477-
478419
zz_pBak bak; bak.save();
479420

480421
for (long i = s1.first(); i <= s1.last(); i = s1.next(i)) {
@@ -492,21 +433,13 @@ void AltCRT::toPoly(ZZX& poly, const IndexSet& s,
492433
}
493434
}
494435

495-
496-
497-
498-
499436
// The following is identical to definition in DoubleCRT
500-
501437
void AltCRT::toPoly(ZZX& p, bool positive) const
502438
{
503439
const IndexSet& s = map.getIndexSet();
504440
toPoly(p, s, positive);
505441
}
506442

507-
508-
509-
510443
// Division by constant
511444
AltCRT& AltCRT::operator/=(const ZZ &num)
512445
{
@@ -524,9 +457,6 @@ AltCRT& AltCRT::operator/=(const ZZ &num)
524457
return *this;
525458
}
526459

527-
528-
529-
530460
// Small-exponent polynomial exponentiation
531461
void AltCRT::Exp(long e)
532462
{
@@ -542,9 +472,6 @@ void AltCRT::Exp(long e)
542472
}
543473
}
544474

545-
546-
547-
548475
// Apply the automorphism F(X) --> F(X^k) (with gcd(k,m)=1)
549476
void AltCRT::automorph(long k)
550477
{
@@ -580,13 +507,6 @@ void AltCRT::automorph(long k)
580507
}
581508
}
582509

583-
584-
585-
586-
587-
588-
589-
590510
// FIXME: there is a potential incompatibilty here
591511
// with DoubleCRT -- starting from the same seed,
592512
// we will get different polynomials. This may lead
@@ -611,36 +531,24 @@ void AltCRT::randomize(const ZZ* seed)
611531
}
612532
}
613533

614-
615-
616-
617534
AltCRT& AltCRT::operator=(const SingleCRT& scrt)
618535
{
619536
assert(0); // not implemented
620537
}
621538

622-
623539
void AltCRT::toSingleCRT(SingleCRT& scrt, const IndexSet& s) const
624540
{
625541
assert(0); // not implemented
626542
}
627543

628-
629-
630544
// The following is identical to definition in DoubleCRT
631-
632545
void AltCRT::toSingleCRT(SingleCRT& scrt) const
633546
{
634547
const IndexSet& s = map.getIndexSet();
635548
toSingleCRT(scrt, s);
636549
}
637550

638-
639-
640-
641551
// The following is identical to definition in DoubleCRT
642-
643-
644552
void AltCRT::scaleDownToSet(const IndexSet& s, long ptxtSpace)
645553
{
646554
assert(ptxtSpace >= 2);
@@ -691,13 +599,6 @@ void AltCRT::scaleDownToSet(const IndexSet& s, long ptxtSpace)
691599
*this /= diffProd; // *this is divisible by diffProd, so this operation actually scales it down
692600
}
693601

694-
695-
696-
697-
698-
699-
700-
701602
ostream& operator<< (ostream &str, const AltCRT &d)
702603
{
703604
assert(0); // not implemented
@@ -708,5 +609,3 @@ istream& operator>> (istream &str, AltCRT &d)
708609
assert(0); // not implemented
709610
}
710611

711-
712-

src/CModulus.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ zz_pContext BuildContext(long p, long maxroot)
6969
{ return zz_pContext(p, maxroot); }
7070

7171

72-
7372
// Constructor: it is assumed that zms is already set with m>1
7473
template <class type> Cmod<type>::
7574
Cmod(const PAlgebra &zms, const zz &qq, const zz &rt)
@@ -171,7 +170,6 @@ void Cmod<type>::FFT(zzv &y, const ZZX& x) const
171170
FHE_TIMER_STOP;
172171
}
173172

174-
175173
template <class type>
176174
void Cmod<type>::iFFT(zpx &x, const zzv& y)const
177175
{
@@ -192,7 +190,6 @@ void Cmod<type>::iFFT(zpx &x, const zzv& y)const
192190

193191
BluesteinFFT(x, m, rt, *ipowers, ipowers_aux, *iRb, iRb_aux, *Ra); // call the FFT routine
194192

195-
196193
// reduce the result mod (Phi_m(X),q) and copy to the output polynomial x
197194
FHE_NTIMER_START("iFFT:division")
198195
rem(x, x, *phimx); // out %= (Phi_m(X),q)
@@ -207,7 +204,7 @@ FHE_NTIMER_STOP("iFFT:division")
207204
FHE_TIMER_STOP;
208205
}
209206

210-
211207
// instantiating the template classes
212208
template class Cmod<CMOD_zz_p>; // small q
213209
template class Cmod<CMOD_ZZ_p>; // large q
210+

0 commit comments

Comments
 (0)