| 119 | } |
| 120 | |
| 121 | void Ciphertext::rerandomize(const FHE_PK& pk) |
| 122 | { |
| 123 | Rq_Element tmp(*params); |
| 124 | SeededPRNG G; |
| 125 | vector<FFT_Data::S> r(params->FFTD()[0].phi_m()); |
| 126 | bigint p = pk.p(); |
| 127 | assert(p != 0); |
| 128 | for (auto& x : r) |
| 129 | { |
| 130 | G.get(x, params->p0().numBits() - p.numBits() - 1); |
| 131 | x *= p; |
| 132 | } |
| 133 | tmp.from(r, 0); |
| 134 | Scale(); |
| 135 | cc0 += tmp; |
| 136 | auto zero = pk.encrypt(*params); |
| 137 | zero.Scale(pk.p()); |
| 138 | *this += zero; |
| 139 | } |
| 140 | |
| 141 | |
| 142 | template void mul(Ciphertext& ans,const Plaintext<gfp,FFT_Data,bigint>& a,const Ciphertext& c); |