Skip to content

Commit

Permalink
cpu gate is wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
Wei Dai committed Mar 26, 2018
1 parent 9b0c147 commit 7c3ef4d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
4 changes: 2 additions & 2 deletions cufhe/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ $(DIR_OBJ)/test/test_api_cpu.o: test/test_api_cpu.cc
$(CC) $(FLAGS) $(INC) -M -o $(@:%.o=%.d) $<
$(CC) $(FLAGS) $(INC) -c -o $@ $<

$(DIR_BIN)/test_api_gpu: $(DIR_OBJ)/test/test_api_gpu.o
$(DIR_BIN)/test_api_gpu: $(DIR_OBJ)/test/test_api_gpu.o $(DIR_OBJ)/cufhe_io.o
$(dir_guard)
$(CU) $(FLAGS) -o $@ $(DIR_OBJ)/test/test_api_gpu.o -L$(DIR_BIN) -lcufhe_gpu
$(CU) $(FLAGS) -o $@ $(DIR_OBJ)/test/test_api_gpu.o $(DIR_OBJ)/cufhe_io.o -L$(DIR_BIN) -lcufhe_gpu

$(DIR_OBJ)/test/test_api_gpu.o: test/test_api_gpu.cu
$(dir_guard)
Expand Down
22 changes: 18 additions & 4 deletions cufhe/test/test_api_cpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,24 @@ int main() {
// Same for Ctxt.
PriKey pri_key;
PubKey pub_key;
WritePriKeyToFile(pri_key_old, "data/pri_key.txt");
WritePubKeyToFile(pub_key_old, "data/pub_key.txt");
ReadPriKeyFromFile(pri_key, "data/pri_key.txt");
ReadPubKeyFromFile(pub_key, "data/pub_key.txt");
WritePriKeyToFile(pri_key_old, "pri_key.txt");
WritePubKeyToFile(pub_key_old, "pub_key.txt");
ReadPriKeyFromFile(pri_key, "pri_key.txt");
ReadPubKeyFromFile(pub_key, "pub_key.txt");

for (int i = 0; i <= pub_key_old.bk_->SizeData() / 4; i ++) {
if (pub_key_old.bk_->data()[i] != pub_key.bk_->data()[i]) {
cout<< "Wrong Boot Key" <<endl;
break;
}
}

for (int i = 0; i < pub_key_old.ksk_->SizeData() / 4; i ++) {
if (pub_key_old.ksk_->data()[i] != pub_key.ksk_->data()[i]) {
cout<< "Wrong KeySwitch Key" <<endl;
break;
}
}

cout<< "------ Test Encryption/Decryption ------" <<endl;
cout<< "Number of tests:\t" << kNumTests <<endl;
Expand Down
12 changes: 9 additions & 3 deletions cufhe/test/test_api_gpu.cu
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,24 @@ int main() {

SetSeed(); // set random seed

PriKey pri_key; // private key
PubKey pub_key; // public key
PriKey pri_key_old; // private key
PubKey pub_key_old; // public key
Ptxt* pt = new Ptxt[2 * kNumTests];
Ctxt* ct = new Ctxt[2 * kNumTests];
cudaDeviceSynchronize();
bool correct;

cout<< "------ Key Generation ------" <<endl;
KeyGen(pub_key, pri_key);
KeyGen(pub_key_old, pri_key_old);
// Alternatively ...
// PriKeyGen(pri_key);
// PubKeyGen(pub_key, pri_key);
WritePriKeyToFile(pri_key_old, "pri_key.txt");
WritePubKeyToFile(pub_key_old, "pub_key.txt");
PriKey pri_key; // private key
PubKey pub_key; // public key
ReadPriKeyFromFile(pri_key, "pri_key.txt");
ReadPubKeyFromFile(pub_key, "pub_key.txt");

cout<< "------ Test Encryption/Decryption ------" <<endl;
cout<< "Number of tests:\t" << kNumTests <<endl;
Expand Down

0 comments on commit 7c3ef4d

Please sign in to comment.