mirror of
https://github.com/mii443/FINAL.git
synced 2025-08-22 15:05:36 +00:00
SchemeLWE::not_gate implemented
This commit is contained in:
@ -151,6 +151,14 @@ class SchemeLWE
|
||||
* @param[in] ct_2 encryption of the second input bit
|
||||
*/
|
||||
void xor_gate(Ctxt_LWE& ct_res, const Ctxt_LWE& ct1, const Ctxt_LWE& ct2) const;
|
||||
|
||||
|
||||
/**
|
||||
* Computes the NOT gate of a given ciphertext ct
|
||||
* @param[out] ct_res encryption of the outuput of the NOT gate
|
||||
* @param[in] ct encryption of the input bit
|
||||
*/
|
||||
void not_gate(Ctxt_LWE& ct_res, const Ctxt_LWE& ct) const;
|
||||
};
|
||||
|
||||
|
||||
|
@ -484,4 +484,13 @@ void SchemeLWE::xor_gate(Ctxt_LWE& ct_res, const Ctxt_LWE& ct1, const Ctxt_LWE&
|
||||
bootstrap(ct_res);
|
||||
}
|
||||
|
||||
void SchemeLWE::not_gate(Ctxt_LWE& ct_res, const Ctxt_LWE& ct) const
|
||||
{
|
||||
if (ct_res.a.size() != parLWE.n)
|
||||
ct_res.a = vector<int>(parLWE.n);
|
||||
for (size_t i = 0; i < parLWE.n; i++)
|
||||
ct_res.a[i] = -ct.a[i];
|
||||
ct_res.b = parLWE.delta_base - ct.b;
|
||||
ct_res.b = parLWE.mod_q_base(ct_res.b);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user