Commit 3e37e752 authored by yiwenshao's avatar yiwenshao

able to configure decryption onion and select choosen onions

parent beec50da
...@@ -93,6 +93,8 @@ std::shared_ptr<ReturnMeta> getReturnMeta(std::vector<FieldMeta*> fms, ...@@ -93,6 +93,8 @@ std::shared_ptr<ReturnMeta> getReturnMeta(std::vector<FieldMeta*> fms,
if(index==-1) assert(0); if(index==-1) assert(0);
onion o = tfds[i].getChoosenOnionO()[index]; onion o = tfds[i].getChoosenOnionO()[index];
glog<<"choosenDecryptionOnion: "<<TypeText<onion>::toText(o)<<"\n";
SECLEVEL l = tfds[i].getOriginalFieldMeta()->getOnionMeta(o)->getSecLevel(); SECLEVEL l = tfds[i].getOriginalFieldMeta()->getOnionMeta(o)->getSecLevel();
FieldMeta *k = tfds[i].getOriginalFieldMeta(); FieldMeta *k = tfds[i].getOriginalFieldMeta();
OLK curOLK(o,l,k); OLK curOLK(o,l,k);
...@@ -126,8 +128,10 @@ void initGfb(std::vector<FieldMetaTrans> &res,std::string db,std::string table){ ...@@ -126,8 +128,10 @@ void initGfb(std::vector<FieldMetaTrans> &res,std::string db,std::string table){
/*choosen onions should all be included in gfb. salt is also included /*choosen onions should all be included in gfb. salt is also included
it's hard to decide whether a FieldMetaTrans has salt because the senmantic is different from that of FieldMeta. it's hard to decide whether a FieldMetaTrans has salt because the senmantic is different from that of FieldMeta.
*/ */
for(auto &item:res){ for(auto &item:res){
for(auto i:item.getChoosenOnionName()){
/* for(auto i:item.getChoosenOnionName()){
field_names.push_back(i); field_names.push_back(i);
} }
for(auto i:item.getChoosenFieldTypes()){ for(auto i:item.getChoosenFieldTypes()){
...@@ -136,12 +140,31 @@ void initGfb(std::vector<FieldMetaTrans> &res,std::string db,std::string table){ ...@@ -136,12 +140,31 @@ void initGfb(std::vector<FieldMetaTrans> &res,std::string db,std::string table){
for(auto i:item.getChoosenFieldLengths()){ for(auto i:item.getChoosenFieldLengths()){
field_lengths.push_back(i); field_lengths.push_back(i);
} }
*/
//only choose onions that are used.
for(auto i=0u;i<item.getChoosenOnionName().size();i++){
onion o = item.getChoosenOnionO()[i];
if( ((o==oDET)&&(constGlobalConstants.useDET==true)) ||
((o==oOPE)&&(constGlobalConstants.useOPE==true)) ||
((o==oASHE)&&(constGlobalConstants.useASHE==true)) ||
((o==oAGG)&&(constGlobalConstants.useHOM==true)) ||
((o==oSWP)&&(constGlobalConstants.useSWP==true)) ) {
field_names.push_back(item.getChoosenOnionName()[i]);
field_types.push_back(item.getChoosenFieldTypes()[i]);
field_lengths.push_back(item.getChoosenFieldLengths()[i]);
glog<<"usedField: "<<item.getChoosenOnionName()[i]<<"\n";
}
}
if(item.getHasSalt()){ if(item.getHasSalt()){
field_names.push_back(item.getSaltName()); field_names.push_back(item.getSaltName());
field_types.push_back(item.getSaltType()); field_types.push_back(item.getSaltType());
field_lengths.push_back(item.getSaltLength()); field_lengths.push_back(item.getSaltLength());
glog<<"useSalt: "<<item.getSaltName()<<"\n";
}else{
glog<<"do not use salt"<<"\n";
} }
} }
gfb.field_names = field_names; gfb.field_names = field_names;
gfb.field_types = field_types; gfb.field_types = field_types;
gfb.field_lengths = field_lengths; gfb.field_lengths = field_lengths;
...@@ -369,6 +392,7 @@ main(int argc, char* argv[]){ ...@@ -369,6 +392,7 @@ main(int argc, char* argv[]){
break; break;
} }
} }
glog<<"reencryptionAndInsert: "<< glog<<"reencryptionAndInsert: "<<
std::to_string(t_init.lap()/1000000u)<< std::to_string(t_init.lap()/1000000u)<<
"##"<<std::to_string(time(NULL))<<"\n"; "##"<<std::to_string(time(NULL))<<"\n";
......
...@@ -18,14 +18,44 @@ globalConstants initGlobalConstants(){ ...@@ -18,14 +18,44 @@ globalConstants initGlobalConstants(){
globalConstants res; globalConstants res;
std::string line; std::string line;
while(std::getline(infile,line)){ while(std::getline(infile,line)) {
int index = line.find(":"); int index = line.find(":");
std::string head = line.substr(0,index); std::string head = line.substr(0,index);
if(head=="loadCount"){ if(head=="loadCount") {
res.loadCount = stoi(line.substr(index+1)); res.loadCount = stoi(line.substr(index+1));
}else if(head=="pipelineCount"){ }else if(head=="pipelineCount") {
res.pipelineCount = stoi(line.substr(index+1)); res.pipelineCount = stoi(line.substr(index+1));
}else if(head=="other"){ }else if(head=="useASHE") {
if(line.substr(index+1)=="true" ){
res.useASHE = true;
}else{
res.useASHE = false;
}
}else if(head=="useHOM") {
if(line.substr(index+1)=="true"){
res.useHOM = true;
}else{
res.useHOM = false;
}
}else if(head=="useOPE") {
if(line.substr(index+1)=="true"){
res.useOPE = true;
}else{
res.useOPE = false;
}
}else if(head=="useSWP") {
if(line.substr(index+1)=="true"){
res.useSWP = true;
}else{
res.useSWP = false;
}
}else if(head=="useDET") {
if(line.substr(index+1)=="true"){
res.useDET = true;
}else{
res.useDET = false;
}
}else if(head=="other") {
; ;
}else{ }else{
assert(0); assert(0);
......
...@@ -12,6 +12,11 @@ added by et. all et related things. ...@@ -12,6 +12,11 @@ added by et. all et related things.
struct globalConstants{ struct globalConstants{
int loadCount;/*used to limit the number of final_load*/ int loadCount;/*used to limit the number of final_load*/
int pipelineCount; int pipelineCount;
bool useASHE;
bool useHOM;
bool useOPE;
bool useSWP;
bool useDET;
std::string logFile;/*file name for log*/ std::string logFile;/*file name for log*/
}; };
......
#include "wrapper/reuse.hh" #include "wrapper/reuse.hh"
#include "util/util.hh" #include "util/util.hh"
#include "util/constants.hh"
#include <map> #include <map>
using std::cout; using std::cout;
using std::cin; using std::cin;
...@@ -606,10 +607,17 @@ int getDecryptionOnionIndex(FieldMetaTrans& fdtrans) { ...@@ -606,10 +607,17 @@ int getDecryptionOnionIndex(FieldMetaTrans& fdtrans) {
} }
for(auto item:onion_order){ for(auto item:onion_order){
if(onionIndexPair.find(item)!=onionIndexPair.end()){ if(onionIndexPair.find(item)!=onionIndexPair.end()){
if( ((item==oDET)&&(constGlobalConstants.useDET==true)) ||
((item==oOPE)&&(constGlobalConstants.useOPE==true)) ||
((item==oASHE)&&(constGlobalConstants.useASHE==true)) ||
((item==oAGG)&&(constGlobalConstants.useHOM==true))
){
res = onionIndexPair[item]; res = onionIndexPair[item];
break; break;
} }
} }
}
assert(res!=-1);
return res; return res;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment