
CCS ’22, November 7–11, 2022, Los Angeles, CA, USA. Xiaoyu Fan et al.
Pitfall 3: Generality.
Although we can write many non-linear
functions using the built-ins, some functions are hard to implement.
For example, functions
𝛾(𝑥,𝑧)
,
Γ(𝑥,𝑧)
and
Φ(𝑥)
are dened as
integrals. It is very tedious, if not impossible, to implement them in
MPC using numerical methods and built-in operations.
Pitfall 4: Portability.
Even if we can aord the engineering eort
to build a complete scientic computation library, there are too
many performance trade-os to make it portable to dierent MPC
systems and applications. MPC systems use a variety of protocols
(to support dierent security assumptions), number representations
and sizes, as well as custom programming languages. Also, they are
deployed in dierent hardware/software/network environments.
We want the computation library to maintain eciency in all cases
with minimal porting eorts.
In this paper, we oer a new scheme, non-linear function code
generator (NFGen), to evaluate non-linear functions on general-
purpose MPC platforms. We approximate each non-linear function
using an
𝑚
-piece piecewise polynomial with max order
𝑘
(we auto-
matically determine
𝑘
and
𝑚
). Our approach has three advantages.
First, it only uses secure
+
,
×
and
>
operations supported by all pop-
ular MPC platforms, and we can prove that the security properties
are the same as the underlying platform with the same adversar-
ial models. Second, the evaluation is oblivious, i.e., the operation
sequence is not dependent on input data, allowing for predictable
running time and avoiding timing-related side-channels. Third, ob-
taining the approximation is independent of input data and hence
can be precomputed on plaintext.
Key challenges.
Finding a good
(𝑘,𝑚)
-piecewise polynomial ap-
proximation for MPC platforms is a challenging problem. First,
tting polynomials for FXP computation introduces many chal-
lenges: 1) the polynomial needs to meet both the range and the
resolution requirements of FXP, making sure all intermediate steps
neither overow nor underow; 2) an FXP is essentially an integer,
making the polynomials discrete. Fitting one polynomial minimiz-
ing the approximation error is an NP-complete integer programming
(IP) problem. Thus we need to nd an approximation. Second, there
is a trade-o between
𝑚
and
𝑘
: whether we get more pieces (mainly
leading to more
>
’s) or use a higher-order polynomial (leading to
more
×
’s). The choice depends on the performance of the specic
MPC system, as we discussed above.
Method overview.
We compute the polynomial tting as a pre-
computation step in plaintext. In a nutshell, we rst construct a
polynomial with order
𝑘
in FLP using Chebyshev Interpolation [
42
]
(or Lagrange Interpolation [
34
] for corner case) and then discretized
it into FXP. We check the accuracy of the FXP polynomial using
random data samples. If it does not achieve the user-specied ac-
curacy, we split the input domain into two and recurse on each
smaller domain. We design a series of algorithms leveraging the
FLP capability to help nd a better FXP approximation, like using
two FXPs to expand the range and improving the precision through
residual functions. Section 4 provides the details of the algorithms.
At runtime, we evaluate the (𝑘,𝑚)-piecewise polynomial in an
oblivious way, i.e. the execution only depends on
(𝑘,𝑚)
, but not
input data. We design an oblivious piecewise polynomial evaluation
(OPPE) algorithm (Section 4.3). To get a good
(𝑘,𝑚)
trade-o on dif-
ferent MPC platforms, NFGen uses a proler to collect performance
metrics of a specic deployment of an MPC platform and learns
a model to predict the performance with dierent
(𝑘,𝑚)
.NFGen
automatically makes the choice using the prediction and generates
MPC-platform-specic OPPE code using built-in code templates.
NFGen provides templates for both PrivPy [
29
] and MP-SPDZ [
23
].
The template is the only platform-dependent part in NFGen, and it
only takes a short template to port NFGen to a new MPC platform.
Evaluation results.
We evaluate NFGen against 6 secret sharing
protocols using
15
commonly used non-linear functions on both
PrivPy [
29
] and MP-SPDZ [
23
]. We observe signicant performance
improvements over baselines (direct evaluation) in
93%
of all cases
with an average speedup of
6.5×
and a maximum speedup of
86.1×
.
NFGen saves
39.3%
network communications on average. We also
show that we can avoid the overow errors and achieve much bet-
ter accuracy comparing with the baseline, and allow a larger input
domain even with small FXP widths. Using logistic regression (LR)
as an example, we demonstrate performance and accuracy improve-
ments over direct evaluation and ad hoc approximations, with
3.5×
speedup and
0.6% −14%
accuracy improvements. Additionally,
we illustrate how NFGen helps users to easily implement otherwise
hard-to-implement functions on MPC by using 8 complex functions
dened as integrals and the 𝜒2test on real data.
In summary, our contributions include:
1) We propose a series of algorithms to t an eective piece-
wise polynomial approximation on plaintext, fully considering the
dierences between FLP and FXP representations.
2) We design and implement the code generator with automatic
proling to allow portability to dierent MPC systems with distinct
performance characteristics.
3) We conduct comprehensive evaluations against six MPC pro-
tocols on two platforms over 23 non-linear functions, showing
signicant improvements in performance, accuracy, portability to
dierent MPC platforms, usability and savings in communications.
2 BACKGROUND AND RELATED WORK
In this section, we rst introduce the background of general-purpose
MPC platforms and FXP numbers for readers unfamiliar with this
area and then review related works.
2.1 General-purpose MPC Platforms
General-purpose MPC platforms usually provide a high-level pro-
gramming front-end with a compiler/interpreter to translate a high-
level code into a series of cryptographic building blocks [
21
]. They
provide common operators like
+
,
×
,
>
and
1
𝑥
in the front-end, and
implement these operations using MPC protocols. These platforms
guarantee privacy in the end-to-end algorithms based on the uni-
versal composability of the underlying security protocols. Example
platforms include MP-SPDZ [
23
], PrivPy [
29
], CrypTen [
26
], Se-
cureML [
37
], ABY [
17
], and CryptGPU [
41
] etc. They hugely lower
the barriers of developing privacy-preserving applications.
Most of the general-purpose MPC platforms use secret sharing
(SS) [
17
,
26
,
29
,
37
,
41
] as the underlying protocol. There are a range
of security assumptions (e.g., semi-honest vs. malicious) in these
protocols, resulting in signicantly diering performance. Some
platforms allow users to choose the underlying protocols, like [
23
].
Our goal is to make NFGen protocol-agnostic.