diff --git a/bin/ckks.o b/bin/ckks.o index 581a997abe79b44212a9fde32de6aa3f4085a637..cc3ed5eeea7736a6881ebc2557bb9970fba809c2 100644 Binary files a/bin/ckks.o and b/bin/ckks.o differ diff --git a/bin/encoder.o b/bin/encoder.o index 204d296b9567fbaaa8580d64efee32a46fcccf15..75116dfb0aecb58a6c557ebcb47452b00703178d 100644 Binary files a/bin/encoder.o and b/bin/encoder.o differ diff --git a/bin/evalkey.o b/bin/evalkey.o index d611734c4173a13cec8287d32567469ca02170d4..ba063c472fcf2ad902fc40176de3074f2137d63f 100644 Binary files a/bin/evalkey.o and b/bin/evalkey.o differ diff --git a/bin/polynomial.o b/bin/polynomial.o index 6de4feeb93bd8e693e882095f2f9081a86dc29ac..067b06b876f3d1a978807b1711a82b941dea529f 100644 Binary files a/bin/polynomial.o and b/bin/polynomial.o differ diff --git a/bin/pubkey.o b/bin/pubkey.o index 5ef768e30378c447d4432460dc79f144d93ac71a..170bbe8a88baf2f039c780acd6bddf007ee85e6b 100644 Binary files a/bin/pubkey.o and b/bin/pubkey.o differ diff --git a/run b/run index f543ad7ed63fc9674d3a174649740b63efdbf26e..5d77c5dfd8013fe1aa2b97ea64d0029271bd1f2b 100755 Binary files a/run and b/run differ diff --git a/src/ckks.h b/src/ckks.h index 21657d47ca15885824d57117d5176cad6c0a3a8e..2c1c269268537479e180700f0dd2709b5ddfe84b 100644 --- a/src/ckks.h +++ b/src/ckks.h @@ -14,7 +14,7 @@ class CKKS { int level = 6; int q0 = 67; int pl[6] = {61, 67, 71, 73, 79, 59}; - int ql; + int64_t ql; PubKey pk; EvalKey evk; SecKey sk; diff --git a/src/encoder.cpp b/src/encoder.cpp index f7a4f961f71c237ac2e296e3e57e22a1db5140ff..9fdae21755b749432c37c9ca57fb2c34e8a0625a 100644 --- a/src/encoder.cpp +++ b/src/encoder.cpp @@ -127,7 +127,7 @@ coeffarr Encoder::coordinateWRR(dcomparr coordinates){ coeffarr roundedCoor; - for (int i=0; i<10; i++){ + for (int i=0; i<M/2; i++){ r = real(coordinates.arr[i]) - floor(real(coordinates.arr[i])); f = randomChoice(r); roundedCoor.arr[i] = round(real(coordinates.arr[i])-f); diff --git a/src/encoder.h b/src/encoder.h index 7daa3a03e8b7de30afa6c49ae8d3eabe6e5ae91c..969e082f3d5e57f393955f44ee577fe54e23fc40 100644 --- a/src/encoder.h +++ b/src/encoder.h @@ -5,18 +5,18 @@ using namespace std; #define J dcomplex(0.0,1.0) -#define SIZE 10 +#define SIZE 100 typedef complex<double> dcomplex; typedef Eigen::Matrix<dcomplex, 4, 4> Matrix4dc; typedef Eigen::Matrix<dcomplex, 4, 1> Matrix1dc; struct dcomparr { - dcomplex arr[100]; + dcomplex arr[SIZE]; }; struct coeffarr { - int arr[10]; + int64_t arr[SIZE]; }; #ifndef ENCODER_H @@ -27,8 +27,8 @@ class Encoder { int M; double scale; dcomplex root; - dcomplex vandermonde[10][10]; - dcomplex sigmaRBasis[10][10]; + dcomplex vandermonde[SIZE][SIZE]; + dcomplex sigmaRBasis[SIZE][SIZE]; Matrix4dc vand; Encoder(int in, double inScale); diff --git a/src/evalkey.cpp b/src/evalkey.cpp index a8288cf2a4d8846e3127c51df88984f65d99ce0c..68bce70e247c52e0c0a8f8da75b0b0f0f8c73808 100644 --- a/src/evalkey.cpp +++ b/src/evalkey.cpp @@ -6,7 +6,7 @@ using namespace std; -EvalKey::EvalKey(Polynomial _s, int degree, int q){ +EvalKey::EvalKey(Polynomial _s, int degree, int64_t q){ a = Polynomial(degree); b = Polynomial(degree); p = 1000; @@ -31,11 +31,11 @@ Polynomial EvalKey::genE(int degree, double var){ return err; } -void EvalKey::generateA(int degree, int q){ - int half_q = (p*q)/2; +void EvalKey::generateA(int degree, int64_t q){ + int64_t half_q = (p*q)/2; random_device rd; mt19937 gen(rd()); - uniform_int_distribution<int> dis(-half_q, half_q); + uniform_int_distribution<int64_t> dis(-half_q, half_q); double a_coeffs[degree]; for (int i=0; i<degree; i++){ diff --git a/src/evalkey.h b/src/evalkey.h index eeb4f8bc2e3892fb80e88f8561944a08af9236c0..30a56592feafa1e6a912a6e4462710fc4396ae9a 100644 --- a/src/evalkey.h +++ b/src/evalkey.h @@ -8,12 +8,12 @@ class EvalKey{ Polynomial a; Polynomial b; Polynomial s; - int p; + int64_t p; EvalKey() = default; - EvalKey(Polynomial _s, int degree, int q); + EvalKey(Polynomial _s, int degree, int64_t q); Polynomial genE(int degree, double var); - void generateA(int degree, int q); + void generateA(int degree, int64_t q); void computeB(int q); }; diff --git a/src/polynomial.cpp b/src/polynomial.cpp index 090b5f1f3101b508847eb4b8d38efa4567692775..bdd44b74743053e3c172d0b3e6c54b273a573e4f 100644 --- a/src/polynomial.cpp +++ b/src/polynomial.cpp @@ -47,10 +47,10 @@ Polynomial Polynomial::scaleRoundCoeff(double scale){ return out; } -Polynomial Polynomial::modCoeff(int q){ +Polynomial Polynomial::modCoeff(int64_t q){ Polynomial out(degree); for (int i=0; i<degree; i++){ - int temp = ((int) coeffs[i])%q; + int64_t temp = ((int64_t) coeffs[i])%q; out.coeffs[i] = (double) temp; } return out; diff --git a/src/polynomial.h b/src/polynomial.h index a9101a20a4d57a5740c1445a2d2abc70c6223c03..04e8de8d713e73e38ee069131d91cbcf4cdfd1ca 100644 --- a/src/polynomial.h +++ b/src/polynomial.h @@ -14,7 +14,7 @@ class Polynomial { void setCoeffs(double coeff[]); Polynomial scaleCoeff(double scale); Polynomial scaleRoundCoeff(double scale); - Polynomial modCoeff(int q); + Polynomial modCoeff(int64_t q); Polynomial dot(Polynomial const &obj); Polynomial operator + (Polynomial const &obj); Polynomial operator * (Polynomial const &obj); diff --git a/src/pubkey.cpp b/src/pubkey.cpp index e52c1314fc0d2b675d64db2f02a5f28efc41ad36..d9deba0a8c5f02aa667810a84f5e262f83d2c6b7 100644 --- a/src/pubkey.cpp +++ b/src/pubkey.cpp @@ -6,7 +6,7 @@ using namespace std; -PubKey::PubKey(Polynomial _s, int degree, int q){ +PubKey::PubKey(Polynomial _s, int degree, int64_t q){ a = Polynomial(degree); b = Polynomial(degree); s = _s; @@ -30,11 +30,11 @@ Polynomial PubKey::genE(int degree, double var){ return err; } -void PubKey::generateA(int degree, int q){ - int half_q = q/2; +void PubKey::generateA(int degree, int64_t q){ + int64_t half_q = q/2; random_device rd; mt19937 gen(rd()); - uniform_int_distribution<int> dis(-half_q, half_q); + uniform_int_distribution<int64_t> dis(-half_q, half_q); double a_coeffs[degree]; for (int i=0; i<degree; i++){ diff --git a/src/pubkey.h b/src/pubkey.h index 1c12e4c76cf4a8a836520d6e2dcf96d81f0abf86..7929abcb3962a60dab07eabc3d3fa67585ab89f3 100644 --- a/src/pubkey.h +++ b/src/pubkey.h @@ -10,9 +10,9 @@ class PubKey{ Polynomial s; PubKey() = default; - PubKey(Polynomial _s, int degree, int q); + PubKey(Polynomial _s, int degree, int64_t q); Polynomial genE(int degree, double var); - void generateA(int degree, int q); + void generateA(int degree, int64_t q); void computeB(int q); }; diff --git a/test.cpp b/test.cpp index 2df90f3d1918ebc88b2aa27a6d1a443121116b93..bab3c670b54c25ccdf1a266938e22f2bf6f41ad3 100644 --- a/test.cpp +++ b/test.cpp @@ -16,9 +16,9 @@ int main(){ int q0 = 67; int pl[6] = {61, 67, 71, 73, 79, 59}; - int ql = q0; + int64_t ql = q0; - for (int i=0; i<5; i++){ + for (int i=0; i<3; i++){ ql *= pl[i]; } diff --git a/test.o b/test.o index 0e498838f94daa08e019afa313471f617252a30f..1fd77b778c7af00a5f6a8ead0a26b90c439a17f1 100644 Binary files a/test.o and b/test.o differ