Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EzPC-Custom
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rasoul Akhavan Mahdavi
EzPC-Custom
Commits
8882f749
Commit
8882f749
authored
5 years ago
by
Nishant Kumar
Browse files
Options
Downloads
Patches
Plain Diff
Updating Porthos codegen.
parent
0bd6cc20
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
EzPC/codegenporthos.ml
+96
-93
96 additions, 93 deletions
EzPC/codegenporthos.ml
EzPC/config.ml
+1
-1
1 addition, 1 deletion
EzPC/config.ml
EzPC/main.ml
+3
-3
3 additions, 3 deletions
EzPC/main.ml
with
100 additions
and
97 deletions
EzPC/codegen
securenn
.ml
→
EzPC/codegen
porthos
.ml
+
96
−
93
View file @
8882f749
...
...
@@ -474,6 +474,8 @@ let o_global (g0:gamma) (d:global) :comp * gamma =
let
prelude_string
:
string
=
"
\
#include
\"
globals.h
\"\n
\
\n
\
#include<vector>
\n
\
#include<math.h>
\n
\
#include<cstdlib>
\n
\
...
...
@@ -484,52 +486,52 @@ let prelude_string :string =
using namespace std;
\n
\
\n
\
uint32_t public_lrshift(uint32_t x, uint32_t y){
\n
\
return (x >> y);
\n
\
return (x >> y);
\n
\
}
\n
\
\n
\
int32_t public_lrshift(int32_t x, uint32_t y){
\n
\
return ((int32_t)(((uint32_t)x) >> y));
\n
\
return ((int32_t)(((uint32_t)x) >> y));
\n
\
}
\n
\
\n
\
uint64_t public_lrshift(uint64_t x, uint64_t y){
\n
\
return (x >> y);
\n
\
return (x >> y);
\n
\
}
\n
\
\n
\
int64_t public_lrshift(int64_t x, uint64_t y){
\n
\
return ((int64_t)(((uint64_t)x) >> y));
\n
\
return ((int64_t)(((uint64_t)x) >> y));
\n
\
}
\n
\
\n
\
template<typename T>
\n
\
vector<T> make_vector(size_t size) {
\n
\
return std::vector<T>(size);
\n
\
return std::vector<T>(size);
\n
\
}
\n
\
\n
\
template <typename T, typename... Args>
\n
\
auto make_vector(size_t first, Args... sizes)
\n
\
auto make_vector(size_t first, Args... sizes)
\n
\
{
\n
\
auto inner = make_vector<T>(sizes...);
\n
\
return vector<decltype(inner)>(first, inner);
\n
\
auto inner = make_vector<T>(sizes...);
\n
\
return vector<decltype(inner)>(first, inner);
\n
\
}
\n
\
\n
\
template<typename T>
\n
\
ostream& operator<< (ostream &os, const vector<T> &v)
\n
\
{
\n
\
for(auto it = v.begin (); it != v.end (); ++it) {
\n
\
os << *it << endl;
\n
\
}
\n
\
return os;
\n
\
for(auto it = v.begin (); it != v.end (); ++it) {
\n
\
os << *it << endl;
\n
\
}
\n
\
return os;
\n
\
}
\n
\
\n
\
"
let
securenn
_prelude_string
:
string
=
let
porthos
_prelude_string
:
string
=
"
\
#include
\"
ezpc.h
\"\n
\
\n
\
extern int partyNum;
\n
\
vector<uint64_t*> toFreeMemoryLaterArr;
\n
\
int NUM_OF_PARTIES;
\n
\
\n
\
AESObject* aes_common;
\n
\
AESObject* aes_indep;
\n
\
AESObject* aes_a_1;
\n
\
...
...
@@ -554,7 +556,7 @@ ParallelAESObject* aes_parallel;\n\
\n
\
"
let
securenn
_main_decl
:
string
=
let
porthos
_main_decl
:
string
=
"
\n
\
extern int instanceID;
...
...
@@ -562,107 +564,108 @@ int main(int argc, char** argv)\n\
{
\n
\
"
let
securenn
_main_prelude_string
:
string
=
let
porthos
_main_prelude_string
:
string
=
"
\
parseInputs(argc, argv, false);
\n
\
string whichNetwork =
\"
No Network
\"
;
\n
\
\n
\
aes_indep = new AESObject(argv[4]);
\n
\
aes_common = new AESObject(argv[5]);
\n
\
aes_a_1 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_a_2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_b_1 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_b_2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_c_1 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_share_conv_bit_shares_p0_p2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_share_conv_bit_shares_p1_p2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_share_conv_shares_mod_odd_p0_p2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_share_conv_shares_mod_odd_p1_p2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_comp_msb_shares_lsb_p0_p2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_comp_msb_shares_lsb_p1_p2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_comp_msb_shares_bit_vec_p0_p2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_comp_msb_shares_bit_vec_p1_p2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_conv_opti_a_1 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_conv_opti_a_2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_conv_opti_b_1 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_conv_opti_b_2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_conv_opti_c_1 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_parallel = new ParallelAESObject(argv[5]);
\n
\
instanceID = atoi(argv[6]);
\n
\
parseInputs(argc, argv);
\n
\
string whichNetwork =
\"
Your Network
\"
;
\n
\
show_porthos_mode();
\n
\
string indep_key_location, common_key_location;
\n
\
if(partyNum == PARTY_A){
\n
\
indep_key_location =
\"
files/keyA
\"
;
\n
\
common_key_location =
\"
files/keyAB
\"
;
\n
\
}
\n
\
else if(partyNum == PARTY_B){
\n
\
indep_key_location =
\"
files/keyB
\"
;
\n
\
common_key_location =
\"
files/keyAB
\"
;
\n
\
}
\n
\
else{
\n
\
indep_key_location =
\"
files/keyB
\"
;
\n
\
common_key_location =
\"
files/keyAB
\"
;
\n
\
}
\n
\
aes_indep = new AESObject(indep_key_location);
\n
\
aes_common = new AESObject(common_key_location);
\n
\
aes_a_1 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_a_2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_b_1 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_b_2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_c_1 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_share_conv_bit_shares_p0_p2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_share_conv_bit_shares_p1_p2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_share_conv_shares_mod_odd_p0_p2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_share_conv_shares_mod_odd_p1_p2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_comp_msb_shares_lsb_p0_p2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_comp_msb_shares_lsb_p1_p2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_comp_msb_shares_bit_vec_p0_p2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_comp_msb_shares_bit_vec_p1_p2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_conv_opti_a_1 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_conv_opti_a_2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_conv_opti_b_1 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_conv_opti_b_2 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_conv_opti_c_1 = new AESObject(
\"
files/keyD
\"
);
\n
\
aes_parallel = new ParallelAESObject(common_key_location);
\n
\
\n
\
if (
!STANDALONE
)
\n
\
{
\n
\
initializeMPC();
\n
\
initializeCommunication(argv[
3
], partyNum);
\n
\
synchronize(2000000);
\n
\
}
\n
\
if (
MPC
)
\n
\
{
\n
\
initializeMPC();
\n
\
initializeCommunication(argv[
2
], partyNum);
\n
\
synchronize(2000000);
\n
\
}
\n
\
\n
\
if (PARALLEL)
\n
\
aes_parallel->precompute();
\n
\
if (PARALLEL) aes_parallel->precompute();
\n
\
\n
\
e_role role = partyNum;
\n
\
start_m();
\n
\
e_role role = partyNum;
\n
\
"
let
securenn
_postlude_string
:
string
=
let
porthos
_postlude_string
:
string
=
"
\n
\
end_m(whichNetwork);
\n
\
\n
\
cout <<
\"
----------------------------------
\"
<< endl;
\n
\
cout << NUM_OF_PARTIES <<
\"
PC code, P
\"
<< partyNum << endl;
\n
\
cout << NUM_ITERATIONS <<
\"
iterations,
\"
<< whichNetwork <<
\"
, batch size
\"
<< MINI_BATCH_SIZE << endl;
\n
\
cout <<
\"
----------------------------------
\"
<< endl << endl;
\n
\
cout <<
\"
----------------------------------
\"
<< endl;
\n
\
cout << NUM_OF_PARTIES <<
\"
PC code, P
\"
<< partyNum << endl;
\n
\
cout << NUM_ITERATIONS <<
\"
iterations,
\"
<< whichNetwork << endl;
\n
\
cout <<
\"
----------------------------------
\"
<< endl << endl;
\n
\
\n
\
\n
\
/****************************** CLEAN-UP ******************************/
\n
\
delete aes_common;
\n
\
delete aes_indep;
\n
\
delete aes_a_1;
\n
\
delete aes_a_2;
\n
\
delete aes_b_1;
\n
\
delete aes_b_2;
\n
\
delete aes_c_1;
\n
\
delete aes_share_conv_bit_shares_p0_p2;
\n
\
delete aes_share_conv_bit_shares_p1_p2;
\n
\
delete aes_share_conv_shares_mod_odd_p0_p2;
\n
\
delete aes_share_conv_shares_mod_odd_p1_p2;
\n
\
delete aes_comp_msb_shares_lsb_p0_p2;
\n
\
delete aes_comp_msb_shares_lsb_p1_p2;
\n
\
delete aes_comp_msb_shares_bit_vec_p0_p2;
\n
\
delete aes_comp_msb_shares_bit_vec_p1_p2;
\n
\
delete aes_conv_opti_a_1;
\n
\
delete aes_conv_opti_a_2;
\n
\
delete aes_conv_opti_b_1;
\n
\
delete aes_conv_opti_b_2;
\n
\
delete aes_conv_opti_c_1;
\n
\
delete aes_parallel;
\n
\
// delete config;
\n
\
// delete l0;
\n
\
// delete l1;
\n
\
// delete l2;
\n
\
// delete l3;
\n
\
// delete network;
\n
\
if (partyNum != PARTY_S)
\n
\
deleteObjects();
\n
\
delete aes_common;
\n
\
delete aes_indep;
\n
\
delete aes_a_1;
\n
\
delete aes_a_2;
\n
\
delete aes_b_1;
\n
\
delete aes_b_2;
\n
\
delete aes_c_1;
\n
\
delete aes_share_conv_bit_shares_p0_p2;
\n
\
delete aes_share_conv_bit_shares_p1_p2;
\n
\
delete aes_share_conv_shares_mod_odd_p0_p2;
\n
\
delete aes_share_conv_shares_mod_odd_p1_p2;
\n
\
delete aes_comp_msb_shares_lsb_p0_p2;
\n
\
delete aes_comp_msb_shares_lsb_p1_p2;
\n
\
delete aes_comp_msb_shares_bit_vec_p0_p2;
\n
\
delete aes_comp_msb_shares_bit_vec_p1_p2;
\n
\
delete aes_conv_opti_a_1;
\n
\
delete aes_conv_opti_a_2;
\n
\
delete aes_conv_opti_b_1;
\n
\
delete aes_conv_opti_b_2;
\n
\
delete aes_conv_opti_c_1;
\n
\
delete aes_parallel;
\n
\
deleteObjects();
\n
\
\n
\
return 0;
\n
\
return 0;
\n
\
"
let
o_one_program
((
globals
,
main
)
:
global
list
*
codegen_stmt
)
(
ofname
:
string
)
:
unit
=
let
prelude
=
if
Config
.
get_codegen
()
=
Config
.
CPP
then
o_str
prelude_string
else
o_str
(
prelude_string
^
"
\n
"
^
(
securenn
_prelude_string
))
o_str
(
prelude_string
^
"
\n
"
^
(
porthos
_prelude_string
))
in
let
main_header
=
if
Config
.
get_codegen
()
=
Config
.
CPP
then
o_str
"
\n\n
int main () {
\n
"
else
o_str
securenn
_main_decl
else
o_str
porthos
_main_decl
in
let
main_prelude
=
if
Config
.
get_codegen
()
=
Config
.
CPP
then
o_null
else
seq
(
o_str
securenn
_main_prelude_string
)
o_newline
else
seq
(
o_str
porthos
_main_prelude_string
)
o_newline
in
let
main_prelude
,
g
=
...
...
@@ -674,8 +677,8 @@ let o_one_program ((globals, main):global list * codegen_stmt) (ofname:string) :
in
let
main_body
,
g
=
o_codegen_stmt
([]
|>
push_local_scope
g
)
main
in
let
main_end
=
if
Config
.
get_codegen
()
=
Config
.
SECURENN
then
o_str
securenn
_postlude_string
if
Config
.
get_codegen
()
=
Config
.
PORTHOS
then
o_str
porthos
_postlude_string
else
o_null
in
...
...
This diff is collapsed.
Click to expand it.
EzPC/config.ml
+
1
−
1
View file @
8882f749
...
...
@@ -2,7 +2,7 @@ type codegen =
|
ABY
|
CPP
|
OBLIVC
|
SECURENN
|
PORTHOS
type
bool_sharing_mode
=
|
Yao
...
...
This diff is collapsed.
Click to expand it.
EzPC/main.ml
+
3
−
3
View file @
8882f749
...
...
@@ -63,7 +63,7 @@ let tc_and_codegen (p:program) (file:string) :unit =
let
p
=
partition
p
in
print_msg
(
"Split the program into "
^
string_of_int
(
p
|>
snd
|>
List
.
length
)
^
" partition(s), generating .cpp files"
);
if
Config
.
get_codegen
()
=
OBLIVC
then
Codegenoblivc
.
o_program
p
file
else
if
Config
.
get_codegen
()
=
SECURENN
then
Codegen
securenn
.
o_program
p
file
else
if
Config
.
get_codegen
()
=
PORTHOS
then
Codegen
porthos
.
o_program
p
file
else
Codegen
.
o_program
p
file
;
Well_typed
()
)
in
match
x
with
...
...
@@ -90,9 +90,9 @@ let specs = Arg.align [
|
"ABY"
->
ABY
|>
Config
.
set_codegen
|
"CPP"
->
CPP
|>
Config
.
set_codegen
|
"OBLIVC"
->
OBLIVC
|>
Config
.
set_codegen
|
"
SECURENN"
->
SECURENN
|>
Config
.
set_codegen
|
"
PORTHOS"
->
PORTHOS
|>
Config
.
set_codegen
|
_
->
failwith
"Invalid codegen mode"
)
,
" Codegen mode (ABY or CPP or OBLIVC or
SECURENN
, default ABY)"
);
" Codegen mode (ABY or CPP or OBLIVC or
PORTHOS
, default ABY)"
);
(
"--o_prefix"
,
Arg
.
String
(
fun
s
->
o_prefix
:=
s
)
,
" Prefix for output files, default is the input file prefix"
);
(
"--disable-tac"
,
Arg
.
Unit
Config
.
disable_tac
,
" Disable 3-address code transformation (also disables the CSE optimization)"
);
(
"--disable-cse"
,
Arg
.
Unit
Config
.
disable_cse
,
" Disable Common Subexpression Elimination optimization"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment