---
title: "CrypTFlow2: Practical 2-Party Secure Inference (2020)"
description: "CrypTFlow2 makes private neural network inference practical through efficient secure comparisons, exact division, and flexible cryptographic…"
canonical: "https://research.elamur.ai/free/en/papers/rathee-2020-cryptflow2-practical-2-party-secure/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/rathee-2020-cryptflow2-practical-2-party-secure/)

[home](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2020](https://md.research.elamur.ai/free/en/papers/2020/) / CrypTFlow2: Practical 2-Party Secure Inference

# CrypTFlow2: Practical 2-Party Secure Inference

Paper · 2020 · Deevashwer Rathee, Mayank Rathee, Nishant Kumar et al.

**Authors:** Deevashwer Rathee, Mayank Rathee, Nishant Kumar, Nishanth Chandran, Divya Gupta, Aseem Rastogi and [Rahul R. Sharma](https://md.research.elamur.ai/free/en/authors/rahul-sharma/) · **Year:** 2020 · **Venue:** ACM SIGSAC Conference on Computer and Communications Security (CCS) · **Licence:** [arXiv — non-exclusive license to distribute](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

[**326** citations OpenAlex, 2026-10-14](https://openalex.org/works?filter=cites:W3093021001) · ACM SIGSAC Conference on Computer and Communications Security (CCS) · [licence](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

- [DOI 10.1145/3372297.3417274](https://doi.org/10.1145/3372297.3417274)
- [arXiv 2010.06457](https://arxiv.org/abs/2010.06457)
- [OpenAlex](https://openalex.org/W3093021001)

## Deep dive: CrypTFlow2: Practical 2-Party Secure Inference

CrypTFlow2 makes private neural network inference practical through efficient secure comparisons, exact division, and flexible cryptographic backends. · about 34 minutes to read

**In this deep dive**

1. [Summary](#dd-summary)
2. [Ideas worth borrowing](#dd-ideas-worth-borrowing)
3. [How Mova uses it](#dd-how-mova-uses-it)
4. [The problem and its context](#dd-the-problem-and-its-context)
5. [The method, step by step](#dd-the-method-step-by-step)
6. [Experiments and results](#dd-experiments-and-results)
7. [What the ablations show](#dd-what-the-ablations-show)
8. [Limitations](#dd-limitations)
9. [What came after](#dd-what-came-after)

### Summary

A prediction service can create a difficult privacy bargain. The person requesting a prediction may need to disclose sensitive data, while the service owner may want to keep its trained weights confidential. CrypTFlow2 studies how to compute the prediction without exposing either party’s private input to the other. Its setting has a client with an input and a server with trained network weights. The client receives the prediction; the computation should reveal no additional information about the client’s data or the server’s weights beyond the information permitted by that result.

The paper addresses this problem through secure two-party computation: cryptographic protocols that let the parties calculate together without exchanging their private values in readable form. Its central contribution is a set of efficient protocols for operations that make secure neural inference expensive. These include comparisons, the sign tests needed for ReLU activations, and integer division. The division work matters for correctness as well as speed. Fixed-point arithmetic represents fractional values with scaled integers, and multiplication requires a subsequent reduction in scale. CrypTFlow2 performs that reduction faithfully, so secure execution produces the same bits as the corresponding cleartext fixed-point computation.

These building blocks support alternative implementations of the expensive linear layers. One backend uses oblivious transfer, a primitive for privately selecting information. The other uses homomorphic encryption, which permits certain calculations on encrypted values. The authors integrate both into the CrypTFlow compilation framework, allowing TensorFlow inference programs to be translated into secure protocols. This is a system for executing existing trained networks privately, rather than a new procedure for learning their weights.

The evaluation reaches ImageNet-scale image classification with SqueezeNet, ResNet50, and DenseNet121. SqueezeNet can run securely in under a minute, while the larger networks establish that the approach extends beyond the smaller benchmarks used in earlier two-party systems. On the CIFAR tasks used to compare against Delphi, the new protocols evaluate nonlinear components with a reported speed advantage of 20×–30×. The choice between the cryptographic backends depends on communication conditions and numerical precision: homomorphic encryption wins in the tested wide-area setting, while the local-area results depend on the network being evaluated.

The guarantees have clear boundaries. The security analysis assumes that a participant may inspect what it receives but still follows the protocol. It does not cover a participant who deliberately sends incorrect messages. The numerical guarantee concerns equivalence to fixed-point execution, whose precision must itself be chosen appropriately. CrypTFlow2 also does not completely conceal the network architecture. Its achievement is to make substantially larger private inference computations feasible while preserving a precise arithmetic specification and an explicit two-party security assumption.

### Ideas worth borrowing

Make arithmetic correctness part of the specification. CrypTFlow2 treats the rounding behavior of division as an essential property of the computation. An implementation can preserve most predictions and still fail to implement the function it claims to compute. This distinction is useful anywhere software translates arithmetic between representations or execution environments. A compiler, numerical library, or privacy system benefits from stating which reference execution it must reproduce before deciding which shortcuts are acceptable.

Replace a general mechanism with a carefully chosen primitive. Earlier systems commonly used garbled circuits to evaluate nonlinear operations. The paper instead builds efficient comparison and sign protocols, then uses them throughout the inference pipeline. The reusable lesson is to identify the small operation that repeatedly dominates a larger workload. Improving that operation can help several components at once, especially when those components share a mathematical structure.

Separate local work from joint correction. Dividing each secret share independently does not generally produce shares of the desired quotient. The authors derive correction terms that make the result exact, leaving much of the arithmetic to be performed locally. This is a useful way to approach distributed computation: first determine what each participant can calculate alone, then characterize precisely what interaction must repair. The same reasoning applies when a representation introduces carries, wraparound, or rounding.

Exploit correlations between nearby computations. The comparison protocol needs related inequalities and equality tests. Rather than treating them as unrelated cryptographic tasks, the authors combine transfers with the same selection input and generate correlated randomness for operations with a shared operand. This suggests a broader optimization strategy for compilers and protocol libraries: inspect neighboring operations for information they can safely reuse. The opportunity may lie in their inputs and dependencies rather than in their surface operation names.

Optimize for elapsed time, not a single resource count. A comparison configuration that minimizes transmitted bits is not the fastest configuration in the experiments. Larger lookup tables save communication but increase local cryptographic work. The authors therefore choose a different block size for execution than for their best communication figures. This is useful whenever an implementation balances computation, bandwidth, and synchronization. A theoretical minimum in one dimension should become a candidate for measurement, rather than an automatic deployment choice.

Use proven value properties to simplify later operations. After ReLU, the output is non-negative. CrypTFlow2’s compiler can move truncation past that activation and omit a sign calculation that would otherwise be necessary. The transformation also adjusts other operands when intervening additions require matching scales. The general idea is to connect semantic knowledge about values to implementation costs. A useful compiler fact is one that enables a cheaper operation without changing the intended result.

Keep alternative backends behind a common interface. Both CrypTFlow2 backends consume and produce arithmetic shares at layer boundaries. This lets the system compare different cryptographic strategies while retaining the same overall inference structure. The approach is useful when deployment conditions vary: bandwidth, latency, and arithmetic width can change which implementation is fastest. A stable boundary makes those choices manageable without forcing the whole application to be rewritten.

### How Mova uses it

For Mova, a small transparent language system written in Rust, the strongest connection is a possible approach to private computation and explicit numerical semantics. CrypTFlow2 does not establish a Mova integration, and there is no basis for claiming that its protocols are already implemented there. Its relevance is therefore architectural: it offers concrete mechanisms and design principles that Mova could adopt if private execution becomes a requirement.

A possible application would separate a user’s private input from service-side private parameters. The paper’s arrangement gives a precise starting point for such a feature: define what the client contributes, what the server contributes, and what the client is allowed to learn from the output. That specification would need to precede implementation. Simply encrypting a request while it travels would not reproduce the computation described in CrypTFlow2, because the paper keeps intermediate values protected throughout the joint calculation.

The arithmetic contribution is useful even before considering a complete private service. Mova could define a reference integer or fixed-point execution and require any secure backend to match it exactly. CrypTFlow2 shows why this matters: a seemingly small discrepancy in scaling or division can recur across a long computation. A transparent implementation should make the rounding rule, signed representation, and overflow assumptions inspectable. The paper supplies a worked example of making those details part of the formal computation.

Its layer interface also suggests a practical boundary for an experimental Rust implementation. An operation could accept protected shares and return protected shares in a specified ring, while the implementation behind that interface handles comparison, selection, or division. This would make the secure component’s obligations explicit. It would also allow ordinary execution to serve as a reference for checking numerical behavior. These are possible design choices, rather than evidence about Mova’s current internal structure.

The compiler optimization offers another transferable idea. If Mova can establish a property of an intermediate value, it could use that property to simplify a later operation. CrypTFlow2’s example is nonnegativity after ReLU, which removes work from truncation. Applying the same principle elsewhere would require a proof tied to the actual operation and representation. The useful inheritance is the discipline of tracking value properties and preserving semantics through optimization.

There are also reasons to keep the connection narrow. CrypTFlow2 evaluates image-classification networks, and its efficient components are developed around their arithmetic. It does not demonstrate private language processing or provide measurements for Mova’s workload. Before adopting its backend design, Mova would need to identify whether its expensive operations fit the paper’s supported primitives. The paper is a concrete foundation for exploring private numerical execution, but it does not establish that a language system can inherit its performance results unchanged.

### The problem and its context

#### Privacy requires protecting both sides of a prediction

The paper’s starting point is a service in which the server owns trained weights and the client owns an input. The broad network structure is publicly known. In ordinary inference, the server could receive the input, evaluate the network, and return a prediction. That arrangement exposes the input to the service. Moving all computation to the client could create the opposite problem by requiring disclosure of the server’s private weights.

Secure inference asks for a different arrangement. The client should obtain the result while the input remains hidden from the server. The client should also learn no additional information about the weights beyond what follows from its own input and the prediction. The paper treats this as an application of [machine learning](https://md.research.elamur.ai/free/en/concepts/machine-learning/) in which the execution method must preserve both parties’ confidentiality.

The authors motivate this capability through prediction services, including medical applications discussed in earlier research. Their examples include private diagnosis involving chest conditions, diabetic retinopathy, and malaria. These examples explain why input confidentiality might matter, but they are not the empirical focus of CrypTFlow2. The main evaluation studies the feasibility and performance of secure image-classification inference.

The privacy objective also explains why intermediate results matter. If a system protects the original request but reveals activations during evaluation, it has exposed information outside the intended output. CrypTFlow2 therefore maintains protected representations across layers. Neither party is supposed to reconstruct the intermediate values merely to make a difficult operation convenient.

#### General secure computation was already possible

The paper does not claim to make joint private computation possible for the first time. General protocols for secure two-party computation were already known. The obstacle is their cost when applied to the operations and scale of practical neural inference.

Earlier systems combined different cryptographic techniques. SecureML and MiniONN used oblivious-transfer approaches for linear computation, while Gazelle and Delphi used homomorphic encryption. For nonlinear activations, garbled circuits were a common component. A garbled circuit represents the desired function through protected logical operations, allowing the parties to evaluate it without learning the private values carried through it.

That generality is useful, but it can be expensive. An image-classification network may contain many activations, each requiring a sign decision and a selection. When those decisions are repeated over large layers, their communication becomes a substantial part of total execution time. Improving matrix multiplication alone does not remove this cost.

The authors also discuss changing the network so that secure evaluation becomes easier. ReLU can be replaced with functions that are more convenient for a particular cryptographic technique. According to the paper, such substitutions can reduce classification accuracy. CrypTFlow2 pursues a different engineering objective: retain the required activation behavior and improve the protocol used to calculate it.

Other approaches introduce a helper whose participation is assumed not to collude with the other parties. The paper places several efficient prior systems in this category. Such a helper changes the trust arrangement. CrypTFlow2’s target is a computation between the client and server themselves, without relying on that additional non-collusion assumption.

#### ReLU exposes the cost of a simple decision

In cleartext software, ReLU has a short definition: keep a non-negative value and replace a negative value with zero. Under secret sharing, neither participant knows the underlying value. They cannot simply inspect its sign locally.

The challenge is particularly clear when a secret is represented as a modular sum of shares. A share’s apparent sign says little about the reconstructed secret. The shares were chosen to hide the value, so interpreting them independently as ordinary signed numbers does not reveal the desired sign test.

A secure ReLU consequently needs a protocol for determining the sign without disclosing it. That sign then controls a protected choice between the input and zero. Maximum pooling and finding the index of a maximum require related decisions. The paper’s comparison work addresses this common core.

The same observation explains why an apparently minor primitive can influence whole-network performance. The expensive task is not the local mathematical definition of ReLU. It is obtaining the required decision while preserving secrecy, then repeating that procedure over the activation arrays generated by the network.

#### Fixed-point arithmetic creates a second problem

Cryptographic protocols operate naturally on integers in finite arithmetic domains. Neural inference, in contrast, starts from values expressed with fractional precision. CrypTFlow2 uses fixed-point encoding: multiply by a power of two, round down, and store the result as an integer.

Multiplication changes the scale. If both inputs already include a scaling factor, their product carries the factor again. The implementation must divide afterwards to restore the chosen representation. Average pooling also needs division, because it forms a mean instead of a sum.

Some earlier systems used local truncation as an approximation. Each party adjusted its own share without performing all the joint work required for an exact quotient. The authors explain that this can create occasional large errors and smaller errors in the least significant position. Repeated operations can accumulate these discrepancies.

This is a correctness issue distinct from prediction accuracy. A secure program may frequently return the same classification as a cleartext program while still calculating different intermediate values. CrypTFlow2 insists on a stronger property: the secure execution must implement the specified fixed-point program exactly.

That choice is especially relevant to scale. A numerical shortcut that seems acceptable in a small computation may be invoked repeatedly in a larger network. The authors’ division theorem supplies a way to repair the arithmetic instead of relying on the hope that individual errors remain inconsequential.

#### Why ImageNet changes the test

The paper contrasts earlier secure-inference evaluations on smaller classification tasks with ImageNet-scale computation. MNIST involves handwritten digit images of size 28×28, while the ImageNet setting described by the authors usually uses color images of size 224×224 and a thousand possible classes.

The significance is not merely that the input image is larger. The evaluated networks contain larger and more numerous intermediate arrays, with substantial convolution, activation, and pooling work. These workloads make the costs of comparison and truncation difficult to ignore.

SqueezeNet, ResNet50, and DenseNet121 therefore serve as system-level tests of the proposed primitives. A successful result must show that arithmetic correctness, nonlinear evaluation, and linear computation can coexist at that scale. CrypTFlow2’s contribution is the complete connection between those pieces, supported by both protocol analysis and an executable compilation path.

### The method, step by step

The computation begins with ordinary trained inference code and ends with the client learning a prediction. Between those points, CrypTFlow2 changes how values are represented and how operations are executed. It preserves a stable rule at layer boundaries: the parties hold arithmetic shares of the layer input, perform a secure protocol, and obtain arithmetic shares of the layer output.

From trained inference code to private prediction The steps in order.

#### Define the function and its security boundary

The intended prediction can be written as:

```
y = F(x, w)
```

Here, x is the client’s private input, w contains the server’s private weights, F is the known network computation, and y is the prediction delivered to the client. The security objective allows the client to learn y and whatever follows from y together with x. It does not promise that outputs themselves reveal nothing.

The adversary is static and semi-honest. Static means that the corrupted participant is selected before execution. Semi-honest means that the participant follows the protocol while trying to infer additional information from its observations.

The proof framework compares actual protocol execution with an ideal arrangement in which a trusted functionality receives the private inputs and returns the prescribed outputs. Security requires a simulator that can reproduce what a corrupted participant observes without access to the other participant’s private information. If actual and simulated observations cannot be distinguished by a computationally bounded environment, the protocol meets the paper’s security definition.

This framework matters to the system’s modular design. Comparison, conversion, selection, and arithmetic are analyzed as components. The full inference procedure then invokes them in sequence while maintaining their input and output conventions.

#### Represent secrets through shares

For arithmetic sharing over a ring, the representation satisfies:

```
a = (a₀ + a₁) mod n
```

The secret value is a, the ring modulus is n, and the parties hold a₀ and a₁ separately. The operator mod takes the remainder modulo n. The shares are generated randomly subject to reconstructing a, so either share alone hides the secret.

CrypTFlow2 uses arithmetic domains suited to its alternative backends. The oblivious-transfer backend operates over a power-of-two ring:

```
L = 2^ℓ
```

L is the modulus and ℓ is the integer bitwidth. This domain supports the familiar two’s-complement interpretation of signed integers. The homomorphic-encryption backend uses an appropriate prime modulus n, while the underlying protocols are developed for more general rings as well.

Boolean sharing uses exclusive-or:

```
b = b₀ ⊕ b₁
```

Here, b is a secret bit, b₀ and b₁ are its Boolean shares, and ⊕ denotes exclusive-or. The distinction between arithmetic and Boolean shares is operationally important. A comparison naturally produces a protected bit, whereas a subsequent arithmetic correction needs that bit represented in the arithmetic ring.

The paper therefore includes Boolean-to-arithmetic conversion. It also uses a secure multiplexer: an operation that returns protected shares of a value when a protected choice bit selects it, and shares of zero otherwise.

#### Encode fractional values and choose precision

The fixed-point encoding is:

```
a = ⌊x · 2^s⌋ mod n
```

The original numerical value is x, s is the scale parameter, n is the ring modulus, and a is the encoded integer. The floor brackets mean rounding downward. The power-of-two factor determines how fractional precision is represented in the integer.

The compiler chooses arithmetic width and scale using a validation set. The paper’s implementation extends Athos, CrypTFlow’s frontend, so that both quantities can be tuned. Earlier CrypTFlow execution used 64-bit integers partly to limit the probability of errors associated with its local truncation procedure. Because CrypTFlow2 removes that source of error, its compiler can choose width according to the requirements of the fixed-point computation.

Choosing a suitable width remains essential. Intermediate values must fit the signed range intended by the encoding. Exact secure arithmetic reproduces the specified ring computation; it does not rescue a poorly chosen numerical representation.

The paper’s procedure concerns inference conversion rather than training. It starts with trained TensorFlow code, establishes a fixed-point version with appropriate numerical behavior, and executes that version securely. The validation step selects representation settings; it does not learn a replacement set of network weights.

#### Build comparison from short blocks

The comparison problem gives one participant an unsigned integer x and the other an unsigned integer y. They want protected shares of the bit indicating whether x is smaller.

The key recursive identity is:

```
1[x < y] = 1[x₁ < y₁] ⊕ (1[x₁ = y₁] ∧ 1[x₀ < y₀])
```

The notation 1[condition] is an indicator: it equals 1 when the condition holds and 0 otherwise. The symbols ∧ and ⊕ mean logical AND and exclusive-or. The strings x₁ and y₁ contain the more significant portions of the inputs, while x₀ and y₀ contain the less significant portions.

The identity says that the upper portion determines the answer unless the upper portions are equal. Only then does the lower comparison matter. Exclusive-or is valid here because the relevant alternatives cannot both hold.

A direct recursive construction could continue to individual bits. CrypTFlow2 instead stops at blocks of m bits and evaluates the short comparisons through lookup tables and oblivious transfer. The parameter m controls the balance between the number of blocks and the size of each table.

In a one-out-of-k oblivious transfer, a sender supplies candidate messages and a receiver privately chooses which message to receive. The sender does not learn the selection, and the receiver obtains only the permitted message. For a short comparison, a table can encode the possible answers while masking them so that the output remains shared.

The internal tree then combines comparison and equality shares from smaller pieces. Logical AND requires interaction, while exclusive-or of Boolean shares can be performed locally. The tree therefore gives a way to balance communication volume against the number of sequential interaction stages.

The construction also handles input widths that do not divide evenly into blocks. A shorter final block uses a smaller table. When the number of leaves does not form a perfect binary tree, the authors combine maximal complete subtrees and recursively assemble the remainder.

#### Reduce duplication inside the comparison protocol

The first optimization combines leaf operations. At a given block, the receiver uses the same private block value to select both a comparison result and an equality result. These can be packaged into a single transfer containing both protected output bits.

The second optimization concerns the logical AND operations used when combining subtrees. Related combinations share an equality operand. Instead of producing entirely independent auxiliary randomness, the protocol generates correlated bit triples that reflect this shared input.

A bit triple supplies protected random bits together with their product, allowing an AND operation to be evaluated securely. The correlated construction supplies related triples with a common operand. The paper uses a one-out-of-8 transfer to generate this structure more economically than independent generation.

The third optimization removes equality results that will never affect the final answer. Along the least significant branch, some equality calculations are unnecessary because no still lower comparison needs them. Eliminating those calculations saves both leaf and internal-node work.

These changes are closely tied to the comparison structure. They do not weaken its output or expose additional intermediate decisions. Instead, they remove repeated cryptographic setup and calculations that the surrounding computation does not need.

#### Turn comparison into a protected sign test

The paper denotes its nonnegativity indicator by DReLU. Though the name comes from the derivative of ReLU, its operational definition includes zero among the non-negative inputs:

```
DReLU(a) = 1 ⊕ MSB(a)
```

This equation applies to a signed value a in the power-of-two ring. MSB(a) is its most significant bit under two’s-complement encoding. DReLU returns 1 for a non-negative input and 0 for a negative input.

The challenge is to obtain the reconstructed value’s top bit from separate shares. The relevant identity is:

```
MSB(a) = MSB(a₀) ⊕ MSB(a₁) ⊕ carry
```

The shares are a₀ and a₁. The bit carry records whether adding their lower portions produces a carry into the most significant position. Each party knows the top bit of its own share, so the only joint task in this identity is computing the carry.

If u₀ and u₁ are the unsigned integers represented by the lower ℓ−1 bits of the respective shares, then:

```
carry = 1[u₀ + u₁ ≥ 2^(ℓ−1)]
```

The width is ℓ, and the indicator tests whether the lower-part sum reaches the threshold for carrying into the top position. CrypTFlow2 expresses that condition as an instance of its comparison protocol.

For a general ring, sign is defined by where the unsigned representative falls relative to the midpoint:

```
DReLU(a) = 1[aᵤ < ⌈n/2⌉]
```

Here, aᵤ is the unsigned integer representative of a, n is the modulus, and the ceiling brackets round upward. The lower interval represents non-negative values.

The sum of shares may wrap around the modulus, so evaluating this definition from shares requires distinguishing possible intervals of the unreduced sum. A straightforward method uses separate threshold tests. The optimized protocol observes that one test becomes predetermined from a party’s own share, leaving fewer necessary comparisons.

The remaining comparisons are arranged to share the receiver’s input. This lets their transfers be combined without revealing which redundant test was omitted. A final protected selection produces shares of the sign indicator.

#### Use sign and selection for nonlinear layers

ReLU is expressed as:

```
ReLU(a) = DReLU(a) · a
```

The input is a, and DReLU(a) is its nonnegativity bit. The multiplication means that a non-negative input is preserved while a negative input becomes zero.

The protocol first obtains Boolean shares of DReLU(a). A secure multiplexer then uses that protected choice to produce arithmetic shares of the appropriate output. The sign itself need not be revealed to either party.

Maximum pooling uses related machinery. To compare candidate values x and y, the parties locally form shares of their difference, obtain a protected sign decision, and select the appropriate contribution. Repeating the operation across the pool yields its maximum.

The paper describes this pooling construction as a sequential recurrence over candidates. Finding the index of the maximum extends the same idea by carrying an index alongside the selected value. Thus comparison becomes useful beyond an activation function: it supports the decisions needed to choose among protected alternatives.

The arithmetic assumptions remain relevant. The sign of a ring subtraction must correspond to the intended signed comparison for the values being processed. The paper’s representation choices aim to keep intermediate numerical behavior within the intended range.

#### Define division before implementing it

Signed division must specify how negative quotients are rounded. CrypTFlow2 uses downward rounding and defines ring division through the signed interpretation of a ring element:

```
rdiv(a, d) = ⌊(aᵤ − 1[aᵤ ≥ ⌈n/2⌉] · n) / d⌋ mod n
```

The input a is an element of the ring with modulus n. Its unsigned representative is aᵤ. The public divisor d is positive and smaller than n. The indicator subtracts n when aᵤ belongs to the interval representing negative values, converting the unsigned representative to its signed integer meaning.

This definition separates the numerical operation from its protected implementation. The protocol must reproduce this quotient, rather than a nearby result or a value that happens to preserve the final classification.

Dividing shares separately is insufficient because addition can introduce carries and modular wraparound. The signed meanings of the individual shares can also differ from the signed meaning of their sum. CrypTFlow2’s theorem identifies the correction needed to reconcile those effects.

Write the modulus as a quotient and remainder with respect to d:

```
n = n¹ · d + n⁰
```

The integer n¹ is the quotient and n⁰ is the remainder, with n⁰ non-negative and smaller than d. Superscripts in this notation distinguish parts of the decomposition; they are not exponents.

The unsigned shares are decomposed similarly:

```
aᵢ = aᵢ¹ · d + aᵢ⁰
```

The index i identifies a participant. The value aᵢ¹ is the share’s quotient and aᵢ⁰ is its remainder. Each participant can calculate these values locally because it knows its own share.

#### Derive the correction terms

Let n′ denote the signed midpoint, obtained by rounding n/2 upward. The theorem introduces a signed correction corr:

```
corr = −1 if aᵤ ≥ n′ and a₀ < n′ and a₁ < n′; 1 if aᵤ < n′ and a₀ ≥ n′ and a₁ ≥ n′; 0 otherwise
```

The value aᵤ is the unsigned representative of the reconstructed secret. The values a₀ and a₁ are the unsigned shares. The correction distinguishes cases in which the signs of both shares agree but differ from the sign of the reconstructed value.

The next term collects the relevant remainders:

```
A = a₀⁰ + a₁⁰ − (1[a₀ ≥ n′] + 1[a₁ ≥ n′] − corr) · n⁰
```

The share remainders are a₀⁰ and a₁⁰, and n⁰ is the modulus remainder. The indicator terms account for the signed interpretation of each share. A is an ordinary integer quantity whose bounded range permits efficient comparisons.

The local rounding adjustment is:

```
B = ⌊(a₀⁰ − 1[a₀ ≥ n′] · n⁰) / d⌋ + ⌊(a₁⁰ − 1[a₁ ≥ n′] · n⁰) / d⌋
```

B combines the downward-rounded divisions of the adjusted remainders. Each summand depends on one participant’s share and public parameters, so the participants can supply its contribution locally.

The remaining threshold information is summarized by:

```
C = 1[A < d] + 1[A < 0] + 1[A < −d]
```

C is an integer sum of comparison bits. The thresholds divide A’s possible range into intervals corresponding to the required quotient correction.

The theorem then reconstructs the exact answer:

```
rdiv(a₀, d) + rdiv(a₁, d) + corr · n¹ + 1 − C − B ≡ rdiv(a, d) mod n
```

The two rdiv terms are the independently divided shares. The remaining terms repair their sum. The symbol ≡ states equality modulo n, so the complete expression gives the correct ring representation of the signed quotient.

The importance of this result is practical as well as mathematical. Most of the division can remain local. Secure comparison and conversion protocols supply the nonlocal information needed to make that local work exact.

#### Specialize division to fixed-point truncation

When the modulus is a power of two and the divisor is also a power of two, the theorem simplifies:

```
(a₀ ≫ s) + (a₁ ≫ s) + corr · 2^(ℓ−s) + 1[a₀⁰ + a₁⁰ ≥ 2^s] ≡ (a ≫ s) mod 2^ℓ
```

The ring width is ℓ and the scale reduction is s. The operator ≫ denotes signed arithmetic right shift. The remainders a₀⁰ and a₁⁰ are taken modulo the divisor 2^s. The term corr handles signed wraparound, while the indicator accounts for a carry from the discarded portions.

The protocol calculates the secret’s sign, uses a protected lookup to obtain shares of corr, and compares the low portions to determine the carry. Boolean-to-arithmetic conversion then makes that carry available for the arithmetic correction. Each participant combines these protected terms with its local shift.

General division uses the broader theorem. To compute C, the system tests the signs of A−d, A, and A+d in a smaller power-of-two ring. The necessary width is:

```
δ = ⌈log₂(6 · d)⌉
```

The divisor is d and δ is the bitwidth used for the temporary signed comparisons. The logarithm is base two. The bound is chosen so that the relevant temporary values fit without changing their intended integer signs.

The paper also exploits structure in the prime modulus used by homomorphic encryption. When the modulus remainder relative to the truncation divisor is sufficiently small, one threshold comparison is unnecessary. This yields a cheaper specialization for the truncations used in the evaluated encrypted backend.

#### Evaluate linear layers with alternative cryptographic mechanisms

For fully connected layers and convolutions, the oblivious-transfer backend uses established private multiplication techniques over the power-of-two ring. The server knows the weights, while activations are shared. The implementation combines transfer messages when structured multiplications use the same operand, reducing repeated work.

Convolutions are organized through matrix-multiplication techniques. Their outputs initially have the enlarged fixed-point scale created by multiplication, so exact truncation follows before values are used at the standard scale.

The homomorphic-encryption backend instead has the client encrypt its activation share. The server calculates on that ciphertext using its private weights, incorporates the required sharing adjustments, and returns encrypted information from which the client obtains its output share.

The authors use the BFV encryption scheme and build on convolution and matrix-vector techniques from Gazelle and Delphi. The encryption supports the additions and plaintext multiplications needed by these linear layers. Its communication depends on the layer’s input and output representations rather than directly on every scalar multiplication.

Encrypted convolution nevertheless has substantial local costs. CrypTFlow2 reduces rotations by grouping intermediate ciphertexts that require the same alignment. It adds values within a group before performing the shared rotation, avoiding repeated alignment work.

Average pooling follows a simpler pattern. The parties add their input shares locally, producing shares of the pool sum. They then invoke exact division by the public pool size. This preserves the intended mean under the paper’s signed fixed-point arithmetic.

#### Compile the complete computation

The official implementation is incorporated into the EzPC codebase through CrypTFlow’s compilation framework. Athos accepts TensorFlow inference code, produces a fixed-point computation, and connects it to the cryptographic backend. The new protocol library extends components from EMP, while the encrypted linear layers build on SEAL and Delphi code.

The implementation is multithreaded. It also optimizes cryptographic routines used repeatedly in oblivious-transfer extension, including key expansion and pipelining for the required AES operations. These improvements matter because a protocol’s local cryptographic work can dominate after communication has been reduced.

Finally, the compiler reduces the cost of exact truncation by using facts about the surrounding computation. Moving truncation after ReLU makes the truncation input non-negative and removes a sign subprotocol. When an addition lies along the transformed path, the compiler adjusts the other operand’s scale so that the addition remains meaningful.

The result is a complete inference pipeline instead of a collection of isolated primitives. Its correctness depends on the arithmetic definitions, the individual protocols, and the compiler transformations preserving the same fixed-point computation.

### Experiments and results

#### Workloads, machines, and comparison conditions

The experiments examine primitive performance, comparison with an earlier complete system, and scalability to larger image-classification networks. The main metrics are runtime and communication. The paper also checks that its fixed-point code preserves the accuracy of the TensorFlow input computation.

The local-area setup places both machines in West Europe. For the wide-area setup, one machine is in East US. The reported LAN bandwidth is 377 MBps, with echo latency of 0.3ms; the WAN bandwidth is 40 MBps, with echo latency of 80ms.

Each machine has a 3.7 GHz Intel Xeon processor, 4 cores, and 16 GBs of memory. These conditions matter to interpretation. A protocol with low communication but high local computation may behave differently across the two network settings, and a protocol with several interaction stages may need sufficiently large batches to amortize their latency.

The larger benchmarks are SqueezeNet, ResNet50, and DenseNet121 on ImageNet-scale classification. ResNet50 requires 37-bit fixed-point values to match the reported accuracy, while the other evaluated networks use 32 bits. The secure execution introduces no further discrepancy relative to the selected fixed-point program.

The comparison with Delphi uses its own benchmark setting: MiniONN on CIFAR-10 and ResNet32 on CIFAR-100, with ReLU activations. The authors use a bitwidth of 41 and measure the comparison in the LAN environment. This keeps the principal prior-system comparison tied to workloads Delphi was designed to evaluate.

#### Why the activation workload is substantial

The benchmark descriptions show how many times the new primitives must be used. SqueezeNet contains 26 convolution layers, and its ReLU activations total 2,033,480 elements. Its largest ReLU layer contains 200,704 elements.

ResNet50 has 53 convolution layers and 49 ReLU layers. Those ReLU layers contain 9,006,592 elements in total, with 802,816 elements in the largest layer. Its pooling includes an average over a pool of size 49.

DenseNet121 has 121 convolution layers. Its ReLU workload totals 15,065,344 elements, again reaching 802,816 elements in the largest activation layer. Its average-pooling workload includes pools of size 49 and size 4.

These counts explain why primitive improvements can matter at whole-network scale. A modest operation becomes a major cost when invoked across large intermediate arrays. They also explain why a comparison measured on a tiny batch may not predict performance on the actual networks.

#### Comparison with garbled circuits

The authors use EMP as their garbled-circuit baseline. Their activation scaling experiment covers batches from 2^0 to 2^20 ReLU operations. The evaluated image networks have activation layers in the region from 2^13 through 2^20 operations.

For that workload region, the reported runtime advantage ranges from 2×–25×. Larger layers benefit more, and wide-area execution produces larger gains when communication accounts for a substantial portion of elapsed time.

When the authors aggregate the ReLU work of their benchmarks, the power-of-two protocol reaches speed advantages of up to 8× in LAN and 18× in WAN. Its communication is roughly 7× more efficient than the garbled-circuit implementation.

For the general-ring protocol, the corresponding reported maxima are 9× in LAN and 21× in WAN, with roughly 9× lower communication. These are results for the activation computations under the tested domains and network settings, instead of a universal multiplier for complete inference.

The paper also gives a concrete communication comparison for exact truncation with width ℓ=32 and scale reduction s=12:

Exact truncation at ℓ=32 and s=12, communication The specialized protocol transmits substantially fewer bits than garbled circuits.

**The numbers**

| System or setting | bits |
| --- | --- |
| Garbled circuits | 24,064 |
| CrypTFlow2 truncation (this paper) | 4310 |

This comparison concerns protocol communication, not measured elapsed time. It supports the claim that exact arithmetic need not retain the communication burden of a general circuit implementation. It does not mean that the communication-minimizing configuration is automatically the fastest one.

#### Average pooling and amortization

For average-pooling layers, the paper reports runtime reductions reaching 51× and communication reductions reaching 41× compared with garbled circuits. The workload breakdown helps explain why those gains vary.

DenseNet121 requires 176,640 divisions for its average-pooling layers. On that workload, both cryptographic domains obtain runtime improvements greater than 32× in LAN and 45× in WAN.

SqueezeNet requires 1000 divisions, while ResNet50 requires 2048. Their reported runtime improvements fall in the smaller range of 2× to 7×. The authors attribute this to weaker amortization: there is less useful division work over which to spread protocol overhead.

Communication improves substantially even in those smaller cases. The reported advantage exceeds 19× for SqueezeNet, 27× for ResNet50, and 31× for DenseNet121, for both protocol variants. This distinction between runtime and transmitted data is important. Lower communication remains valuable, but elapsed time also includes local work and interaction overhead.

#### Comparison with Delphi

On the CIFAR benchmarks, nonlinear evaluation is the dominant component of Delphi’s total computation time. Replacing that component with CrypTFlow2’s protocols yields the reported speed advantage of 20×–30×. The authors include correct truncation in their nonlinear timing.

For MiniONN, communication decreases by 12×. For ResNet32, the reported communication improvement is 9×. These figures describe the compared nonlinear computation, which is the part of the pipeline directly replaced by the new protocols.

The online comparison also favors CrypTFlow2 by an order of magnitude. In that comparison, linear-layer online work is negligible, leaving nonlinear evaluation as the main source of time. The result therefore tests a particularly consequential part of the service’s response path.

The scope of the comparison deserves care. The authors use Delphi’s established smaller workloads instead of treating its unoptimized performance on the new ImageNet-scale tasks as the main baseline. This makes the evidence more informative about the benefits of the replacement protocols themselves.

#### Encrypted convolution improvements

The implementation study also reports a concrete convolution example from ResNet50. The layer uses an image size of 230×230, a filter of 7×7, input channels of 3, output channels of 64, and a stride of 2×2.

With the paper’s implementation improvements, its LAN runtime changes as follows:

ResNet50 first convolution, LAN runtime The optimized encrypted implementation substantially reduces the layer’s execution time.

**The numbers**

| System or setting | seconds |
| --- | --- |
| Earlier implementation | 306 |
| CrypTFlow2 optimized implementation (this paper) | 18 |

The same layer also transmits less data:

ResNet50 first convolution, communication The optimized encrypted implementation reduces the data exchanged for the layer.

**The numbers**

| System or setting | MiB |
| --- | --- |
| Earlier implementation | 204 |
| CrypTFlow2 optimized implementation (this paper) | 76 |

These changes reflect an implementation package that includes parallelization, modulus switching, and support for strided convolution. The paper does not isolate the contribution of every change in this example. The results show the value of the combined implementation work alongside the new nonlinear protocols.

#### Complete ImageNet-scale inference

Both backends can evaluate SqueezeNet in under a minute and extend to ResNet50 and DenseNet121. Across the evaluated benchmarks, the paper reports completion within 10 minutes in LAN and 20 minutes in WAN.

The backend comparison is conditional. In LAN, oblivious transfer is at least 20% faster for SqueezeNet and DenseNet121. The encrypted backend has more local computation, which matters when communication is relatively inexpensive.

ResNet50 changes that balance. Its wider arithmetic increases the communication cost of oblivious-transfer linear layers, and homomorphic encryption wins in both network settings. In WAN, the encrypted backend is faster across all the evaluated networks: the reported advantage is 2× for SqueezeNet and DenseNet121, and 4× for ResNet50.

The empirical conclusion is therefore more useful than a blanket preference for one cryptographic technique. Communication conditions and arithmetic width influence which backend provides the lower inference latency. CrypTFlow2 supports both so that this choice can follow the deployment rather than dictate the entire application design.

### What the ablations show

The paper offers targeted component comparisons, parameter analysis, and implementation measurements instead of a comprehensive ablation that removes every optimization from the complete system.

#### Minimum communication does not give minimum runtime

The clearest parameter study concerns the comparison block size m. For ℓ=32, the communication expression is minimized at m=7. Yet m=4 gives the best measured execution time in both tested network environments.

The paper reports that this faster setting uses about 30% more communication while reducing computation by approximately 3×. The reason is the growth of the lookup-table work. A larger block reduces the number of leaves, but it increases the number of possible table entries that must be processed.

This analysis prevents a misleading reading of the theoretical figures. The best communication numbers demonstrate what the protocol can achieve under one objective. The implementation settings show what is preferable when the objective is actual runtime on the evaluated machines.

#### Shared inputs create measurable protocol savings

The comparison analysis identifies savings from combining leaf transfers and from using correlated triples. These are controlled structural changes: the intended comparison remains the same, while repeated setup and auxiliary work are reduced.

The general-ring sign protocol supplies another example. A simple construction uses separate threshold comparisons to handle sign and modular wraparound. The optimized version removes a comparison whose result is already determined by a party’s share, then combines work across the remaining related calls.

The authors describe the resulting communication improvement as nearly 2× relative to the simpler construction. This is an analysis of protocol structure and cost, not evidence that every complete inference becomes twice as fast. Its importance is that it explains how the optimized primitive avoids paying independently for related decisions.

#### Layer size explains the network effect

The activation experiments vary the number of ReLU operations, making them informative about amortization. The benefit over garbled circuits increases with larger batches. Wide-area communication makes the reduction in transmitted data particularly valuable once the batch is large enough.

This explains an otherwise surprising result: a protocol with several interaction stages can still perform well across a high-latency connection. The stages remain, but each stage handles enough useful work that bandwidth becomes a major contributor to total time.

The average-pooling comparison supports the same interpretation from another direction. DenseNet121 has a much larger division workload than the other evaluated networks and receives much stronger runtime gains. The improvement depends on how the primitive is used, not only on its isolated formula.

#### Backend comparisons expose precision costs

The contrast between the LAN results for ResNet50 and the other networks provides an analysis of numerical width. Oblivious-transfer linear layers have communication that grows quadratically with bitlength in the implementation considered by the authors.

The move to 37-bit arithmetic for ResNet50 changes the tradeoff enough for encrypted execution to win even in LAN. This supports a practical conclusion: choosing a numerical representation and choosing a cryptographic backend are connected decisions.

The evidence does not isolate bitwidth as the sole difference between the networks. Their architectures and layer dimensions also differ. The authors use the width dependence to explain the observed backend behavior, but this is not a controlled experiment in which only width changes.

#### Compiler and implementation gains have different evidence

Moving truncation after ReLU is justified by a semantic property: the values are non-negative, so part of the truncation protocol becomes redundant. The compiler must also preserve compatible scales through intervening operations. Its correctness depends on those conditions, rather than on an empirical tolerance for altered predictions.

The encrypted convolution example, in contrast, measures a bundle of implementation improvements. It establishes that the improved implementation is much faster and communicates less for the reported layer. It does not provide separate whole-network measurements for rotation grouping, parallelization, and modulus switching.

Taken together, these analyses show several sources of improvement: better primitive structure, removal of unnecessary work, batching, and lower-level implementation changes. They support the system’s overall performance story while leaving the exact contribution of every optimization to complete inference unresolved.

### Limitations

#### The authors’ stated security limits

The paper’s security guarantee covers semi-honest behavior. A participant may try to infer private information from its legitimate view, but it must carry out the prescribed computation. The authors explicitly identify protection against malicious participants as future work.

That boundary affects practical interpretation. The proof does not establish correct behavior when a party substitutes arbitrary messages, manipulates its intermediate calculations, or otherwise departs from the protocol. Extending the system to that setting would require additional mechanisms and analysis.

The architecture is also not entirely concealed. The initial problem assumes a publicly known computation structure with private weights. The encrypted backend can hide some architectural details, including filter dimensions, strides, and whether certain layers are convolutional or fully connected. The authors nonetheless describe further architectural hiding as an open direction.

The selected arithmetic width and scale also reveal information related to the weights. The paper acknowledges this leakage and places it alongside comparable disclosures in earlier systems. Its confidentiality guarantee should therefore be understood together with these public configuration choices.

#### The authors’ stated scope limits

CrypTFlow2 evaluates inference. The conclusion identifies secure training at ImageNet scale as a future objective, with a likely need for protocols that exploit specialized computation and networking hardware.

Its inference results therefore do not establish a training system. Training introduces a different workload and additional operations; the paper does not supply end-to-end measurements for that task. The fact that the evaluated prediction networks can run on commodity machines does not settle the resource requirements of learning their weights privately.

The authors also leave broader concealment of the computation structure for future work. Their objective is to hide more architectural information while keeping overhead manageable. The present system demonstrates a useful point in that tradeoff, rather than complete privacy for every aspect of the service.

#### What exact arithmetic does and does not establish

A careful reader should distinguish exact secure execution from exact reproduction of arbitrary floating-point behavior. CrypTFlow2 first chooses a fixed-point program. Its protocols then reproduce that program’s operations faithfully.

The conversion into fixed-point form remains a numerical design decision. Width and scale are selected with a validation set, and the representation is intended to keep intermediate magnitudes within the appropriate range. The paper checks accuracy for its benchmarks, but the cryptographic theorem alone does not guarantee that every possible network can use the same settings.

Likewise, preserving arithmetic does not establish that a prediction is correct in the application sense. It guarantees that private execution returns the result of the specified computation. Classification quality remains a property of the trained network and its numerical representation.

The output itself is also outside the scope of a promise of total secrecy. The client is permitted to learn the prediction and whatever follows from it together with its input. The security definition protects additional information exposed by the protocol; it does not claim that intended outputs carry no information about the server.

#### Limits visible in the evaluation

The performance evidence comes from specific machines, network conditions, and image-classification workloads. It demonstrates feasibility and comparative advantages in those settings. It does not establish the same runtime for every connection, machine configuration, or application.

The WAN result is especially conditional on communication characteristics. Homomorphic encryption wins across the tested wide-area workloads, while LAN results vary. Those observations support deployment-dependent backend selection instead of a universal ranking.

The primitive results also depend on batch size. Smaller average-pooling workloads show much weaker runtime gains despite substantial communication improvements. An application with many small, sequential protected decisions may not receive the same benefit as the large activation arrays in the main benchmarks.

Finally, the paper does not isolate every system optimization. The combination of new protocols, compiler changes, cryptographic implementation work, and improved encrypted convolution produces the reported system. The experiments explain important components, but they do not allocate a precise share of the complete speedup to each one.

### What came after

No specific subsequent study is established here, so a citation history cannot be given responsibly. The paper itself leaves a clear research agenda: extend secure execution from inference to training, strengthen protection against malicious participants, and conceal more of the network structure without excessive overhead.

Its reusable contribution is a set of mechanisms that later research could build on. Efficient private comparison supports protected decisions; exact division connects secret sharing to faithful fixed-point arithmetic; and interchangeable backends expose the practical tradeoff between local computation and communication.

Those are foundations and open directions, rather than evidence that a particular successor completed them. CrypTFlow2’s demonstrated result remains the combination achieved in its own setting: larger two-party private inference, exact execution of the chosen fixed-point computation, and an implementation whose cryptographic strategy can follow the network environment.

## Cite

Cite as Deevashwer Rathee, Mayank Rathee, Nishant Kumar, Nishanth Chandran, Divya Gupta, Aseem Rastogi and Rahul R. Sharma. 2020. CrypTFlow2: Practical 2-Party Secure Inference. ACM SIGSAC Conference on Computer and Communications Security (CCS).

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.1145/3372297.3417274](https://doi.org/10.1145/3372297.3417274) · [arXiv 2010.06457](https://arxiv.org/abs/2010.06457)

```bibtex
@inproceedings{rathee2020cryptflow2,
  title = {{CrypTFlow2: Practical 2-Party Secure Inference}},
  author = {Deevashwer Rathee, Mayank Rathee, Nishant Kumar, Nishanth Chandran, Divya Gupta, Aseem Rastogi and Rahul R. Sharma},
  booktitle = {ACM SIGSAC Conference on Computer and Communications Security (CCS)},
  year = {2020},
  doi = {10.1145/3372297.3417274},
  eprint = {2010.06457},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.1145/3372297.3417274}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
