Created ct_not_const to speed up SchemeNTRU::not_gate

This commit is contained in:
hilder.vitor
2022-03-11 12:58:21 +01:00
parent de62bcd412
commit fe261e2a1c
2 changed files with 11 additions and 1 deletions

View File

@ -74,6 +74,7 @@ class SchemeNTRU
Ctxt_NTRU ct_nand_const;
Ctxt_NTRU ct_and_const;
Ctxt_NTRU ct_or_const;
Ctxt_NTRU ct_not_const;
void mask_constant(Ctxt_NTRU& ct, int constant);
@ -98,6 +99,13 @@ class SchemeNTRU
//cout << "Encryption of OR: " << float(clock()-start)/CLOCKS_PER_SEC << endl;
}
inline void set_not_const()
{
encrypt(ct_not_const, 1);
}
public:
SchemeNTRU()
@ -112,6 +120,7 @@ class SchemeNTRU
set_nand_const();
set_and_const();
set_or_const();
set_not_const();
}
/**
* Encrypts a bit using matrix NTRU.

View File

@ -298,6 +298,7 @@ void SchemeNTRU::xor_gate(Ctxt_NTRU& ct_res, const Ctxt_NTRU& ct1, const Ctxt_NT
void SchemeNTRU::not_gate(Ctxt_NTRU& ct_res, const Ctxt_NTRU& ct) const
{
nand_gate(ct_res, ct, ct);
ct_res = ct_not_const;
ct_res -= ct;
}