Skip to content

Commit bebd490

Browse files
committed
Added CB params and instantiations
1 parent e56310d commit bebd490

File tree

4 files changed

+73
-1
lines changed

4 files changed

+73
-1
lines changed

include/externs/circuitbootstrapping.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,27 @@ namespace TFHEpp{
99
TFHEPP_EXPLICIT_INSTANTIATION_CIRCUIT_BOOTSTRAPPING(INST)
1010
#undef INST
1111

12+
#define INST(iksP, brP, ahP) \
13+
extern template void AnnihilateCircuitBootstrapping<iksP, brP, ahP>( \
14+
TRGSW<typename brP::targetP> & trgsw, \
15+
const TLWE<typename iksP::domainP> &tlwe, const EvalKey &ek)
16+
TFHEPP_EXPLICIT_INSTANTIATION_ANNIHILATE_CIRCUIT_BOOTSTRAPPING(INST)
17+
#undef INST
18+
1219
#define INST(iksP, bkP, privksP) \
1320
extern template void CircuitBootstrappingFFT<iksP, bkP, privksP>( \
1421
TRGSWFFT<typename privksP::targetP> & trgswfft, \
1522
const TLWE<typename iksP::domainP> &tlwe, const EvalKey &ek)
1623
TFHEPP_EXPLICIT_INSTANTIATION_CIRCUIT_BOOTSTRAPPING(INST)
1724
#undef INST
1825

26+
#define INST(iksP, brP, ahP) \
27+
extern template void AnnihilateCircuitBootstrappingFFT<iksP, brP, ahP>( \
28+
TRGSWFFT<typename brP::targetP> & trgswfft, \
29+
const TLWE<typename iksP::domainP> &tlwe, const EvalKey &ek)
30+
TFHEPP_EXPLICIT_INSTANTIATION_ANNIHILATE_CIRCUIT_BOOTSTRAPPING(INST)
31+
#undef INST
32+
1933
#define INST(iksP, bkP, privksP) \
2034
extern template void CircuitBootstrappingSub<iksP, bkP, privksP>( \
2135
TRGSW<typename privksP::targetP> & trgsw, \

include/params.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,26 @@ struct lvlh2param {
7070
#endif
7171
};
7272

73+
struct cblvl02param {
74+
using domainP = lvl0param;
75+
using targetP = lvl2param;
76+
#ifdef USE_KEY_BUNDLE
77+
static constexpr uint32_t Addends = 2;
78+
#else
79+
static constexpr uint32_t Addends = 1;
80+
#endif
81+
};
82+
83+
struct cblvlh2param {
84+
using domainP = lvlhalfparam;
85+
using targetP = lvl2param;
86+
#ifdef USE_KEY_BUNDLE
87+
static constexpr uint32_t Addends = 2;
88+
#else
89+
static constexpr uint32_t Addends = 1;
90+
#endif
91+
};
92+
7393
template <class P>
7494
using Key = std::array<typename P::T, P::k * P::n>;
7595

@@ -233,6 +253,8 @@ using relinKeyFFT = std::array<TRLWEInFD<P>, P::l>;
233253
#define TFHEPP_EXPLICIT_INSTANTIATION_CIRCUIT_BOOTSTRAPPING(fun) \
234254
fun(lvl10param, lvl02param, lvl21param); \
235255
fun(lvl10param, lvl02param, lvl22param);
256+
#define TFHEPP_EXPLICIT_INSTANTIATION_ANNIHILATE_CIRCUIT_BOOTSTRAPPING(fun) \
257+
fun(lvl10param, lvl02param, AHlvl2param);
236258
#define TFHEPP_EXPLICIT_INSTANTIATION_CIRCUIT_BOOTSTRAPPING_SUBIKS(fun) \
237259
fun(lvl10param, lvl02param, lvl21param);
238260
} // namespace TFHEpp

include/params/128bit.hpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,35 @@ struct lvl2param {
108108
static_cast<double>(1ULL << (std::numeric_limits<T>::digits - 4));
109109
};
110110

111-
struct AHlvl2param {
111+
struct cblvl2param{
112112
using baseP = lvl2param;
113113
static constexpr int32_t key_value_max = baseP::key_value_max;
114114
static constexpr int32_t key_value_min = baseP::key_value_min;
115115
static constexpr std::uint32_t nbit = baseP::nbit;
116116
static constexpr std::uint32_t n = baseP::n; // dimension
117117
static constexpr std::uint32_t k = baseP::k;
118+
static_assert(n*k==baseP::n*baseP::k,"cblvl2param must have same key size as lvl2param");
119+
static constexpr std::uint32_t l = 4;
120+
static constexpr std::uint32_t lₐ = l;
121+
static constexpr std::uint32_t Bgbit = 10;
122+
static constexpr std::uint32_t Bgₐbit = Bgbit;
123+
static constexpr std::uint32_t Bg = 1 << Bgbit;
124+
static constexpr std::uint32_t Bgₐ = 1 << Bgₐbit;
125+
static constexpr ErrorDistribution errordist = baseP::errordist;
126+
static const inline double α = baseP::α; // fresh noise
127+
using T = typename baseP::T; // Torus representation
128+
static constexpr std::make_signed_t<T> μ = baseP::μ;
129+
static constexpr uint32_t plain_modulus = baseP::plain_modulus;
130+
static constexpr double Δ = baseP::Δ;
131+
};
132+
133+
struct AHlvl2param {
134+
using baseP = cblvl2param;
135+
static constexpr int32_t key_value_max = baseP::key_value_max;
136+
static constexpr int32_t key_value_min = baseP::key_value_min;
137+
static constexpr std::uint32_t nbit = baseP::nbit;
138+
static constexpr std::uint32_t n = baseP::n; // dimension
139+
static constexpr std::uint32_t k = baseP::k;
118140
static constexpr std::uint32_t lₐ = 5;
119141
static constexpr std::uint32_t l = 5;
120142
static constexpr std::uint32_t Bgbit = 9;

src/circuitbootstrapping.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,27 @@ namespace TFHEpp {
77
TFHEPP_EXPLICIT_INSTANTIATION_CIRCUIT_BOOTSTRAPPING(INST)
88
#undef INST
99

10+
#define INST(iksP, brP, ahP) \
11+
template void AnnihilateCircuitBootstrapping<iksP, brP, ahP>( \
12+
TRGSW<typename brP::targetP> & trgsw, \
13+
const TLWE<typename iksP::domainP> &tlwe, const EvalKey &ek)
14+
TFHEPP_EXPLICIT_INSTANTIATION_ANNIHILATE_CIRCUIT_BOOTSTRAPPING(INST)
15+
#undef INST
16+
1017
#define INST(iksP, bkP, privksP) \
1118
template void CircuitBootstrappingFFT<iksP, bkP, privksP>( \
1219
TRGSWFFT<typename privksP::targetP> & trgswfft, \
1320
const TLWE<typename iksP::domainP> &tlwe, const EvalKey &ek)
1421
TFHEPP_EXPLICIT_INSTANTIATION_CIRCUIT_BOOTSTRAPPING(INST)
1522
#undef INST
1623

24+
#define INST(iksP, brP, ahP) \
25+
template void AnnihilateCircuitBootstrappingFFT<iksP, brP, ahP>( \
26+
TRGSWFFT<typename brP::targetP> & trgswfft, \
27+
const TLWE<typename iksP::domainP> &tlwe, const EvalKey &ek)
28+
TFHEPP_EXPLICIT_INSTANTIATION_ANNIHILATE_CIRCUIT_BOOTSTRAPPING(INST)
29+
#undef INST
30+
1731
#define INST(iksP, bkP, privksP) \
1832
template void CircuitBootstrappingSub<iksP, bkP, privksP>( \
1933
TRGSW<typename privksP::targetP> & trgsw, \

0 commit comments

Comments
 (0)