MCPcopy Create free account
hub / github.com/data61/MP-SPDZ / mul

Function mul

FHE/Ciphertext.cpp:60–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58
59
60void mul(Ciphertext& ans,const Ciphertext& c0,const Ciphertext& c1,
61 const FHE_PK& pk)
62{
63 CODE_LOCATION_NO_SCOPE
64
65 if (c0.params!=c1.params) { throw params_mismatch(); }
66 if (ans.params!=c1.params) { throw params_mismatch(); }
67
68 // Switch Modulus for c0 and c1 down to level 0
69 Ciphertext cc0=c0,cc1=c1;
70 cc0.Scale(pk.p()); cc1.Scale(pk.p());
71
72 // Now do the multiply
73 auto d0 = cc0.cc0 * cc1.cc0;
74 auto d1 = cc0.cc0 * cc1.cc1 + cc0.cc1 * cc1.cc0;
75 auto d2 = cc0.cc1 * cc1.cc1;
76 d2.negate();
77
78 // Now do the switch key
79 d2.raise_level();
80 d0.mul_by_p1();
81 auto t = pk.bs()* d2;
82 add(d0,d0,t);
83
84 d1.mul_by_p1();
85 mul(t,pk.as(),d2);
86 add(d1,d1,t);
87
88 ans.set(d0, d1, check_pk_id(c0.pk_id, c1.pk_id));
89 ans.Scale(pk.p());
90}
91
92
93template<class T,class FD,class S>

Callers 1

mulMethod · 0.70

Calls 15

params_mismatchClass · 0.85
check_pk_idFunction · 0.85
raise_levelMethod · 0.80
mul_by_p1Method · 0.80
to_polyMethod · 0.80
lower_levelMethod · 0.80
addFunction · 0.70
ScaleMethod · 0.45
pMethod · 0.45
negateMethod · 0.45
setMethod · 0.45
levelMethod · 0.45

Tested by

no test coverage detected