Welcome to MP-SPDZ’s documentation!¶
This documentation provides a reference to the most important high-level functionality provided by the MP-SPDZ compiler. For a tutorial and documentation on how to run programs, the implemented protocols etc. see https://github.com/data61/MP-SPDZ.
After putting your code in
Program/Source/<progname>.mpc, run the
compiler from the root directory as follows
./compile.py [options] <progname> [args]
<progname> [args] are accessible as list under
The following options influence the computation domain:
Compile for computation modulo a prime and the default integer length. This means that secret integers are assumed to have at most said length unless explicitly told otherwise. The compiled output will communicate the minimum length of the prime number to the virtual machine, which will fail if this is not met. This is the default with an integer length set to 64. When not specifying the prime, the minimum prime length will be around 40 bits longer than the integer length. Furthermore, the computation will be optimistic in the sense that overflows in the secrets might have security implications.
Specify a concrete prime modulus for computation. This can be used together with
-F, in which case integer length has to be at most the prime length minus two. The security implications of overflows in the secrets do not go beyond incorrect results.
Compile for computation modulo 2^(ring size). This will set the assumed length of secret integers to one less because many operations require this. The exact ring size will be communicated to the virtual machine, which will use it automatically if supported.
Compile for binary computation using integer length as default.
For arithmetic computation (
-R) you can set the bit
length during execution using
binary computation you can do so with
sfix.set_precision() to change the range for fixed-point
The following options switch from a single computation domain to mixed computation when using in conjunction with arithmetic computation:
The implementation of both daBits and edaBits are explained in this paper.
<number of parties>¶
=<number of parties>¶
The following options change less fundamental aspects of the computation:
Set the budget for loop unrolling with
for_range_opt()and similar. This means that loops are unrolled up to budget instructions. Default is 100,000 instructions.
Speed up the compilation of repetitive code at the expense of a potentially higher number of communication rounds. For example, the compiler by default will try to compute a division and a logarithm in parallel if possible. Using this option complex operations such as these will be separated and only multiple divisions or logarithms will be computed in parallel. This speeds up the compilation because of reduced complexity.
Compilation vs run time¶
The most important thing to keep in mind is that the Python code is
executed at compile-time. This means that Python data structures such
dict only exist at compile-time
and that all Python loops are unrolled. For run-time loops and lists,
you can use
for_range() (or the more
Array. For convenient multithreading you
automatically distributes the computation on the requested number of
This reference uses the term ‘compile-time’ to indicate Python types
(which are inherently known when compiling). If the term ‘public’ is
used, this means both compile-time values as well as public run-time
types such as
- High-Level Interface
- Virtual Machine
- Low-Level Interface