diff --git a/include/keyswitch.hpp b/include/keyswitch.hpp index 6cf2c35..6d7d239 100644 --- a/include/keyswitch.hpp +++ b/include/keyswitch.hpp @@ -385,4 +385,38 @@ void TLWE2TRLWEChengsPacking(TRLWE
&res, std::vector &res, const std::vector &ahk, const uint l, const uint offset, const uint interval)
+{
+ if(offset >= tlwe.size()) res = {};
+ else if(l==0) InvSampleExtractIndex (res,tlwe[offset],0);
+ else{
+ TRLWE tempeven;
+ PackLWEsLSB (tempeven, tlwe, ahk, l-1, offset, interval*2);
+ TRLWE tempodd;
+ PackLWEsLSB (tempodd, tlwe, ahk, l-1, offset+interval, interval*2);
+ TRLWE tempoddmul;
+ for(int i = 0; i < P::k+1; i++){
+ PolynomialMulByXai (tempoddmul[i], tempodd[i], P::n>>l);
+ for(int j = 0; j < P::n; j++){
+ tempeven[i][j] /= 2;
+ tempoddmul[i][j] /= 2;
+ tempodd[i][j] = tempeven[i][j] - tempoddmul[i][j];
+ // tempodd[i][j] = (tempeven[i][j] - tempoddmul[i][j])/2;
+ }
+ }
+ EvalAuto (res, tempodd, (1< &res, std::vector &ahk)
+{
+ PackLWEsLSB (res, tlwe, ahk, P::nbit, 0, 1);
+}
} // namespace TFHEpp
\ No newline at end of file
diff --git a/test/tlwe2trlwepacking.cpp b/test/tlwe2trlwepacking.cpp
new file mode 100644
index 0000000..c1c94c8
--- /dev/null
+++ b/test/tlwe2trlwepacking.cpp
@@ -0,0 +1,50 @@
+#include