Input/Output¶
This section gives an overview over the input/output facilities.
Private Inputs from Computing Parties¶
All secret types have an input function
(e.g. Compiler.types.sint.get_input_from()
or
Compiler.types.sfix.get_input_from()
). Inputs are read as
whitespace-separated text in order (independent of the data type) from
Player-Data/Input-P<player>-<thread>
, where thread
is 0
for
the main thread. You can change the prefix (Player-Data/Input
)
using the -IF
option on the virtual machine binary. You can also
use -I
to read inputs from the command line.
Compiler.types.sint.input_tensor_from()
and
Compiler.types.sfix.input_tensor_from()
allow inputting a
tensor.
Compile-Time Data via Private Input¶
input_tensor_via()
is a convenience
function that allows to use data available at compile-time via
private input.
Public Inputs¶
All types can be assigned a hard-coded value at compile time, e.g.
sint(1)
. This is impractical for larger amounts of
data. foreach_enumerate()
provides a
facility for this case. It uses
public_input
internally, which reads
from Programs/Public-Input/<progname>
.
Public Outputs¶
By default, print_ln()
and related
functions only output to the terminal on party 0. This allows to run
several parties in one terminal without spoiling the output. You can
use interactive mode with option -I
in order to output on all
parties. Note that this also to reading inputs from the command line
unless you specify -IF
as well. You can also specify a file prefix
with -OF
, so that outputs are written to
<prefix>-P<player>-<thread>
.
Private Outputs to Computing Parties¶
Some types provide a function to reveal a value only to a specific
party (e.g., Compiler.types.sint.reveal_to()
). It can be used
conjunction with print_ln_to()
in order to
output it.
Binary Output¶
Most types returned by reveal()
or reveal_to()
feature a binary_output()
method, which writes to
Player-Data/Binary-Output-P<playerno>-<threadno>
. The format is
either signed 64-bit integer or double-precision floating-point in
machine byte order (usually little endian).
Clients (Non-computing Parties)¶
Compiler.types.sint.receive_from_client()
and
Compiler.types.sint.reveal_to_clients()
allow
communicating securely with the clients. See this example
covering both client code and server-side high-level code.
Compiler.types.sint.input_tensor_from_client()
and
Compiler.types.MultiArray.reveal_to_clients()
. The same
functions are available for sfix
and
Array
, respectively.
See also Reference below.
Reference¶
-
class Client¶
Client-side interface
Public Functions
-
Client(const vector<string> &hostnames, int port_base, int my_client_id)¶
Start a new set of connections to computing parties.
- Parameters
hostnames – location of computing parties
port_base – port base
my_client_id – client identifier
Public Members
-
vector<client_socket*> sockets¶
Sockets for cleartext communication
-
octetStream specification¶
Specification of computation domain
-
Client(const vector<string> &hostnames, int port_base, int my_client_id)¶