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
926ed3c7
Commit
926ed3c7
authored
5 years ago
by
Nishant Kumar
Browse files
Options
Downloads
Patches
Plain Diff
Updated ezpc.h for output queue elements.
parent
87212653
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
EzPC/ABY_example/common/ezpc.h
+25
-8
25 additions, 8 deletions
EzPC/ABY_example/common/ezpc.h
EzPC/codegen.ml
+16
-2
16 additions, 2 deletions
EzPC/codegen.ml
with
41 additions
and
10 deletions
EzPC/ABY_example/common/ezpc.h
+
25
−
8
View file @
926ed3c7
...
...
@@ -67,11 +67,15 @@ share* arithmetic_right_shift(Circuit* c, share* val, uint32_t shift_factor) {
* and adds the returned share to this queue
* this queue is then flushed at the end after we have done exec
*/
struct
output_queue_elmt
{
share
*
ptr
;
e_role
role
;
//who should we output the clear value to
ostream
&
os
;
//output stream to which we will output (cout or files), can this be a reference to prevent copying?
e_role
role
;
//who should we output the clear value to
enum
{
PrintMsg
,
PrintValue
}
kind
;
string
msg
;
share
*
ptr
;
};
typedef
vector
<
output_queue_elmt
>
output_queue
;
/*
* called from the EzPC generated code
...
...
@@ -81,9 +85,16 @@ void add_to_output_queue(output_queue &q,
e_role
role
,
ostream
&
os
)
{
struct
output_queue_elmt
elmt
{
ptr
,
role
,
o
s
};
struct
output_queue_elmt
elmt
{
os
,
role
,
o
utput_queue_elmt
::
PrintValue
,
""
,
ptr
};
q
.
push_back
(
elmt
);
}
void
add_print_msg_to_output_queue
(
output_queue
&
q
,
string
msg
,
e_role
role
,
ostream
&
os
)
{
struct
output_queue_elmt
elmt
{
os
,
role
,
output_queue_elmt
::
PrintMsg
,
msg
,
NULL
};
q
.
push_back
(
elmt
);
}
/*
* flush the queue
* both parties call this function with their role
...
...
@@ -92,11 +103,17 @@ void add_to_output_queue(output_queue &q,
void
flush_output_queue
(
output_queue
&
q
,
e_role
role
,
uint32_t
bitlen
)
{
for
(
output_queue
::
iterator
it
=
q
.
begin
();
it
!=
q
.
end
();
++
it
)
{
//iterate over the queue
if
(
it
->
role
==
ALL
||
it
->
role
==
role
)
{
//if the queue element role is same as mine
if
(
bitlen
==
32
)
{
//output to the stream
it
->
os
<<
it
->
ptr
->
get_clear_value
<
uint32_t
>
()
<<
endl
;
}
else
{
it
->
os
<<
it
->
ptr
->
get_clear_value
<
uint64_t
>
()
<<
endl
;
if
(
it
->
kind
==
output_queue_elmt
::
PrintValue
)
{
if
(
it
->
role
==
ALL
||
it
->
role
==
role
)
{
//if the queue element role is same as mine
if
(
bitlen
==
32
)
{
//output to the stream
it
->
os
<<
it
->
ptr
->
get_clear_value
<
uint32_t
>
()
<<
endl
;
}
else
{
it
->
os
<<
it
->
ptr
->
get_clear_value
<
uint64_t
>
()
<<
endl
;
}
}
}
else
{
if
(
it
->
role
==
ALL
||
it
->
role
==
role
)
{
//if the queue element role is same as mine
it
->
os
<<
it
->
msg
<<
endl
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
EzPC/codegen.ml
+
16
−
2
View file @
926ed3c7
...
...
@@ -422,8 +422,22 @@ let rec o_stmt (g:gamma) (s:stmt) :comp * gamma =
|
Output
(
e_role
,
e
,
Some
t
)
when
is_role
e_role
->
let
r
=
get_role
e_role
in
let
bt
,
l
=
get_bt_and_label
t
in
if
not
(
l
|>
get_opt
|>
is_secret_label
)
then
o_codegen_stmt
g
(
Cout
(
"cout"
,
Base_e
e
,
bt
))
if
not
(
l
|>
get_opt
|>
is_secret_label
)
then
let
print_output_msg
=
let
msg
=
Var
{
name
=
"
\"
Value of "
^
(
expr_to_string
e
)
^
":
\"
"
;
index
=
0
}
|>
mk_dsyntax
""
in
Cout
(
"cout"
,
Base_e
msg
,
bt
)
in
o_codegen_stmt
g
(
Seq_codegen
(
print_output_msg
,
Cout
(
"cout"
,
Base_e
e
,
bt
)))
else
let
print_output_msg
=
let
msg
=
Var
{
name
=
"
\"
Value of "
^
(
expr_to_string
e
)
^
":
\"
"
;
index
=
0
}
|>
mk_dsyntax
""
in
App_codegen
(
"add_print_msg_to_output_queue"
,
[
Base_e
(
Var
{
name
=
"out_q"
;
index
=
0
}
|>
mk_dsyntax
""
);
Base_e
msg
;
Base_e
e_role
;
Base_e
(
Var
{
name
=
"cout"
;
index
=
0
}
|>
mk_dsyntax
""
)])
in
let
is_arr
=
is_array_typ
t
in
(* bt is the base type and sl is the secret label *)
...
...
@@ -462,7 +476,7 @@ let rec o_stmt (g:gamma) (s:stmt) :comp * gamma =
Base_e
(
Var
{
name
=
"cout"
;
index
=
0
}
|>
mk_dsyntax
""
)]))
in
o_codegen_stmt
g
output_gate_loops
o_codegen_stmt
g
(
Seq_codegen
(
print_output_msg
,
output_gate_loops
))
|
Skip
s
->
(
if
s
=
""
then
o_null
else
seq
o_newline
(
seq
(
o_comment
s
)
o_newline
))
,
g
...
...
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