1 Introduction

A biprime is a number \(N\) of the form \(N=p\cdot q\) where \(p\) and \(q\) are primes. Such numbers are used as a component of the public key (i.e., the modulus) in the RSA cryptosystem [46], with the factorization being a component of the secret key. A long line of research has studied methods for sampling biprimes efficiently; in the early days, the task required specialized hardware and was not considered generally practical [44, 45]. In subsequent years, advances in computational power brought RSA into the realm of practicality and then ubiquity. Given a security parameter \({\kappa } \), the de facto standard method for sampling RSA biprimes involves choosing random \({\kappa } \)-bit numbers and subjecting them to the Miller–Rabin primality test [38, 43] until two primes are found; these primes are then multiplied to form a \(2{\kappa } \)-bit modulus. This method suffices when a single party wishes to generate a modulus, and is permitted to know the associated factorization.

Boneh and Franklin [4, 5] initiated the study of distributed RSA modulus generation.Footnote 1 This problem involves a set of parties who wish to jointly sample a biprime in such a way that no corrupt and colluding subset (below some defined threshold size) can learn the biprime’s factorization.

It is clear that applying generic multiparty computation (MPC) techniques to the standard sampling algorithm yields an impractical solution: implementing the Miller–Rabin primality test requires repeatedly computing \(a^{p-1}\bmod {p}\), where \(p\) is (in this case) secret, and so such an approach would require the generic protocol to evaluate a circuit containing many modular exponentiations over \({\kappa } \) bits each. Instead, Boneh and Franklin [4, 5] constructed a new biprimality test that generalizes Miller–Rabin and avoids computing modular exponentiations with secret moduli. Their test carries out all exponentiations modulo the public biprime \(N\), and this allows the exponentiations to be performed locally by the parties. Furthermore, they introduced a three-phase structure for the overall sampling protocol, which subsequent works have embraced:

  1. 1.

    Prime Candidate Sieving: candidate values for \(p\) and \(q\) are sampled jointly in secret-shared form, and a weak-but-cheap form of trial division sieves them, culling candidates with small factors.

  2. 2.

    Modulus Reconstruction: \(N:=p\cdot q\) is securely computed and revealed.

  3. 3.

    Biprimality Testing: using a distributed protocol, \(N\) is tested for biprimality. If \(N\) is not a biprime, then the process is repeated.

The seminal work of Boneh and Franklin considered the semi-honest n-party setting with an honest majority of participants. Many extensions and improvements followed (as detailed in Sect. 1.3), the most notable of which (for our purposes) are two recent works that achieve malicious security against a dishonest majority. In the first, Hazay et al. [28, 29] proposed an n-party protocol in which both sieving and modulus reconstruction are achieved via additively homomorphic encryption. Specifically, they rely upon both ElGamal and Paillier encryption, and in order to achieve malicious security, they use zero-knowledge proofs for a variety of relations over the ciphertexts. Thus, their protocol represents a substantial advancement in terms of its security guarantee, but this comes at the cost of additional assumptions and an intricate proof, and also at substantial concrete cost, due to the use of many custom zero-knowledge proofs.

The subsequent protocol of Frederiksen et al. [23] (the second recent work of note) relies mainly on oblivious transfer (OT), which they use to perform both sieving and, via Gilboa’s classic multiplication protocol [24], modulus reconstruction. They achieved malicious security using the folklore technique in which a “Proof of Honesty” is evaluated as the last step and demonstrated practicality by implementing their protocol; however, it is not clear how to extend their approach to more than two parties in a straightforward way. Moreover, their approach to sieving admits selective-failure attacks, for which they account by including some leakage in the functionality. It also permits a malicious adversary to selectively and covertly induce false negatives (i.e., force the rejection of true biprimes after the sieving stage), a property that is again modeled in their functionality. In conjunction, these attributes degrade security, because the adversary can rejection-sample biprimes based on the additional leaked information, and efficiency, because ruling out malicious false-negatives involves running sufficiently many instances to make the probability of statistical failure in all instances negligible.

Thus, given the current state of the art, it remains unclear whether one can sample an RSA modulus among two parties (one being malicious) without leaking additional information or permitting covert rejection sampling, or whether one can sample an RSA modulus among many parties (all but one being malicious) without involving heavy cryptographic primitives such as additively homomorphic encryption, and their associated performance penalties. In this work, we present a protocol which efficiently achieves both tasks.

1.1 Results and Contributions

A Clean Functionality. We define , a simple, natural functionality for sampling biprimes from the same well-known distribution used by prior works [5, 23, 29], with no leakage or conflation of sampling failures with adversarial behavior.

A Modular Protocol, with Natural Assumptions. We present a protocol in the -hybrid model, where is an augmented multiplier functionality and is a biprimality-testing functionality, and prove that it UC-realizes in the malicious setting, assuming the hardness of factoring. More specifically, we prove:

Theorem 1.1

(Main security theorem, informal) In the presence of a PPT malicious adversary corrupting any subset of parties, can be securely computed with abort in the -hybrid model, assuming the hardness of factoring.

Additionally, because our security proof relies upon the hardness of factoring only when the adversary cheats, we find to our surprise that our protocol achieves perfect security against semi-honest adversaries.

Theorem 1.2

(Semi-honest security theorem, informal) In the presence of a computationally unbounded semi-honest adversary corrupting any subset of parties, can be computed with perfect security in the -hybrid model.

Supporting Functionalities and Protocols. We define , a simple, natural functionality for biprimality testing and show that it is UC-realized in the semi-honest setting by a well-known protocol of Boneh and Franklin [5], and in the malicious setting by a derivative of the protocol of Frederiksen et al. [23]. We believe this dramatically simplifies the composition of these two protocols and, as a consequence, leads to a simpler analysis. Either protocol can be based exclusively upon oblivious transfer.

We also define , a functionality for sampling and multiplying secret-shared values in a special form derived from the Chinese remainder theorem. In the context of , this functionality allows us to efficiently sample numbers in a specific range, with no small factors, and then compute their product. We prove that it can be UC-realized exclusively from oblivious transfer, using derivatives of well-known multiplication protocols [19, 20].

Asymptotic Efficiency. We perform an asymptotic analysis of our composed protocols and find that our semi-honest protocol is a factor of \({\kappa }/\log {\kappa } \) more bandwidth-efficient than that of Frederiksen et al. [23], where \({\kappa } \) is the bit-length of the primes p and q. Our malicious protocol is a factor of \({\kappa }/{s} \) more efficient than theirs in the optimistic case (when parties follow the protocol), where \({s} \) is a statistical security parameter, and it is a factor of \({\kappa } \) more efficient when parties deviate from the protocol. Frederiksen et al. claim in turn that their protocol is strictly superior to the protocol of Hazay et al. [29] with respect to asymptotic bandwidth performance.

Concrete Efficiency. We perform a closed-form concrete communication cost analysis of our protocol (with some optimizations, including the use of random oracles), and compare our results to the protocol of Frederiksen et al. (the most efficient prior work). For \({\kappa } =1024\) (i.e., when sampling a 2048-bit biprime), our protocol outperforms theirs by a factor of roughly five in the presence of worst-case malicious adversaries, and by a factor of roughly eighty in the semi-honest setting. As the bitlength of the sampled prime grows, so too does the concrete performance advantage of our protocol.

1.2 Overview of Techniques

Constructive Sampling and Efficient Modulus Reconstruction. Most prior works use rejection sampling to generate a pair of candidate primes and then multiply those primes together in a separate step. Specifically, they sample a shared value \(p\leftarrow [0,2^{\kappa })\) uniformly, and then run a trial-division protocol repeatedly, discarding both the value and the work that has gone into testing it if trial division fails. This represents a substantial amount of wasted work in expectation. Furthermore, Frederiksen et al. [23] report that multiplication of candidates after sieving accounts for two thirds of their concrete cost.

We propose a different approach that leverages the Chinese remainder theorem (CRT) to constructively sample a pair of candidate primes and multiply them together efficiently. A similar sieving approach (in spirit) was initially formulated as an optimization in a different setting by Malkin et al. [37]. The CRT implies an isomorphism between a set of values, each in a field modulo a distinct prime, and a single value in a ring modulo the product of those primes (i.e., \({\mathbb {Z}}_{m_1}\times \cdots \times {\mathbb {Z}}_{m_\ell }\simeq {\mathbb {Z}}_{m_1\cdot \ldots \cdot m_\ell }\)). We refer to the set of values as the CRT form or CRT representation of the single value to which they are isomorphic. We formulate a sampling mechanism based on this isomorphism as follows: for each of the first \(O({\kappa }/\log {\kappa })\) odd primes, the parties jointly (and efficiently) sample shares of a value that is nonzero modulo that prime. These values are the shared CRT form of a single \({\kappa } \)-bit value that is guaranteed to be indivisible by any prime in the set sampled against. For technical reasons, we sample two such candidates simultaneously.

Rather than converting pairs of candidate primes from CRT form to standard form, and then multiplying them, we instead multiply them component-wise in CRT form and then convert the product to standard form to complete the protocol. This effectively replaces a single “full-width” multiplication of size \({\kappa } \) with \(O({\kappa }/\log {\kappa })\) individual multiplications, each of size \(O(\log {\kappa })\). We intend to perform multiplication via an OT-based protocol, and the computation and communication complexity of such protocols grows at least with the square of their input length, even in the semi-honest case [24]. Thus, in the semi-honest case, our approach yields an overall complexity of \(O({\kappa } \log {\kappa })\), as compared to \(O({\kappa } ^2)\) for a single full-width multiplication. In the malicious case, combining the best known multiplier construction [19, 20] with the most efficient known OT extension scheme [6] yields a complexity that also grows with the product of the input length and a statistical parameter \({s} \), and so our approach achieves an overall complexity of \(O({\kappa } \log {\kappa } + {\kappa } \cdot {s})\), as compared to \(O({\kappa } ^2+{\kappa } \cdot {s})\) for a single full-width malicious multiplication. Via closed-form analysis, we show that this asymptotic improvement is also reflected concretely.

Achieving Security with Abort Efficiently. The fact that we sample primes in CRT form also plays a crucial role in our security analysis. Unlike the work of Frederiksen et al. [23], our protocol achieves the standard, intuitive notion of security with abort: the adversary can instruct the functionality to abort regardless of whether a biprime is successfully sampled, and the honest parties are always made aware of such adversarial aborts. There is, in other words, absolutely no conflation of sampling failures with adversarial behavior. For the sake of efficiency, our protocol permits the adversary to cheat prior to biprimality testing and then rules out such cheats retroactively using one of two strategies. In the case that a biprime is successfully sampled, adversarial behavior is ruled out, retroactively, in a privacy-preserving fashion using well-known but moderately expensive techniques, which is tolerable only because it need not be done more than once. In the case that a sampled value is not a biprime, however, the inputs to the sampling protocol are revealed to all parties, and the retroactive check is carried out in the clear. Proving the latter approach secure turns out to be surprisingly subtle.

The challenge arises from the fact that the simulator must simulate the protocol transcript for the OT-multipliers on behalf of the honest parties without knowing their inputs. Later, if the sampling-protocol inputs are revealed, the simulator must “explain” how the simulated transcript is consistent with the true inputs of the honest parties. Specifically, in maliciously secure OT-multipliers of the sort we use [19, 20], the OT receiver (Bob) uses a high-entropy encoding of his input, and the sender (Alice) can, by cheating, learn a one-bit predicate of this encoding. Before Bob’s true input is known to the simulator, it must pick an encoding at random. When Bob’s input is revealed, the simulator must find an encoding of his input which is consistent with the predicate on the random encoding that Alice has learned. This task closely resembles solving a random instance of subset sum.

We are able to overcome this difficulty because our multiplications are performed component-wise over CRT-form representations of their operands. Because each component is of size \(O(\log {\kappa })\) bits, the simulator can simply guess random encodings until it finds one that matches the required constraints. We show that this strategy succeeds in strict polynomial time and that it induces a distribution statistically close to that of the real execution.

This form of “privacy-free” malicious security (wherein honest behavior is verified at the cost of sacrificing privacy) leads to considerable efficiency gains in our case: it is up to a multiplicative factor of \({s} \) (the statistical parameter) cheaper than the privacy-preserving check used in the case that a candidate passes the biprimality test (and the one used in prior OT-multipliers [19, 20]). Since most candidates fail the biprimality test, using the privacy-free check to verify that they were generated honestly results in substantial savings.

Biprimality Testing as a Black Box. We specify a functionality for biprimality testing and prove that it can be realized by a maliciously secure version of the Boneh–Franklin biprimality test. Our functionality has a clean interface and does not, for example, require its inputs to be authenticated to ensure that they were actually generated by the sampling phase of the protocol. The key insight that allows us to achieve this level of modularity is a reduction to factoring: if an adversary is able to cheat by supplying incorrect inputs to the biprimality test, relative to a candidate biprime \(N\), and the biprimality test succeeds, then we show that the adversary can be used to factor biprimes. We are careful to rely on this reduction only in the case that \(N\) is actually a biprime, and to prevent the adversary from influencing the distribution of candidates.

The Benefits of Modularity. We claim as a contribution the fact that modularity has yielded both a simpler protocol description and a reasonably simple proof of security. We believe that this approach will lead to derivatives of our work with stronger security properties or with security against stronger adversaries. As a first example, we prove that a semi-honest version of our protocol (differing only in that it omits the retroactive consistency check in the protocol’s final step) achieves perfect security. We furthermore observe that in the malicious setting, instantiating and with security against adaptive adversaries yields an RSA modulus sampling protocol that is adaptively secure.

Similarly, only minor adjustments to the main protocol are required to achieve security with identifiable abort [16, 32]. If we assume that the underlying functionalities and are instantiated with identifiable abort, then it remains only to ensure the use of consistent inputs across these functionalities, and to detect which party has provided inconsistent inputs if an abort occurs. This can be accomplished by augmenting with an additional interface for revealing the input values provided by all the parties upon global request (e.g., when the candidate \(N\) is not a biprime). Given identifiable abort, it is possible to guarantee output delivery in the presence of up to \(n-1\) corruptions via standard techniques, although the functionality must be weakened to allow the adversary to reject one biprime per corrupt party.Footnote 2 A proof of this extension is beyond the scope of this work; we focus instead on the advancements our framework yields in the setting of security with abort.

1.3 Additional Related Work

Frankel, MacKenzie, and Yung [22] adjusted the protocol of Boneh and Franklin [4] to achieve security against malicious adversaries in the honest-majority setting. Their main contribution was the introduction of a method for robust distributed multiplication over the integers. Cocks [11] proposed a method for multiparty RSA key generation under heuristic assumptions, and later attacks by Coppersmith (see [12]) and Joye and Pinch [33] suggested this method may be insecure. Poupard and Stern [42] presented a maliciously secure two-party protocol based on oblivious transfer. Gilboa [24] improved efficiency in the semi-honest two-party model, and introduced a novel method for multiplication from oblivious transfer, from which our own multipliers derive.

Malkin, Wu, and Boneh [37] implemented the protocol of Boneh and Franklin and introduced an optimized sieving method similar in spirit to ours. In particular, their protocol generates sharings of random values in \({\mathbb {Z}}_M^*\) (where M is a primorial modulus) during the sieving phase, instead of naïve random candidates for primes p and q. However, their method produces multiplicative sharings of p and q, which are converted into additive sharings for biprimality testing via an honest-majority, semi-honest protocol. This conversion requires rounds linear in the party count, and it is unclear how to adapt it to tolerate a malicious majority of parties without a significant performance penalty.

Algesheimer, Camenish, and Shoup [1] described a method to compute a distributed version of the Miller–Rabin test: they used secret-sharing conversion techniques reliant on approximations of \(1/p\) to compute exponentiations modulo a shared \(p\). However, each invocation of their Miller–Rabin test still has complexity in \(O({\kappa } ^3)\) per party, and their overall protocol has communication complexity in \(O({\kappa } ^5/\log ^2{{\kappa }})\), with \(\Theta ({\kappa })\) rounds of interaction. Concretely, Damgård and Mikkelsen [18] estimate that 10,000 rounds are required to sample a 2000-bit biprime using this method. Damgård and Mikkelsen also extended their work to improve both its communication and round complexity by several orders of magnitude, and to achieve malicious security in the honest-majority setting. Their protocol is at least a factor of \(O({\kappa })\) better than that of Algesheimer, Camenish, and Shoup, but it still requires hundreds of rounds. We were not able to compute an explicit complexity analysis of their approach. We give a summary of prior works in Table 1, for ease of comparison.

In a follow-up work, Chen et al. [10] make use of our CRT-based biprime sampling technique, but abandon our modular protocol and proof in favor of a monolithic construction that leverages recent advancements in additively-homomorphic encryption and zero-knowledge arguments. They focus on the setting wherein there is a powerful, semi-honest aggregator, and many weak, malicious clients. This mixed security model yields opportunities for optimization, and they show that their approach is sufficiently efficient for real-world use, even with thousands of participants spread around the world.

Finally, we note that the manipulation of values in what we have referred to as CRT form has long been studied under the guise of residue number systems [48]. Though we take few pains to formalize the connection or to generalize beyond what is required for this work, some of our techniques could be viewed as multiparty adaptations of techniques from the RNS literature.

Table 1 Comparison of prior works

1.4 Organization

Basic notation and background information are given in Sect. 2. Our ideal biprime-sampling functionality is defined in Sect. 3, and we give a protocol that realizes it in Sect. 4. In Sect. 5, we present our biprimality-testing protocol. In Sect. 6, we give an efficiency analysis. We defer full proofs of security and the details of our multiplication protocol to the appendices.

2 Preliminaries

Notation. We use \(=\) for equality, \(:=\) for assignment, \(\leftarrow \) for sampling from a distribution, \(\equiv \) for congruence, \(\smash {\approx _{\mathrm{c}}}\) for computational indistinguishability, and \(\smash {\approx _{\mathrm{s}}}\) for statistical indistinguishability. In general, single-letter variables are set in italic font, multiletter variables and function names are set in sans-serif font, and string literals are set in \(\texttt {slab-serif}\) font. We use \(\bmod {}\) to indicate the modulus operator, while \(\pmod {m}\) at the end of a line indicates that all equivalence relations on that line are to be taken over the integers modulo m. By convention, we parameterize computational security by the bit-length of each prime in an RSA biprime; we denote this length by \({\kappa } \) throughout. We use \({s} \) to represent the statistical parameter. Where concrete efficiency is concerned, we introduce a second computational security parameter, \({\lambda } \), which represents the length of a symmetric key of equivalent strength to a biprime of length \(2{\kappa } \).Footnote 3\({\kappa } \) and \({\lambda } \) must vary together, and a recommendation for the relationship between them has been laid down by NIST [2].

Vectors and arrays are given in bold and indexed by subscripts; thus, \({\varvec{\mathrm {x}}}_i\) is the \(i\)th element of the vector \({\varvec{\mathrm {x}}}\), which is distinct from the scalar variable x. When we wish to select a row or column from a two-dimensional array, we place a \(*\) in the dimension along which we are not selecting. Thus, \(\smash {{\varvec{\mathrm {y}}}_{*,j}}\) is the \(j\)th column of matrix \({\varvec{\mathrm {y}}}\), and \(\smash {{\varvec{\mathrm {y}}}_{j,*}}\) is the \(j\)th row. We use \(\mathcal{P} _i\) to denote the party with index i, and when only two parties are present, we refer to them as Alice and Bob. Variables may often be subscripted with an index to indicate that they belong to a particular party. When arrays are owned by a party, the party index always comes first. We use |x| to denote the bit-length of x and \(|{\varvec{\mathrm {y}}}|\) to denote the number of elements in the vector \({\varvec{\mathrm {y}}}\).

Universal Composability. We prove our protocols secure in the universal composability (UC) framework and use standard UC notation. In Appendix A, we give a high-level overview and refer the reader to Canetti [7] for further details. In functionality descriptions, we leave some standard bookkeeping elements implicit. For example, we assume that the functionality aborts if a party tries to reuse a session identifier inappropriately, send messages out of order, etc. For convenience, we provide a function \(\mathsf {GenSID} \), which takes any number of arguments and deterministically derives a unique Session ID from those arguments. For example, \(\mathsf {GenSID} (\mathsf {sid},x,\texttt {x})\) derives a new Session ID from the variables \(\mathsf {sid}\) and x, and the string literal “x”.

Chinese Remainder Theorem. The Chinese remainder theorem (CRT) defines an isomorphism between a set of residues modulo a set of respective pairwise-coprime values and a single value modulo the product of the same set of pairwise-coprime values. This forms the basis of our sampling procedure.

Theorem 2.1

(CRT) Let \({\varvec{\mathrm {m}}} \) be a vector of pairwise-coprime positive integers and let \({\varvec{\mathrm {x}}}\) be a vector of numbers such that \(|{\varvec{\mathrm {m}}} |=|{\varvec{\mathrm {x}}}|=\ell \) and \(0\le {\varvec{\mathrm {x}}}_j<{\varvec{\mathrm {m}}} _j\) for all \(j\in [\ell ]\), and finally let \(M:=\prod _{j\in [\ell ]} {\varvec{\mathrm {m}}} _j\). Under these conditions, there exists a unique value y such that \(0\le y<M\) and \(y\equiv {\varvec{\mathrm {x}}}_j\pmod {{\varvec{\mathrm {m}}} _j}\) for every \(j\in [\ell ]\).

We refer to \({\varvec{\mathrm {x}}}\) as the CRT form of y with respect to \({\varvec{\mathrm {m}}} \). For completeness, we give the algorithm, which finds the unique y given \({\varvec{\mathrm {m}}} \) and \({\varvec{\mathrm {x}}}\).

figure p

3 Assumptions and Ideal Functionality

We begin this section by discussing the distribution of biprimes from which we sample and thus the precise factoring assumption that we make, and then we give an efficient sampling algorithm and an ideal functionality that computes it.

3.1 Factoring Assumptions

The standard factoring experiment (Experiment 3.1) as formalized by Katz and Lindell [34] is parametrized by an adversary \(\mathcal{A} \) and a biprime-sampling algorithm \(\mathsf {GenModulus} \). On input \(1^{\kappa } \), this algorithm returns \((N,p,q)\), where \(N=p\cdot q\), and \(p\) and \(q\) are \({\kappa } \)-bit primes.Footnote 4

figure q

In many cryptographic applications, \(\mathsf {GenModulus} (1^{\kappa })\) is defined to sample \(p\) and \(q\) uniformly from the set of primes in the range \([2^{{\kappa }-1},2^{\kappa })\) [25], and the factoring assumption with respect to this common \(\mathsf {GenModulus}\) function states that for every PPT adversary \(\mathcal{A} \) there exists a negligible function \(\mathsf {negl}\) such that

Because efficiently sampling according to this uniform biprime distribution is difficult in a multiparty context, most prior works sample according to a different distribution, and thus using the moduli they produce requires a slightly different factoring assumption than the traditional one. In particular, several recent works use a distribution originally proposed by Boneh and Franklin [5], which is well adapted to multiparty sampling. Our work follows this pattern.

Boneh and Franklin’s distribution is defined by the sampling algorithm , which takes as an additional parameter the number of parties n. The algorithm samples n integer shares, each in the range \([0,2^{{\kappa }-\log {n}})\),Footnote 5 and sums these shares to arrive at a candidate prime. This does not induce a uniform distribution on the set of \({\kappa } \)-bit primes. Furthermore, only samples individual primes \(p\) or \(q\) that have \(p\equiv q\equiv 3\pmod {4}\), in order to facilitate efficient distributed primality testing, and it filters out the subset of otherwise-valid moduli \(N=p\cdot q\) that have \(p\equiv 1\pmod {q}\) or \(q\equiv 1\pmod {p}\).Footnote 6

figure r

Any protocol whose security depends upon the hardness of factoring moduli output by our protocol (including our protocol itself) must rely upon the assumption that for every PPT adversary \(\mathcal{A} \),

3.2 The Distributed Biprime-Sampling Functionality

Unfortunately, our ideal modulus-sampling functionality cannot merely call ; we wish our functionality to run in strict polynomial time, whereas the running time of is only expected polynomial. Thus, we define a new sampling algorithm, , which might fail, but conditioned on success outputs a distribution statistically indistinguishable from that of . Specifically, a coprimality constraint implies that there exists some concrete lower bound in \(O({\kappa })\) on the factors of the biprimes produced by , whereas with probability negligible in \(\kappa \), outputs biprimes with factors below this bound. Otherwise, for the appropriate (possibly non-integer) value of \({\kappa } \), the two output identical distributions, conditioned on success. However, we give a specific distribution of failures that is tied to the design of our protocol. As a second concession to our protocol design (and following Hazay et al. [29]), takes as input up to \(n-1\) integer shares of \(p\) and \(q\), arbitrarily determined by the adversary, while the remaining shares are sampled randomly. We begin with a few useful notions.

Definition 3.3

(Primorial Number) The \(i\)th primorial number is defined to be the product of the first i prime numbers.

Definition 3.4

(\(({\kappa },n)\)-Near-Primorial Vector) Let \(\ell \) be the largest number such that the \(\ell \)th primorial number is less than \(2^{{\kappa }-\log {n}-1}\), and let \({\varvec{\mathrm {m}}} \) be a vector of length \(\ell \) such that \({\varvec{\mathrm {m}}} _1=4\) and \({\varvec{\mathrm {m}}} _2,\ldots ,{\varvec{\mathrm {m}}} _\ell \) are the odd factors of the \(\ell ^\text {th}\) primorial number, in ascending order. \({\varvec{\mathrm {m}}} \) is the unique \(({\kappa },n)\)-near-primorial vector.

Definition 3.5

(\({\varvec{\mathrm {m}}} \)-Coprimality) Let \({\varvec{\mathrm {m}}} \) be a vector of integers. An integer x is \({\varvec{\mathrm {m}}} \)-coprime if and only if it is not divisible by any \({\varvec{\mathrm {m}}} _i\) for \(i\in [|{\varvec{\mathrm {m}}} |]\).

figure aa

Boneh and Franklin [5, Lemma 2.1] showed that knowledge of \(n-1\) integer shares of the factors \(p\) and \(q\) does not give the adversary any meaningful advantage in factoring biprimes from the distribution produced by . Hazay et al. [29, Lemma 4.1] extended this argument to the malicious setting, wherein the adversary is allowed to choose its own shares. A similar lemma must hold for , as a corollary of the fact that its output distribution differs only negligibly from that of .

Lemma 3.7

([5, 29]) Let \(n<{\kappa } \) and let \((\mathcal{A} _1,\mathcal{A} _2)\) be a pair of PPT algorithms. For \((\mathsf {state},\{(p_i,q_i)\}_{i\in [n-1]})\leftarrow \mathcal{A} _1(1^{\kappa },1^n)\), let \(N\) be a biprime sampled by running . If \(\mathcal{A} _2(\mathsf {state},N)\) outputs the factors of \(N\) with probability at least \(\smash {1/{\kappa } ^d}\), then there exists an expected-polynomial-time algorithm \(\mathcal{B} \) that succeeds with probability at least \(1/2^4n^3{\kappa } ^d-\mathsf {negl}({\kappa })\) in the experiment .

Multiparty functionality. Our ideal functionality is a natural embedding of in a multiparty functionality: it receives inputs \(\{(p_i,q_i)\}_{i\in {{\varvec{\mathrm {P}}}^*}}\) from the adversary and runs a single iteration of with these inputs when invoked. It either outputs the corresponding modulus \(N:=p\cdot q\) if it is valid, or indicates that a sampling failure has occurred. Running a single iteration of per invocation of enables significant freedom in the use of , because it can be composed in different ways to tune the trade-off between resource usage and execution time. It also simplifies the analysis of the protocol that realizes , because the analysis is made independent of the success rate of the sampling procedure.

The functionality may not deliver \(N\) to the honest parties for one of two reasons: either failed to sample a biprime, or the adversary caused the computation to abort. In either case, the honest parties are informed of the cause of the failure, and consequently the adversary is unable to conflate the two cases. This is essentially the standard notion of security with abort, applied to the multiparty computation of the algorithm. In both cases, the \(p\) and \(q\) output by are given to the adversary. This leakage simplifies our proof considerably, and we consider it benign, since the honest parties never receive (and therefore cannot possibly use) \(N\).

figure ap

4 The Distributed Biprime-Sampling Protocol

In this section, we present the distributed biprime-sampling protocol , with which we realize . We begin with a high-level overview, and then in Sect. 4.2, we formally define the two ideal functionalities on which our protocol relies, after which in Sect. 4.3 we give the protocol itself. In Sect. 4.4, we present proof sketches of semi-honest and malicious security.

4.1 High-Level Overview

As described in the Introduction, our protocol derives from that of Boneh and Franklin [5], the main technical differences relative to other recent Boneh–Franklin derivatives [23, 29] being the modularity with which it is described and proven, and the use of CRT-based sampling. Our protocol has three main phases, which we now describe in sequence.

Candidate Sieving. In the first phase of our protocol, the parties jointly sample two \({\kappa } \)-bit candidate primes \(p\) and \(q\) without any small factors, and multiply them to learn their product \(N\). Our protocol achieves these two tasks in an integrated way, thanks to the .

Consider a prime \(m\) and a set of shares \(x_i\) for \(i\in [n]\) over the field \({\mathbb {Z}}_m\). As in the description of , let a and b be defined such that \(a\cdot b\equiv 1\pmod {m}\), and let M be an integer. Observe that if m divides M, then

$$\begin{aligned} \sum \limits _{i\in [n]}x_i\not \equiv 0\pmod {m}{\quad }\implies {\quad } \sum \limits _{i\in [n]}a\cdot b\cdot x_i\bmod {M}\not \equiv 0\pmod {m} \end{aligned}$$
(1)

Now consider a vector of coprime integers \({\varvec{\mathrm {m}}} \) of length \(\ell \), and let \(M\) be their product. Let \({\varvec{\mathrm {x}}}\) be a vector, each element secret shared over the fields defined by the corresponding element of \({\varvec{\mathrm {m}}} \), and let \({\varvec{\mathrm {a}}}\) and \({\varvec{\mathrm {b}}}\) be defined as in (i.e., \({\varvec{\mathrm {a}}}_j :=M/{\varvec{\mathrm {m}}} _j\) and \({\varvec{\mathrm {a}}}_j\cdot {\varvec{\mathrm {b}}}_j \equiv 1 \pmod {{\varvec{\mathrm {m}}} _j}\)). We can see that for any \(k,j\in [\ell ]\) such that \(k\ne j\),

$$\begin{aligned} {\varvec{\mathrm {a}}}_j \equiv 0\pmod {{\varvec{\mathrm {m}}} _{k}}{\quad }\implies {\quad }\sum \limits _{i\in [n]} {\varvec{\mathrm {a}}}_j\cdot {\varvec{\mathrm {b}}}_j\cdot {\varvec{\mathrm {x}}}_{i,j}\bmod {M}\equiv 0\pmod {{\varvec{\mathrm {m}}} _k} \end{aligned}$$
(2)

and the conjunction of Eqs. 1 and 2 gives us

$$\begin{aligned} \sum \limits _{j\in [\ell ]}\sum \limits _{i\in [n]}{\varvec{\mathrm {a}}}_j\cdot {\varvec{\mathrm {b}}}_j\cdot {\varvec{\mathrm {x}}}_{i,j}\bmod {M}\equiv \sum \limits _{i\in [n]}{\varvec{\mathrm {x}}}_{i,k} \pmod {{\varvec{\mathrm {m}}} _k} \end{aligned}$$

for all \(k\in [\ell ]\). Observe that this holds regardless of which order we perform the sums in, and regardless of whether the \(\bmod {\,M}\) operation is done at the end, or between the two sums, or not at all.

It follows then that we can sample n shares for an additive secret sharing over the integers of a \({\kappa } \)-bit value x (distributed between 0 and \(n\cdot M\)) by choosing \({\varvec{\mathrm {m}}} \) to be the \(({\kappa },n)\)-near-primorial vector (per Definition 3.4), instructing each party \(\mathcal{P} _i\) for \(i\in [n]\) to pick \({\varvec{\mathrm {x}}}_{i,j}\) locally for \(j\in [\ell ]\) such that \(0\le {\varvec{\mathrm {x}}}_{i,j}<{\varvec{\mathrm {m}}} _j\), and then instructing each party to locally reconstruct , its share of x. It furthermore follows that if the parties can contrive to ensure that

$$\begin{aligned} \sum \limits _{i\in [n]}{\varvec{\mathrm {x}}}_{i,j}\not \equiv 0\pmod {{\varvec{\mathrm {m}}} _j} \end{aligned}$$
(3)

for \(j\in [\ell ]\), then x will not be divisible by any prime in \({\varvec{\mathrm {m}}} \).

Observe next that if the parties sample two shared vectors \({\varvec{\mathrm {p}}}\) and \({\varvec{\mathrm {q}}}\) as above (corresponding to the candidate primes \(p\) and \(q\)) and compute a shared vector \({\varvec{\mathrm {N}}}\) of identical dimension such that

$$\begin{aligned} \sum \limits _{i\in [n]}{\varvec{\mathrm {p}}}_{i,j}\cdot \sum \limits _{i\in [n]}{\varvec{\mathrm {q}}}_{i,j} \equiv \sum \limits _{i\in [n]}{\varvec{\mathrm {N}}}_{i,j}\pmod {{\varvec{\mathrm {m}}} _j} \end{aligned}$$
(4)

for all \(j\in [\ell ]\), then it follows that

and from this it follows that the parties can calculate integer shares of \(N=p\cdot q\) by multiplying \({\varvec{\mathrm {p}}}\) and \({\varvec{\mathrm {q}}}\) together element-wise using a modular-multiplication protocol for linear secret shares, and then locally running on the output to reconstruct \(N\). In fact, our sampling protocol makes use of a special functionality , which samples \({\varvec{\mathrm {p}}}\), \({\varvec{\mathrm {q}}}\), and \({\varvec{\mathrm {N}}}\) simultaneously such that the conditions in Eqs. 3 and 4 hold.

There remains one problem: our vector \({\varvec{\mathrm {m}}} \) was chosen for sampling integer-shared values between 0 and \(n\cdot M\) (with each share no larger than \(M\)), but \(N\) might be as large as \(n^2\cdot M^2\). In order to avoid wrapping during reconstruction of \(N\), we must reconstruct with respect to a larger vector of primes (while continuing to sample with respect to a smaller one). Let \({\varvec{\mathrm {m}}} \) now be of length \({\ell '}\), and let \(\ell \) continue to denote the length of the prefix of \({\varvec{\mathrm {m}}} \) with respect to which sampling is performed. After sampling the initial vectors \({\varvec{\mathrm {p}}}\), \({\varvec{\mathrm {q}}}\), and \({\varvec{\mathrm {N}}}\), each party \(\mathcal{P} _i\) for \(i\in [n]\) must extend \({\varvec{\mathrm {p}}}_{i,*}\) locally to \({\ell '}\) elements, by computing

for \(j\in [\ell +1,{\ell '}]\), and then likewise for \({\varvec{\mathrm {q}}}_{i,*}\).Footnote 7 Finally, the parties must use a modular-multiplication protocol to compute the appropriate extension of \({\varvec{\mathrm {N}}}\); from this extended \({\varvec{\mathrm {N}}}\), they can reconstruct shares of \(N=p\cdot q\). They swap these shares, and thus, each party ends the sieving phase of our protocol with a candidate biprime \(N\) and an integer share of each of its factors, \(p_i\) and \(q_i\).

Each party completes the first phase by performing a local trial division to check if \(N\) is divisible by any prime smaller than some bound B (which is a parameter of the protocol). The purpose of this step is to reduce the number of calls to and thus improve efficiency.

Biprimality Test. The parties jointly execute a biprimality test, where every party inputs the candidate \(N\) and its shares \(p_i\) and \(q_i\), and receives back a biprimality indicator. This phase essentially comprises a single call to a functionality , which allows an adversary to force spurious negative results, but never returns false positive results. Though this phase is simple, much of the subtlety of our proof concentrates here: we show via a reduction to factoring that cheating parties have a negligible chance to pass the biprimality test if they provide wrong inputs. This eliminates the need to authenticate the inputs in any way.

Consistency Check. To achieve malicious security, the parties must ensure that none among them cheated during the previous stages in a way that might influence the result of the computation. This is what we have previously termed the retroactive consistency check. If the biprimality test indicated that \(N\) is not a biprime, then the parties use a special interface of to reveal the shares they used during the protocol, and then they verify locally and independently that \(p\) and \(q\) are not both primes. If the biprimality test indicated that \(N\) is a biprime, then the parties run a secure test (again via a special interface of ) to ensure that length extensions of \({\varvec{\mathrm {p}}}\) and \({\varvec{\mathrm {q}}}\) were performed honestly. To achieve semi-honest security, this phase is unnecessary, and the protocol can end with the biprimality test.

4.2 Ideal Functionalities Used in the Protocol

Augmented Multiparty Multiplier. The augmented multiplier functionality (Functionality 4.1) is a reactive functionality that operates in multiple phases and stores internal state across calls. It is meant to help in manipulating CRT-form secret shares, and to enforce correct reuse of a set of shares across multiple operations. It contains five basic interfaces.

  • The \(\texttt {sample}\) interface allows the parties to sample shares of nonzero multiplication triplets over small primes. That is, given a prime \(m\), the functionality receives a triplet \((x_i,y_i,z_i)\) from every corrupted party \(\mathcal{P} _i\), and then samples a triplet \((x_j,y_j,z_j)\leftarrow {\mathbb {Z}}^3_m\) for every honest \(\mathcal{P} _j\) conditioned on

    $$\begin{aligned} \sum \limits _{i\in [n]}z_i\equiv \sum \limits _{i\in [n]}x_i\cdot \sum \limits _{i\in [n]}y_i \not \equiv 0\pmod {m} \end{aligned}$$

    In the context of , this is used to sample CRT-shares of \(p\) and \(q\).

  • The \(\texttt {input}\) and \(\texttt {multiply}\) interfaces, taken together, allow the parties to load shares (with respect to some small prime modulus \(m\)) into the functionality’s memory, and later perform modular multiplication on two sets of shares that are associated with the same modulus. That is, given a prime \(m\), each party \(\mathcal{P} _i\) inputs \(x_i\) and, independently, \(y_i\), and when the parties request a product, the functionality samples a share of z from \({\mathbb {Z}}_m\) for each party subject to

    $$\begin{aligned} \sum \limits _{i\in [n]}z_i\equiv \sum \limits _{i\in [n]}x_i\cdot \sum \limits _{i\in [n]}y_i\pmod {m} \end{aligned}$$

    In the context of , this interface is used to perform length-extension on CRT-shares of \(p\) and \(q\).

  • The \(\texttt {check}\) interface allows the parties to securely compute a predicate over the set of stored values. In the context of , this is used to check that the CRT-share extension of \(p\) and \(q\) has been performed correctly, when \(N\) is a biprime.

  • The \(\texttt {open}\) interface allows the parties to retroactively reveal their inputs to one another. In the context of , this is used to verify the sampling procedure and biprimality test when \(N\) is not a biprime.

These five interfaces suffice for the malicious version of the protocol, and the first three alone suffice for the semi-honest version. We make a final adjustment, which leads to a substantial efficiency improvement in the protocol with which we realize (which we describe in Appendix B). Specifically, we give the adversary an interface by which it can request that any stored value be leaked to itself, and by which it can (arbitrarily) determine the output of any call to the \(\texttt {sample}\) or \(\texttt {multiply}\) interfaces. However, if the adversary uses this interface, the functionality remembers, and informs the honest parties by aborting when the \(\texttt {check}\) or \(\texttt {open}\) interfaces is used.

figure bg

Biprimality Test.   The biprimality-test functionality (Functionality 4.2) abstracts the behavior of the biprimality test of Boneh and Franklin [5]. The functionality receives from each party a candidate biprime \(N\), along with shares of its factors \(p\) and \(q\). It checks whether \(p\) and \(q\) are primes and whether \(N=p\cdot q\). The adversary is given an additional interface, by which it can ask the functionality to leak the honest parties’ inputs, but when this interface is used then the functionality reports to the honest parties that \(N\) is not a biprime, even if it is one.

figure bh

Realizations. In Appendix B, we discuss a protocol to realize , and in Sect. 5, we propose a protocol to realize . Both make use of generic MPC, but in such a way that no generic MPC is required unless \(N\) is a biprime.

4.3 The Protocol Itself

We refer the reader back to Sect. 4.1 for an overview of our protocol. We have mentioned that it requires a vector of coprime values, which is prefixed by the \(({\kappa },n)\)-near-primorial vector. We now give this vector a precise definition. Note that the efficiency of our protocol relies upon this vector, because we use its contents to sieve candidate primes. Since smaller numbers are more likely to be factors for the candidate primes, we choose the largest allowable set of the smallest sequential primes.

Definition 4.3

(\(({\kappa },n)\)-Compatible Parameter Set) Let \({\ell '}\) be the smallest number such that the \({\ell '}^\text {th}\) primorial number is greater than \(2^{2{\kappa }-1}\), and let \({\varvec{\mathrm {m}}} \) be a vector of length \({\ell '}\) such that \({\varvec{\mathrm {m}}} _1=4\) and \({\varvec{\mathrm {m}}} _2,\ldots ,{\varvec{\mathrm {m}}} _{\ell '}\) are the odd factors of the \({\ell '}^\text {th}\) primorial number, in ascending order. \(({\varvec{\mathrm {m}}},{\ell '},\ell ,M)\) is the \(({\kappa },n)\)-compatible parameter set if \(\ell < {\ell '}\) and the prefix of \({\varvec{\mathrm {m}}} \) of length \(\ell \) is the \(({\kappa }, n)\)-near-primorial vector per Definition 3.4, and if \(M\) is the product of this prefix.

figure bk
figure pf
figure pg

4.4 Security Sketches

We now informally argue that realizes in the semi-honest and malicious settings. We give a full proof for the malicious setting in Appendix C.

Theorem 4.5

The protocol perfectly UC-realizes in the ,-hybrid model against a semi-honest adversary that statically corrupts up to \(n-1\) parties.

Proof Sketch

In lieu of arguing for the correctness of our protocol, we refer the reader to the explanation in Sect. 4.1 and focus here on the strategy of a simulator \(\mathcal{S} \) against a semi-honest adversary \(\mathcal{A} \) who corrupts the parties indexed by \({{\varvec{\mathrm {P}}}^*} \). \(\mathcal S\) forwards all messages between \(\mathcal{A} \) and the environment faithfully.

In Step 1 of , for each \(j\in [2,\ell ]\), \(\mathcal S\) receives the \(\texttt {sample}\) instruction with modulus \({\varvec{\mathrm {m}}} _j\) on behalf of from all parties indexed by \({{\varvec{\mathrm {P}}}^*} \). For each j, it then samples \(({\varvec{\mathrm {p}}}_{i,j},{\varvec{\mathrm {q}}}_{i,j},{\varvec{\mathrm {N}}}_{i,j})\leftarrow {\mathbb {Z}}^3_{{\varvec{\mathrm {m}}} _j}\) uniformly for \(i\in {{\varvec{\mathrm {P}}}^*} \), and returns each triple to the appropriate party.

Step 2 involves no interaction on the part of the parties, but it is at this point that \(\mathcal S\) computes \(p_i\) and \(q_i\) for \(i\in {{\varvec{\mathrm {P}}}^*} \), in the same way that the parties themselves do. Note that since \({\varvec{\mathrm {p}}}_{*,1}\) and \({\varvec{\mathrm {q}}}_{*,1}\) are deterministically chosen, they are known to \(\mathcal S\). The simulator then sends these shares to via the functionality’s \(\texttt {adv-input}\) interface and receives in return either a biprime \(N\), or two factors \(p\) and \(q\) such that \(N:=p\cdot q\) is not a biprime. Regardless, it instructs to \(\texttt {proceed}\).

In Step 3 of , \(\mathcal S\) receives two \(\texttt {input}\) instructions from each corrupted party for each \(j\in [\ell +1,{\ell '}]\) on behalf of , and confirms receipt as would. Subsequently, for each \(j\in [\ell +1,{\ell '}]\), the corrupt parties all send a \(\texttt {multiply}\) instruction, and then \(\mathcal S\) samples \({\varvec{\mathrm {N}}}_{i,j}\leftarrow {\mathbb {Z}}_{{\varvec{\mathrm {m}}} _j}\) for \(i\in [n]\) subject to

$$\begin{aligned} \sum _{i\in [n]} {\varvec{\mathrm {N}}}_{i,j} \equiv N\pmod {{\varvec{\mathrm {m}}} _j} \end{aligned}$$

and returns each share to the matching corrupt party.

In Step 4 of , for every \(j\in [{\ell '}]\), every corrupt party \(\mathcal{P} _{i'}\) for \(i'\in {{\varvec{\mathrm {P}}}^*} \), and every honest party \(\mathcal{P} _i\) for \(i\in [n]{\setminus }{{\varvec{\mathrm {P}}}^*} \), \(\mathcal S\) sends \({\varvec{\mathrm {N}}}_{i,j}\) to \(\mathcal{P} _{i'}\) on behalf of \(\mathcal{P} _i\), and receives \({\varvec{\mathrm {N}}}_{i',j}\) (which it already knows) in reply.

To simulate the final steps of , \(\mathcal S\) tries to divide \(N\) by all primes smaller than B. If it succeeds, then the protocol is complete. Otherwise, it receives \(\texttt {check-}\texttt {biprimality}\) from all of the corrupt parties on behalf of , and replies with \(\texttt {biprime}\) or \(\texttt {not-biprime}\) as appropriate. It can be verified by inspection that the view of the environment is identically distributed in the ideal-world experiment containing \(\mathcal S\) and honest parties that interact with , and the real-world experiment containing \(\mathcal A\) and parties running .

Theorem 4.6

If factoring biprimes sampled by is hard, then UC-realizes in the -hybrid model against a malicious PPT adversary that statically corrupts up to \(n-1\) parties.

Proof Sketch

We observe that if the adversary simply follows the specification of the protocol and does not cheat in its inputs to or , then the simulator can follow the same strategy as in the semi-honest case. At any point, if the adversary deviates from the protocol, the simulator requests to reveal all honest parties’ shares, and thereafter the simulator uses them by effectively running the code of the honest parties. This matches the adversary’s view in the real protocol as far as the distribution of the honest parties’ shares is concerned.

It remains to be argued that any deviation from the protocol specification will also result in an abort in the real world with honest parties and will additionally be recognized by the honest parties as an adversarially induced cheat (as opposed to a statistical sampling failure). Note that the honest parties must only detect cheating when \(N\) is truly a biprime and the adversary has sabotaged a successful candidate; if \(N\) is not a biprime and would have been rejected anyway, then cheat detection is unimportant. We analyze all possible cases where the adversary deviates from the protocol below. Let \(N\) be defined as the value implied by parties’ sampled shares in Step 1 of .

Case 1: \(N\) is a non-biprime and reconstructed correctly. In this case, will always reject \(N\) as there exist no satisfying inputs (i.e., there are no two prime factors \(p,q\) such that \(p\cdot q=N\)).

Case 2: \(N\) is a non-biprime and reconstructed incorrectly as \(N'\). If by fluke \(N'\) happens to be a biprime, then the incorrect reconstruction will be caught by the explicit secure predicate check during the consistency-check phase. If \(N'\) is a non-biprime, then the argument from the previous case applies.

Case 3: \(N\) is a biprime and reconstructed correctly. If consistent inputs are used for the biprimality test and nobody cheats, the candidate \(N\) is successfully accepted (this case essentially corresponds to the semi-honest case). Otherwise, if inconsistent inputs are used for the biprimality test, one of the following events will occur:

  • rejects this candidate. In this case, all parties reveal their shares of \(p\) and \(q\) to one another (with guaranteed correctness via ) and locally test their primality. This will reveal that \(N\) was a biprime and that must have been supplied with inconsistent inputs, implying that some party has cheated.

  • accepts this candidate. This case occurs with negligible probability (assuming factoring is hard). Because \(N\) only has two factors, there is exactly one pair of inputs that the adversary can supply to to induce this scenario, apart from the pair specified by the protocol. In our full proof (see Appendix C) we show that finding this alternative pair of satisfying inputs implies factoring \(N\). We are careful to rely on the hardness of factoring only in this case, where by premise \(N\) is a biprime with \({\kappa } \)-bit factors (i.e., an instance of the factoring problem).

Case 4: \(N\) is a biprime and reconstructed incorrectly as \(N'\). If \(N'\) is a biprime then the incorrect reconstruction will be caught during the consistency-check phase, just as when \(N\) is a biprime. If \(N'\) is a non-biprime, then it will be rejected by , inducing all parties to reveal their shares and find that their shares do not in fact reconstruct to \(N'\), with the implication that some party has cheated.

Thus, the adversary is always caught when trying to sabotage a true biprime, and it can never sneak a non-biprime past the consistency check. Because the real-world protocol always aborts in the case of cheating, it is indistinguishable from the simulation described above, assuming that factoring is hard. \(\square \)

5 Distributed Biprimality Testing

In this section, we present protocols realizing . In Sect. 5.1, we discuss the semi-honest setting, and in Sect. 5.2, the malicious setting.

5.1 The Semi-Honest Setting

In the semi-honest setting, can be realized by the biprimality-testing protocol of Boneh and Franklin [5]. Loosely speaking, the Boneh–Franklin protocol is a variant of the Miller–Rabin test: for a randomly chosen \(\gamma \in {\mathbb {Z}}^*_N\) with Jacobi symbol 1, it checks whether \(\gamma ^{(N- p- q+1)/4} \equiv \pm 1 \pmod {N}\) (recall that \(\varphi (N)=N- p- q+1\)). A biprime will always pass this test, but non-biprimes may yield a false positive with probability 1/2. The test is repeated \({s} \) times (either sequentially or concurrently) in order to bound the probability of proceeding with a false positive to \(2^{-{s}}\) (where \({s} \) is the statistical security parameter).

The above test filters out all non-biprimes except those with factors of the form \(p=a_1^{b_1}\) and \(q=a_2^{b_2}\), with \(q\equiv 1 \pmod {a_1^{b_1-1}}\). This final class of non-biprimes is filtered by securely sampling \(r\leftarrow {\mathbb {Z}}_N\), computing \(z:=r\cdot (p+q-1)\), and then testing whether \(\gcd (z,N)=1\).Footnote 8 Boneh and Franklin suggest that the secure sampling of r and the computation of z can be done via generic MPC; we provide a functionality (see Appendix A.2) that is adequate for the task, but note that other strategies exist: for example, Frederiksen et al. use a bespoke protocol, which could be further optimized by performing its multiparty multiplication operations in CRT form, as we have outlined in this work. As we report in Sect. 6, this final GCD test does not represent a substantial fraction of the overall cost in the semi-honest setting, even if it is instantiated generically, and so the impact of such optimizations would be minimal. Regardless, we note that the GCD test does induce some false negatives (modeled by ) and refer the reader to Boneh and Franklin [5, Section 4.1] for a more comprehensive discussion. The following lemma is immediately implied by their work.

Lemma 5.1

The biprimality-testing protocol described by Boneh and Franklin [5] UC-realizes with statistical security in the -hybrid model against a static, semi-honest adversary who corrupts up to \(n-1\) parties.

5.2 The Malicious Setting

Unlike a semi-honest adversary, we permit a malicious adversary to force a true biprime to fail our biprimality test and detect such behavior using independent mechanisms in the protocol. However, we must ensure that a non-biprime can never pass the test with more than negligible probability. To achieve this, we use a derivative of the biprimality-testing protocol of Frederiksen et al. [23]. Our protocol takes essentially the same high-level approach as theirs, but the complexity of our protocol is reduced because we consider multiple soundness errors jointly instead of independently. Furthermore, by careful reordering and the right choice of functionalities, we eliminate the non-black-box use of commitments, as well as an expensive, redundant multiparty multiplication over \(2{\kappa } \)-bit inputs.

Our protocol essentially comprises a randomized version of the semi-honest Boneh–Franklin test described previously, followed by a Schnorr-like protocol to verify that the test was performed correctly. The soundness error of the underlying biprimality test is compounded by the Schnorr-like protocol’s soundness error to yield a combined error of 3/4, which implies that the test must repeated \({s} \cdot \log _{4/3}(2)<2.5{s} \) times in order to achieve a soundness error no greater than \(2^{-{s}}\) overall. While this is sufficient to ensure the test itself is carried out honestly, it does not ensure the correct inputs are used. Consequently, generic MPC is used to verify the relationship between the messages involved in the Schnorr-like protocol and the true candidate given by \(N\) and shares of its factors. As a side effect, this generic computation samples \(r\leftarrow {\mathbb {Z}}_N\) and outputs \(z=r\cdot (p+q-1)\bmod {N}\) so that the GCD test can afterward be run locally by each party.

Our protocol makes use of a number of subfunctionalities, all of which are standard and described in Appendix A.2. Namely, we use a coin-tossing functionality to uniformly sample an element from some set, the one-to-many commitment functionality , the generic MPC functionality over committed inputs , and the integer-sharing-of-zero functionality . In addition, the protocol uses the algorithm (Algorithm 5.3).

figure cu
figure pq
figure pr

Below we present the algorithm that is used for the GCD test. The inputs are the candidate biprime \(N\), an integer \(M\) (the bound on the shares’ size), a bit-vector \({\varvec{\mathrm {c}}}\) of length \(2.5{s} \), and for each \(i\in [n]\) a tuple consisting of the shares \(p_i\) and \(q_i\) with the Schnorr-like messages \({\varvec{\mathrm {\tau }}}_{i,*}\) and \({\varvec{\mathrm {\zeta }}}_{i,*}\) generated by \(\mathcal{P} _i\). The algorithm verifies that all input values are compatible and returns \(z=r\cdot (p+q-1) \bmod N\) for a random r.

figure cv

Theorem 5.4

The protocol statistically UC-realizes in the -hybrid model against a malicious adversary that statically corrupts up to \(n-1\) parties.

Proof Sketch

Our simulator \(\mathcal{S} \) for receives \(N\) as common input. Let \({{\varvec{\mathrm {P}}}^*} \) and be vectors indexing the corrupt and honest parties, respectively. To simulate Steps 1 through 3 of , \(\mathcal S\) simply behaves as , , and would in its interactions with the corrupt parties on their behalf, remembering the values received and transmitted. Before continuing, \(\mathcal S\) submits the corrupted parties’ shares of \(p\) and \(q\) to on their behalf. In response, either informs \(\mathcal S\) that \(N\) is a biprime or leaks the honest parties’ shares. In Step 4, \(\mathcal S\) again behaves exactly as would. During the remainder of the protocol, the simulator must follow one of two different strategies, conditioned on whether or not \(N\) is a biprime. We will show that both strategies lead to a simulation that is statistically indistinguishable from the real-world experiment.

  • If reported that \(N\) is a biprime, then we know by the specification of that the corrupt parties committed to correct shares of \(p\) and \(q\) in Step 1 of . Boneh and Franklin [5, Proof of Lemma 4.2] showed that the value (i.e., sign) of the right-hand side of the equality in Step 7 is predictable and related to the value of \({\varvec{\mathrm {\gamma }}}_j\). We refer to them for a precise description and proof. If without loss of generality we take that value to be 1, then \(\mathcal S\) can simulate iteration j of Steps 6 and 7 as follows. First, \(\mathcal S\) computes \(\hat{{\varvec{\mathrm {\chi }}}}_{i,j}\) for \(i\in {{\varvec{\mathrm {P}}}^*} \) to be the corrupt parties’ ideal values of \({\varvec{\mathrm {\chi }}}_{i,j}\) as defined in Step 4 of . Then, \(\mathcal S\) samples \({\varvec{\mathrm {\chi }}}_{i,j}\leftarrow {\mathbb {Z}}^*_N\) uniformly for subject to

    and simulates Step 6 by releasing \({\varvec{\mathrm {\chi }}}_{i,j}\) for to the corrupt parties on behalf of . These values are statistically close to their counterparts in the real protocol. Finally, \(\mathcal S\) simulates Step 7 by running the test for itself and sending the \(\texttt {cheat}\) command to on failure. Given the information now known to \(\mathcal S\), Steps 8 through 11 of can be simulated in a manner similar to the simulation of a common Schnorr protocol: \(\mathcal S\) simply chooses \({\varvec{\mathrm {\zeta }}}_{i,*} \leftarrow {\mathbb {Z}}^{2.5{s}}_{M\cdot 2^{{s} + 1}}\) uniformly for , fixes \({\varvec{\mathrm {c}}}\leftarrow \{0,1\}^{2.5{s}}\) ahead of time, and then works backward via the equation in Step 11 to compute the values of \({\varvec{\mathrm {\alpha }}}_{i,*}\) for that it must send on behalf of the honest parties in Step 8. These values are statistically close to their counterparts in the real protocol. \(\mathcal S\) finally simulates the remaining steps of by checking the predicate itself (since the final GCD test is purely local, no action need be taken by \(\mathcal S\)). If at any point after Step 4 the corrupt parties have cheated (i.e., sent an unexpected value or violated the predicate), then \(\mathcal S\) sends the \(\texttt {cheat}\) command to . Otherwise, it sends the \(\texttt {proceed}\) command to , completing the simulation.

  • If reported that \(N\) is not a biprime (which may indicate that the corrupt parties supplied incorrect shares of \(p\) or \(q\)), then it also leaked the honest parties’ shares of \(p\) and \(q\) to \(\mathcal S\). Thus, \(\mathcal S\) can simulate Steps 4 through 13 of by running the honest parties’ code on their behalf. In all instances of the ideal-world experiment, the honest parties report to the environment that \(N\) is a non-biprime. Thus, we need only prove that there is no strategy by which the corrupt parties can successfully convince the honest parties that \(N\) is a biprime in the real world.

    In order to get away with such a real-world cheat, the adversary must cheat in every iteration j of Steps 4 through 6 for which

    $$\begin{aligned} {\varvec{\mathrm {\gamma }}}_j^{(N-p-q)/4}\not \equiv \pm 1\pmod {N} \end{aligned}$$

    Specifically, in every such iteration j, the corrupt parties must contrive to send values \({\varvec{\mathrm {\chi }}}_{i,j}\) for \(i\in {{\varvec{\mathrm {P}}}^*} \) such that

    $$\begin{aligned} {\varvec{\mathrm {\gamma }}}_j^{(N - 5)/4} \cdot \prod \limits _{i\in [n]} {\varvec{\mathrm {\chi }}}_{i,j} \equiv {\varvec{\mathrm {\gamma }}}_j^{(N-p-q)/4 + {\varvec{\mathrm {\Delta }}}_{1,j}} \equiv \pm 1\pmod {N} \end{aligned}$$

    for some nonzero offset value \({\varvec{\mathrm {\Delta }}}_{1,j}\). We can define a similar offset \({\varvec{\mathrm {\Delta }}}_{2,j}\) for the corrupt parties’ transmitted values of \({\varvec{\mathrm {\alpha }}}_{i,j}\), relative to the values of \({\varvec{\mathrm {\tau }}}_{i,j}\) committed in Step 1:

    $$\begin{aligned} {\varvec{\mathrm {\gamma }}}_j^{{\varvec{\mathrm {\Delta }}}_{2,j}}\cdot \prod \limits _{i\in [n]} {\varvec{\mathrm {\alpha }}}_{i,j} \equiv \prod \limits _{i\in [n]}{\varvec{\mathrm {\gamma }}}_j^{{\varvec{\mathrm {\tau }}}_{i,j}} \pmod {N} \end{aligned}$$

    Since we have presupposed that the protocol outputs \(\texttt {biprime}\), we know that the corrupt parties must transmit correctly calculated values of \({\varvec{\mathrm {\zeta }}}_{i,*}\) in Step 10 of , or else Step 12 would output \(\texttt {non-biprime}\) when these values are checked by the predicate. It follows from this fact and from the equation in Step 11 that \({\varvec{\mathrm {\Delta }}}_{2,j} \equiv {\varvec{\mathrm {c}}}_j\cdot {\varvec{\mathrm {\Delta }}}_{1,j} \pmod {\varphi (N)}\), where \(\varphi (\cdot )\) is Euler’s totient function. However, both \({\varvec{\mathrm {\Delta }}}_{1,*}\) and \({\varvec{\mathrm {\Delta }}}_{2,*}\) are fixed before \({\varvec{\mathrm {c}}}\) is revealed to the corrupt parties, and so the adversary can succeed in this cheat with probability at most 1/2 for any individual iteration j. Per Boneh and Franklin [5, Lemma 4.1], a particular iteration j of Steps 4 through 6 of produces a false positive result with probability at most 1/2 if the adversary behaves honestly. If we assume that the adversary cheats always and only when a false positive would not have been produced by honest behavior, then the total probability of an adversary producing a positive outcome in the \(j\)th iteration of Steps 4 through 6 is upper-bounded by 3/4. The probability that an adversary succeeds over all \(2.5{s} \) iterations is therefore at most \((3/4)^{2.5{s}}<2^{-{s}}\). Thus, the adversary has a negligible chance to force the acceptance of a non-biprime in the real world, and the distribution of outcomes produced by \(\mathcal S\) is statistically indistinguishable from the real-world distribution. \(\square \)

6 Efficiency Analysis

In this section, we give both an asymptotic and a closed-form concrete cost analysis of our protocol, with both semi-honest and malicious security. We begin by addressing the success probability of our ideal functionality , as determined by analysis of the sampling function that it uses. We also discuss various strategies for composing invocations of to amplify the probability that a biprime is successfully produced. After this, we analyze the costs of the protocols realizing and in Sect. 6.2, and in Sect. 6.3, we compose those costs to give an overall cost for each invocation of . In Sect. 6.4, we discuss a compositional strategy that leads to constant or expected-constant rounds overall, and calculate the precise number of rounds required. Finally, in Sect. 6.5, we provide a performance comparison to the protocol of Frederiksen et al. [23].

6.1 Per-Instance Success Probability

By construction, the success probability of is identical to that of . To bound the success probability of , it suffices to determine the probability that a randomly chosen value is prime, conditioned on that value having \({\varvec{\mathrm {m}}} \)-coprimality (per Definition 3.5) relative to the \(({\kappa },n)\)-near-primorial vector \({\varvec{\mathrm {m}}} \) of length \(\ell \). We begin by bounding the probability of finding a prime from below, relative to \(\max ({\varvec{\mathrm {m}}})\), the largest value in \({\varvec{\mathrm {m}}} \).

Lemma 6.1

([5]) Given a \(({\kappa },n)\)-near-primorial vector \({\varvec{\mathrm {m}}} \),

$$\begin{aligned} {\mathrm {Pr}}\left[ \,p \text { is prime} ~|~ p\leftarrow {\mathbb {Z}}_{2^{\kappa }}\text { s.t. }p\text { is }{\varvec{\mathrm {m}}} \text {-coprime}\right] \ge 2.57 \cdot \frac{\ln \max ({\varvec{\mathrm {m}}})}{{\kappa }} \end{aligned}$$

Observe that this is a concrete lower bound. Next, in the interest of asymptotic analysis, we bound the value of the maximum element in \({\varvec{\mathrm {m}}} \). We first adapt a lemma from Rosser and Schoenfeld [47] to bound \(\max ({\varvec{\mathrm {m}}})\) with respect to the product of the elements of \({\varvec{\mathrm {m}}} \), and we then use this to construct a bound with respect to \({\kappa } \).

Lemma 6.2

([47], Theorem 4) Given a \(({\kappa },n)\)-near-primorial vector \({\varvec{\mathrm {m}}} \) and its product \(M\), it holds that \(\max ({\varvec{\mathrm {m}}})\in \Theta (\log M)\).

Lemma 6.3

Given a \(({\kappa },n)\)-near-primorial vector \({\varvec{\mathrm {m}}}\), it holds that \(\max ({\varvec{\mathrm {m}}}) \in \Omega ({\kappa })\).

Proof

Let \(M\) be the product of \({\varvec{\mathrm {m}}} \). By Definition 3.4, M is the largest integer such that M/2 is a primorial and \(M < 2^{{\kappa }- \log n}\). From these facts, the prime number theorem gives us \(M\in \Omega (2^{{\kappa }- \log n - \log {\kappa }})\). Combining this with Lemma 6.2 yields \(\max ({\varvec{\mathrm {m}}})\in \Omega ({\kappa }- \log n - \log {\kappa })\) and finally, Lemma 3.7 constrains \(2\le n<{\kappa } \), which yields \(\max ({\varvec{\mathrm {m}}})\in \Omega ({\kappa })\). \(\square \)

Combining Lemmas 6.1 and 6.3 and considering that must sample two primes simultaneously (but independently) yields an asymptotic figure for the success probability of . Since this governs the number of times must be invoked in order to generate a biprime, we refer to it as our sampling-efficiency theorem.

Theorem 6.4

(Sampling-efficiency theorem) For any strict subset \({{\varvec{\mathrm {P}}}^*} \subset [n]\) and any \((p_i,q_i)\in {\mathbb {Z}}^2_{2^{\kappa }}\) for \(i\in {{\varvec{\mathrm {P}}}^*} \), samples a biprime with probability \(\Omega (\log ^2 {\kappa }/{\kappa } ^2)\).

In order to understand the concrete efficiency of our approach, we determined the unique \(({\kappa },n)\)-near-primorial vectors corresponding to several common RSA security parameter values and then used Lemma 6.1 to derive concrete success probabilities. These are reported in Table 2. For completeness, we also report the asymptotic size of the \(({\kappa },n)\)-near-primorial vector; this can be derived by combining Lemma 6.2 with the following lemma:

Lemma 6.5

([47], Theorem 2) Given a \(({\kappa },n)\)-near-primorial vector \({\varvec{\mathrm {m}}} \) of length \(\ell \), it holds that \(\ell \in \Theta \left( \max ({\varvec{\mathrm {m}}})/\log \max ({\varvec{\mathrm {m}}})\right) \).

Table 2 CRT-form Sampling Parameters, along with per-iteration success probabilities. Recall that biprimes produced are of size \(2{\kappa } \). \({\varvec{\mathrm {m}}} \) is the \(({\kappa },n)\)-near-primorial vector, with \(\ell =|{\varvec{\mathrm {m}}} |\). \({\ell '}\) is the length of the extended vector required by our protocol, as described in Definition 4.3. Note that the number of parties n has no concrete effect on these values

Compositional Strategies. As an immediate corollary to Theorem 6.4, the expected number of invocations of required to produce a biprime is in \(O({\kappa } ^2/\log ^2 {\kappa })\). Concretely, this corresponds to 3607 invocations when \({\kappa } =1024\), or 11,832 invocations when \({\kappa } =2048\). As an alternative to sequential invocation, can be invoked concurrently in batches tuned for a desired probability of success. \(O({\rho }/(\log {\kappa }-\log ({\kappa } ^2-\log ^2{\kappa })))\) concurrent invocations are required to sample a biprime with probability at least \(1-2^{-{\rho }}\). Concretely, with \({\rho } =40\), this corresponds to roughly 100,000 invocations for \({\kappa } =1024\), or 330,000 invocations for \({\kappa } =2048\). Two sequential batches of concurrent invocations are required in expectation if \({\rho } =1\), with roughly 2500 invocations of per batch for \({\kappa } =1024\), or 8200 invocations per batch for \({\kappa } =2048\).

6.2 The Cost of Instantiating and

Before we can discuss the concrete costs of our main sampling protocol, we must determine the costs of instantiating the functionalities it uses. Since was specifically formulated to model the biprimality-testing protocol of Boneh and Franklin [5], it is natural to assume we use that protocol (or our malicious-secure extension) to instantiate it. On the other hand, in both the semi-honest and malicious settings, many sensible approaches exist for instantiating . We choose to base our instantiation on oblivious transfer in both settings. Although OT-based multiplication is not the most bandwidth-efficient option, it compares favorably to alternatives in the real world [19, 20], and OT can be built assuming only the hardness of factoring, if desired [21]. We also assume certain reasonable practical concessions are made. For example, we assume that and are both implemented via a Random Oracle. We note that under these instantiations, committing a value requires \(2{\lambda } \) bits to be broadcast,Footnote 9 and requires no communication at all. We also assume requires no communication: a trivial modification of the Pseudorandom Zero-Sharing protocol of Cramer et al. [17] yields a protocol that realizes against active adversaries with no interaction in the -hybrid model.

Broadcast. It is standard practice in the implementation of MPC protocols (e.g.,  [30, 49, 51]) to use the simple echo broadcast of Goldwasser and Lindell [27] for instantiating broadcast channels. This approach preserves all correctness and privacy guarantees, but only guarantees non-unanimous abort (i.e., each honest party either obtains the correct output or locally aborts, but there is no global agreement on abort). Echo broadcast doubles the round count and adds \((n-1)\cdot {\lambda } \) bits per party per original round to the communication cost, because each party is required to send a hash of the broadcast messages received in one round to all other parties before the next round.

In our setting, we can take the even simpler approach of running the protocol optimistically over point-to-point channels. At the end, every party hashes the entire transcript of broadcast-messages and sends the digest to all other parties. If the digests do not agree, the parties abort; otherwise, they terminate with the output value of the protocol. Therefore, for the sake of calculating concrete costs, we consider the cost of broadcasting a bit to be the same as the cost of transmitting it to all parties (apart from the sender) individually.

Oblivious Transfer. We give concrete efficiency figures assuming that Correlated OT (i.e., OT in which the sender chooses a correlation between two messages, instead of two independent messages) is used in place of standard OT, and assuming that it is instantiated via one of two specific OT-extension protocols. The more efficient of the two is the recently introduced Silent OT-extension protocol of Boyle et al. [6]. When used as a Correlated OT-extension on a correlation from the field \({\mathbb {Z}}_m\), it incurs a cost of \((|m|+1)/2\) bits transmitted per party (averaged over the sender and receiver), over two rounds. However, it requires a variant of the Learning Parity with Noise (LPN) assumption, and it has a large one-time setup cost.

As an alternative, the OT-extension protocol of Keller et al. [35] (hereafter referred to as “KOS OT”) assumes only a base OT functionality, and has a much cheaper one-time setup. When used as a Correlated OT-extension on a correlation from the field \({\mathbb {Z}}_m\), this protocol incurs a cost of \((|m|+{\lambda })/2\) bits transmitted per party (averaged over the sender and receiver) over two rounds. In addition to this cost, the sender must pay an overhead cost for each batch of OTs performed, where a batch may comprise polynomially many individual OTs with an arbitrary mixture of correlation lengths. Since this overhead does not depend on the total number of OTs or the correlation lengths, it can be amortized into irrelevance if the OTs in our protocol can be arranged into a small number of batches. Since this is indeed the case, we ignore the overhead cost for the remainder of our cost analysis. For the sake of analyzing concrete efficiency, we also ignore the one-time setup costs of both OT-extension protocols.

Both OT-extension protocols attain malicious security, but KOS OT has little overhead relative to the best semi-honest protocols, and Silent OT is the most efficient currently known OT protocol of any kind. Consequently, we use them in the semi-honest setting as well.

in the Semi-Honest Setting. In the semi-honest setting, parties can be trusted to reuse inputs when instructed to do so, and the predicate check and input-revelation interfaces of need not be implemented, since will never call them in the semi-honest setting. Consequently, an extremely simple protocol suffices to realize against semi-honest adversaries. When the parties wish to use the \(\texttt {multiply}\) interface with a modulus \(m\), they simply engage in instances of Gilboa’s classic OT-multiplication protocol [24], arranged as per the GMW multiplication paradigm [26] to form a multiparty multiplier. This implies \(2|m|\) oblivious transfers per pair of parties, all with \(|m|\)-bit messages. If Silent OT is used, the total cost is \((n-1)\cdot |m| \cdot (|m| + 1)\) bits transmitted per party (averaged over all parties), over two rounds. If KOS OT is used, the total cost is instead \((n-1)\cdot |m| \cdot (|m| + {\lambda })\) bits. Note that this is substantially worse if \(|m|\) is small.

The \(\texttt {sample}\) interface of can be realized using the same multiplication protocol in a natural way: the parties simply choose random shares of two values and multiply those values together. They multiply their output shares together with another randomly sampled set of shares and then broadcast their shares of this second product. They repeat the whole process if the second product is found to be zero, or otherwise take their shares of the first product as their outputs. Each iteration of this sampling procedure succeeds with probability \((m-1)^3/m^3\). If iterations are run concurrently in batches of size c, then the expected number of batches is \(b=m^3/(m^3-3c\cdot m^2+3c\cdot m-c)\). Given this value b, the expected total cost is \((n-1)\cdot b\cdot c\cdot |m| \cdot (2|m| + 3)\) bits transmitted per party (on average) if Silent OT is used, or \((n-1)\cdot b\cdot c\cdot |m| \cdot (2|m| + 2{\lambda } + 1)\) bits if KOS OT is used. The number of rounds is 5b in expectation.

in the Semi-Honest Setting. To realize in the semi-honest setting, we use the Boneh–Franklin biprimality test [5]. In this protocol, the parties begin by participating in up to \({s} \) iterations of a test in which they each broadcast a value of size \(2{\kappa } \) to all other parties. In the bandwidth-optimal protocol variant, these iterations are sequential. Each has a soundness error of 1/2, and so the expected number of iterations is two if \(N\) is not a biprime, yielding a concrete bandwidth cost for this first step of \(2(n-1)\cdot {s} \cdot {\kappa } \) bits per party if \(N\) is a biprime, or \(4(n-1)\cdot {\kappa } \) bits per party in expectation otherwise. In the round-optimal protocol variant, these iterations are concurrent, and the cost is always \(2(n-1)\cdot {s} \cdot {\kappa } \) bits per party, over one round.

If all iterations of the previous test succeed, then the parties perform the GCD test: they securely multiply two shared values modulo \(N\), and reveal the output. Whereas Boneh and Franklin recommend the BGW generic MPC protocol for this task, we will instead assume that Gilboa’s OT-multiplication protocol is used, in a GMW-like arrangement as previously described, followed by an exchanging of output shares. All shares in one of the two input sets are guaranteed to be smaller than \(2^{k+1}\); if we ensure that parties always play the OT-receiver when using shares from this set as input, then the concrete bandwidth cost for this second step is \((n-1)\cdot ({\kappa } +1) \cdot (2{\kappa } + 1) + 2(n-1)\cdot {\kappa } \) bits transmitted per party, assuming Silent OT is used, or \((n-1)\cdot ({\kappa } +1) \cdot (2{\kappa } + {\lambda }) + 2(n-1)\cdot {\kappa } \) bits if KOS OT is used. In either case, three additional rounds are required.

Instantiating . In the malicious settings, the and protocols both require access to a generic MPC functionality with reusable inputs, which we give as . For the sake of concrete-efficiency figures, we will assume is realized via the Authenticated Garbling protocol of Yang et al. [51]. We make no optimizations, and in particular, do not replace the OT that they use, even though Silent OT might yield a substantial improvement. This protocol has a total cost including preprocessing of

$$\begin{aligned}&(9n - 11 + (4n-4)\cdot {s}/(\log C+1))\cdot C\cdot {\lambda } \\&+ (1-1/n) \cdot I \cdot {\lambda } + (2n-1) \cdot C + \max (I\cdot {\lambda }, C) + I/n + O \end{aligned}$$

bits transmitted per party, on average, where C is the number of AND gates, I is the number of input wires, and O is the number of output wires. Since this equation is quite complicated and gives little insight, we report costs associated with simply in terms of gates and input/output wires, and convert them into bit costs only when calculating the overall total bandwidth cost for . We note that supplying an input (i.e., calling the \(\texttt {commit}\) command of ) to the protocol of Yang et al. requires two rounds, and reconstructing an output (i.e., calling the \(\texttt {compute}\) command) also requires two. We assume that all preprocessing can be run concurrently with other tasks, and thus, it does not contribute any additional rounds.

Using involves converting functions into circuits. The functions we use are easily reduced to a handful of arithmetic operations. We list all non-trivial operations, with costs, in Table 3.

Table 3 Operation costs in AND gates

in the Malicious Setting. The protocol that realizes is complex and involves a number of sub-functionalities that we have not yet introduced. Consequently, we defer our full cost analysis to Appendix B, in which we also describe itself. We note here that the cost of the \(\texttt {multiply}\) command with modulus \(m\) is in \(O(n\cdot (|m|^2+|m|\cdot {s} +2{\lambda }))\) transmitted bits per party if Silent OT is used, or \(O(n\cdot (|m|^2+|m|\cdot {s} +(|m| + 2)\cdot {\lambda }))\) if KOS OT is used, and that the \(\texttt {input}\) command is free if it is not called until immediately before the first associated multiplication. The cost of the \(\texttt {open}\) command is in \(O(n\cdot (|m|^2+|m|\cdot {s}))\) transmitted bits per party. The \(\texttt {sample}\) command has the same expected bandwidth complexity as multiplication. Finally, the complexity of the \(\texttt {check}\) command depends upon the inputs it is given, but broadly, for each input with an associated modulus \(m\), one must pay \({s}/|m|\) times the cost of multiplication, plus a bandwidth cost in \(O(n\cdot {s} ^2/|m|+n\cdot {s} \cdot c)\), where c is the number of times the input was used in a multiplication, plus the cost of using to evaluate a circuit of size with \(O({s} +|m|)\) input wires. In addition to these per input costs, \(\texttt {check}\) uses to evaluate an arbitrary circuit (with no additional inputs), and so costs must be paid proportionate to that circuit’s size.

in the Malicious Setting. In Sect. 5.2, we described a protocol realizing . We now analyze its costs. The Boneh–Franklin Test phase is similar to the first phase of the semi-honest biprimality test, except that messages are committed before they are revealed, they are always decommitted concurrently, and \(2.5{s} \) iterations are required, as opposed to \({s} \). Consequently, this step incurs a cost of \(5(n-1)\cdot {s} \cdot {\kappa } +2(n-1)\cdot {\lambda } \) bits transmitted per party, over two rounds.

This leaves input commitment and consistency check/GCD test phases. The former phase involves only a single commitment by each party. The latter phase is only evaluated if the above test passes, and therefore does not contribute to the cost when \(N\) is not a biprime. To perform the GCD test, the parties each transmit \(2.5{s} \cdot (n-1)\cdot (3{\kappa }-\log _2n+{s} +1)\) bits over two rounds, and in addition, they use to compute a circuit, which is specified by Algorithm 5.3. If for clarity and simplicity we represent the cost of multiplication using the functions from Table 3, then the size of this circuit in AND gates is

and furthermore, it has \(n\cdot (2.5{s} +2)\cdot ({\kappa }-\log _2n)+n\cdot 2.5{s} \cdot ({s} +1)+2n\cdot {\kappa } \) input wiresFootnote 10 and \(2n\cdot {\kappa } \) output wires.

6.3 Putting It All Together

In this section, we will break down the cost of our main protocol in terms of calls to and , and also give the costs associated with the few protocol components that are not interactions with these functionalities. This breakdown (excepting the functionality calls in the consistency check phase) is identical in the malicious and semi-honest settings. We subsequently plug in the individual component costs that we derived in Sect. 6.2 and arrive at predicted concrete cost figures for one instance of our complete protocol. We then use the analysis in Sect. 6.1 to determine the concrete cost of sampling a biprime when our sampling protocol is called sequentially. We discuss alternative composition strategies for achieving constant or expected-constant round counts (and provide an exact round count) in the next section. We begin with a cost breakdown.

  1. 1.

    Candidate Sieving. For each \(j\in [2,\ell ]\), the parties invoke the \(\texttt {sample}\) instruction of using modulus \({\varvec{\mathrm {m}}} _j\). These invocations are concurrent. Following this, for \(j\in [\ell +1,{\ell '}]\), the parties invoke the \(\texttt {input}\) instruction of with modulus \({\varvec{\mathrm {m}}} _j\) twice, and then the \(\texttt {multiply}\) instruction with modulus \({\varvec{\mathrm {m}}} _j\). As discussed in Appendix B.3, the \(\texttt {input}\) instructions are free under this pattern of invocations if we use (Protocol B.7) to realize . We assume the multiplications are done concurrently as well. In addition, every party broadcasts a value in \({\mathbb {Z}}_{{\varvec{\mathrm {m}}} _j}\) for \(j\in [2,{\ell '}]\). This incurs a cost of

    $$(n-1)\cdot \sum \limits _{j\in [2,{\ell '}]}|{\varvec{\mathrm {m}}} _j|$$

    transmitted bits per party, and one additional round.

  2. 2.

    Biprimality Test. The parties send \(\texttt {check-biprimality}\) to at most once. Since our protocol includes local trial division (see Step 5 of ), some protocol instances will skip the biprimality test entirely. However, for the sake of calculating concrete costs, we will assume that this local trial division is not executed. In other words, we assume that the biprimality test is run exactly once per protocol instance, and if local trial division would have rejected a candidate, then the biprimality test certainly fails.

  3. 3.

    Consistency Check. This phase has no cost in the semi-honest setting. In the malicious setting, its cost differs depending on whether the candidate biprime has passed the biprimality test (and local trial division), or failed. In the failure case, the parties send \(\texttt {open}\) to twice with modulus \({\varvec{\mathrm {m}}} _j\) for each \(j\in [2,{\ell '}]\). In the passing case, they instead send \((\texttt {check}, {\textsf {sids}},f)\), where \({\textsf {sids}}\) is the vector of session IDs associated with values sampled by or loaded into in the sieving phase, and f is a predicate specified in our protocol. This circuit representation of f comprises 2n invocations of over the extended vector \({\varvec{\mathrm {m}}} \) of small moduli, 2n comparisons on inputs of size \(2{\kappa } \), two integer sums, each over n elements of \({\kappa }-\log _2n\) bits, one integer multiplication with inputs of length \({\kappa } \), and one equality check over values of length \(2{\kappa } \). We observe that the algorithm can be implemented in the following way: all intermediate operations can be performed over the integers, with a single modular reduction at the end. Because each intermediate product has one multiplicand that is much shorter than the other, we can use the asymmetric modular multiplication method previously described in Sect. 6.2. This circuit requires no additional inputs, relative to the ones supplied by , and its overall gate countFootnote 11 is

Communication Complexity. In order to explore the asymptotic network costs of our protocol in terms of \({\kappa } \), \({s} \), and n, we consider \({\lambda } \) to be in \(O({s})\) for the purposes of this analysis. We also assume \({s} \in O({\kappa })\cap \omega (\log {\kappa })\). We give all our asymptotic figures in terms of data transmitted per party.

Combining the cost breakdown in this section with the asymptotic analysis of CRT sampling parameters in Sect. 6.1, we find that \(O({\kappa }/\log {\kappa })\) invocations of the \(\texttt {sample}\) and \(\texttt {multiply}\) interfaces of are performed during the Candidate Sieving phase of . Let \(({\varvec{\mathrm {m}}},{\ell '},\ell ,M)\) be the \(({\kappa },n)\)-compatible parameter set of , as specified by Definition 4.3. Each \(\texttt {sample}\) and \(\texttt {multiply}\) operation involves a modulus from \({\varvec{\mathrm {m}}} \). Per Lemma 6.2, \(\max ({\varvec{\mathrm {m}}})\in O(\log M)\), and we have from Definition 3.4 that \(M\in O(2^{\kappa })\); thus \(\max ({\varvec{\mathrm {m}}})\in O({\kappa })\). Via Sect. 6.2, this implies that all \(\texttt {multiply}\) and \(\texttt {sample}\) operations have a complexity of \(O(n\cdot \log ^2{\kappa })\) bits transmitted per party in the semi-honest setting, or \(O(n\cdot \log ^2{\kappa } +n\cdot {s} \cdot \log {\kappa })\) in the malicious setting (assuming Silent OT in both cases). The total per-party communication cost of the Sieving phase is therefore \(O(n\cdot {\kappa } \cdot \log {\kappa })\) in the semi-honest setting, or \(O(n\cdot {\kappa } \cdot {s})\) in the malicious setting.

In both the semi-honest and the malicious settings, the communication complexity of a successful biprimality test is dominated by the GCD Test. In the semi-honest case, this check comprises a secure multiplication over \({\kappa } \) bits, so the cost is in \(O(n\cdot {\kappa } ^2)\) bit transmitted per party. In the malicious case, per Sect. 6.2, this check is performed via a circuit with \(O(n\cdot {s} \cdot {\kappa } + {\kappa } ^{\log _23})\) gates,Footnote 12 and per Yang et al. [51], the dominant per-party asymptotic cost of their protocol is in \(O(n\cdot {s} \cdot C/\log C)\), where C is the gate count. Thus, the per-party complexity of a successful biprimality test is

$$\begin{aligned} O\left( \frac{n^2\cdot {s} ^2\cdot {\kappa } + n\cdot {s} \cdot {\kappa } ^{\log _23}}{\log (n\cdot {s} \cdot {\kappa } + {\kappa } ^{\log _23})}\right) \end{aligned}$$

in the malicious case. In both the semi-honest and the malicious settings, failed biprimality tests are unlikely to perform the GCD check,Footnote 13 leaving only the initial testing phase. If we choose the bandwidth-optimal protocol variant in the semi-honest setting, then we can take the communication complexity of a failed biprimality test to be in \(O(n\cdot {\kappa })\). In the malicious setting, it is in \(O(n\cdot {s} \cdot {\kappa })\).

Finally, in the malicious setting only, the consistency check phase is performed. For presumptive biprimes, the cost of this phase is dominated by its generic MPC component, which has \(O(n\cdot {\kappa } ^2)\) gates and, if we assume that Yang et al.’s protocol is used, a total complexity of

$$\begin{aligned} O\left( \frac{n^2\cdot {s} \cdot {\kappa } ^2}{\log n + \log {\kappa }}\right) \end{aligned}$$

per party. For presumptive non-biprimes, the parties invoke the \(\texttt {open}\) interface of a constant number of times for each element of \({\varvec{\mathrm {m}}} \). Reusing our analysis of the sieving phase, we find that the per-party network complexity of this case is \(O(n\cdot {s} \cdot {\kappa })\).

In the case that a biprime is sampled by iterating sequentially until a successful sampling occurs, we know (via Sect. 6.1) that \(O({\kappa } ^2/\log ^2{\kappa })\) iterations are required in expectation. All but one of these iterations are failures, and in the one successful case in the malicious setting, the size of the consistency check circuit dominates that of the biprimality test circuit. Thus, the overall per-party communication complexity to sample a biprime using this composition strategy is in

$$\begin{aligned} O\left( \frac{n\cdot {\kappa } ^3}{\log {\kappa }}\right) \qquad \text { or}\qquad O\left( \frac{n\cdot {s} \cdot {\kappa } ^3}{\log ^2{\kappa }} + \frac{n^2\cdot {s} \cdot {\kappa } ^2}{\log n + \log {\kappa }}\right) \end{aligned}$$

in the semi-honest or malicious settings, respectively.

Concrete Network Cost. We now perform all the substitutions necessary to collapse the cost figures we have reported into concrete values. We plug the costs of individual sub-protocols from Sect. 6.2 into the main protocol breakdown presented in this section, using bandwidth-optimal variants where appropriate, and convert gate counts into bit counts assuming the protocol of Yang et al. [51]. We also derive the expected cost of sampling a single biprime via sequential iteration of until a success occurs: this strategy allows us to determine the number of iterations required by inverting the success probabilities calculated in Sect. 6.1. Finally, we set \({\lambda } =128\) and \({s} =80\). We report the results of this calculation for our semi-honest protocol variant in Table 4, and for our malicious protocol variant in Table 5.

Table 4 Communication per party in kilobits: semi-honest
Table 5 Communication per party in megabits: malicious

6.4 Strictly Constant and Expected-Constant Rounds

In the foregoing sections, we have given costs for sampling a biprime under the assumption that is iterated sequentially. While this ensures that no work or communication is wasted, since no additional instances of are run after the first success, it also yields an expected round complexity that grows with \(\Omega ({\kappa } ^2/\log ^2{\kappa })\) at the least (the inverse of the success probability of a single instance, per Sect. 6.1), and concretely yields tens or hundreds of thousands of rounds in expectation for the values of \({\kappa } \) used in practice. This is not satisfying.

Unfortunately, we cannot achieve constant (or even expected constant) rounds by running instances of concurrently, because the \(\texttt {sample}\) operation of (which samples pairs of secret-shared nonzero values) is also probabilistic, with termination in expected-constant rounds. When multiple expected-constant-round protocols are composed in parallel, the resulting protocol does not have constant rounds in expectation [3, 13, 14]. The naïve solution is to modify the \(\texttt {sample}\) operation of to generate candidates concurrently instead of sequentially and set the parameters such that it succeeds with overwhelming probability. However, this leads to a factor of \(\Theta ({s})\) overhead with respect to communication complexity, relative to sequential composition, which is also not satisfying.

Instead, we propose a non-black-box composition strategy. In order to invoke x times concurrently, we must sample x pairs of nonzero values with respect to each modulus in \({\varvec{\mathrm {m}}} \). To do this, we run a pooled sampling procedure for each modulus, which concurrently samples enough candidates to ensure that there are at least x successes among them with overwhelming probability. For modulus \({\varvec{\mathrm {m}}} _j\), and candidate count \(y\ge x\), the probability of success is governed by the binomial distribution on y and \(({\varvec{\mathrm {m}}} _j-1)^3/{\varvec{\mathrm {m}}} _j^3\). Specifically, to ensure success with overwhelming probability, we must calculate y such that

$$\begin{aligned} 1-2^{-{s}} = \sum _{i=x}^{y}\left( {\begin{array}{c}y\\ x\end{array}}\right) \left( \frac{{\varvec{\mathrm {m}}} _j-1}{{\varvec{\mathrm {m}}} _j}\right) ^{3i}\cdot \left( 1-\left( \frac{{\varvec{\mathrm {m}}} _j-1}{{\varvec{\mathrm {m}}} _j}\right) ^3\right) ^{y-i} \end{aligned}$$
(5)

holds. Although reasonable bounds and approximations exist, it is not easy to solve this equation for y in closed form. Given concrete values for the other parameters, we can compute a value for y.

As an example, consider the following concrete scenario: let x be the size of a batch of concurrent invocations of , where x is tuned such that the batch samples at least one biprime with probability 1/2. Let \({\kappa } =1024\) and let \({s} =80\), and via Sect. 6.1, we have \(x=2500\). Now consider \({\varvec{\mathrm {m}}} _2=3\), the smallest modulus with respect to which sampling will occur. Solving Eq. 5, we find that if we sample 9989 candidate values modulo \({\varvec{\mathrm {m}}} _2\), then at least 2500 of them will be nonzero with probability \(1-2^{-{s}}\). Now, if we sample a biprime by running batches of size x, one batch after the next, until a biprime is sampled, then two batches are required in expectation, which implies that 19,978 total candidate pairs must be sampled with respect to \({\varvec{\mathrm {m}}} _2\), in expectation.

For comparison, consider the sequentially composed case with sequential sampling, in which single instances of are invoked one-at-a-time until a success occurs, and similarly samples candidate pairs of nonzero values until a success occurs. In this case, 3607 invocations of are required in expectation, and during each invocation, \((3/2)^3\) candidate pairs are sampled in expectation by with respect to the modulus \({\varvec{\mathrm {m}}} _2=3\). The total number of candidate pairs with respect to \({\varvec{\mathrm {m}}} _2\) is thus 12,174 in expectation over all invocations of . Thus, in terms of candidates-with-respect-to-\({\varvec{\mathrm {m}}} _2\), the overhead to achieve expected constant rounds using the above strategy is a factor of roughly 1.65, and it is easy to confirm that for all other elements in \({\varvec{\mathrm {m}}} \), this factor is smaller. We conclude from this example that the bandwidth overhead for sampling a biprime in expected-constant rounds is reasonable, relative to the bandwidth-optimal (i.e., sequential) composition strategy. By adjusting the batch-size parameter, it can be shown that there exists a biprime-sampling strategy that takes strict-constant rounds and succeeds in sampling a biprime with probability \(1-2^{-40}\) and that the bandwidth overhead of this strategy is a factor of less than 30 with respect to the bandwidth-optimal strategy (assuming, as before, that \({\kappa } =1024\) and \({s} =80\)).

An Exact Round Count. It remains only to determine the exact round count of a batch, which is the same as the round count of a single instance of , assuming the sampling performed by in that instance is performed concurrently, and that the round-optimal variants of the biprimality test are used. In the semi-honest setting, if we modify the simple semi-honest realization of given in Sect. 6.2 to sample concurrently instead of sequentially then it requires exactly 5 rounds to sample. A similar modification yields 10 rounds for sampling using in the malicious setting. All other components of our combined protocol have constant round counts, and combining the round counts already given in Sects. 6.2, 6.3, and Appendix B yields a total of 12 rounds in the semi honest setting, or 35 rounds in the malicious setting. It is likely that both values can be reduced noticeably by interleaving and combining rounds, but we have made no attempt to do so. If the parties are interacting for the first time, they will need a small number of additional rounds to initialize OT-extensions, but this need only be done once.

6.5 Comparison to Prior Work

The most relevant prior work is that of Frederiksen et al. [23], and in this section we provide an in-depth comparison of the two. Unfortunately, Frederiksen et al. do not report concrete communication costs, and so we must re-derive them as best as we can. Before we discuss concrete costs, however, we describe the high-level differences between the two approaches, and our methodology for comparison. As their protocol supports only two parties, we will assume for the duration of this section that \(n=2\).

Both their protocol and ours are based upon oblivious transfer, but the sampling mechanisms of the two protocols have substantial structural differences. Our CRT-form sampling mechanism has a complexity in \(O({\kappa } \cdot \log {\kappa })\) or \(O({\kappa } \cdot {s})\) in the semi-honest or malicious settings, respectively. This complexity includes the cost of computing the modulus \(N\) from shares of its factors. Their protocol instead samples integer shares of \(p\) and \(q\) uniformly in standard form and uses 1-of-many OT [40] to perform trial division efficiently. Subsequently, they use an OT-multiplier of their own design to compute \(N:=p\cdot q\). Because this multiplication is not performed in CRT form, it has a communication complexity of \(O({\kappa } ^2)\) in both the semi-honest and the malicious settings. In addition, their method induces some leakage, whereas ours leaks no more than Boneh and Franklin [5]. When a biprime is sampled successfully, their biprimality test uses another, similar multiplier, with inputs that are larger by a constant factor. Since their protocol makes black-box use of the KOS OT-extension protocol [35], our comparison will assume their protocol is upgraded to use the more-recent Silent OT-extension protocol [6]. Furthermore, we will assume their scheme amortizes the costs of both 1-of-2 and 1-of-many OT-extension in the best possible way (i.e., we will only count costs that can never be amortized).

In the malicious setting, Frederiksen et al.’s protocol makes use of a proof of honesty which consists mainly of a circuit evaluated by a generic MPC functionality. It is quite similar to a combination of the circuits used by our protocol and the consistency check phase of our protocol.Footnote 14 However, they must run their circuit twice, and on the other hand, because their protocol is two-party only and already admits leakage, they are able to use the very efficient leaky dual-execution method of Mohassel and Franklin [39] to evaluate their circuit, whereas we must use an n-party method with full malicious security. Our goal is to illustrate performance differences between our approach and theirs, not performance differences among underlying black-box components. Because we do not think there is a fair way to reconcile the discrepancy in the generic MPC techniques that the two works employ, we will report the number of AND gates required by both protocols,Footnote 15 and also the number of bits transmitted per party excluding those due to evaluation of these circuits.

Finally, as Frederiksen et al. observed and as we have previously discussed, their functionality allows a malicious adversary to covertly prevent successful sampling in a selective fashion. This is true regardless of the composition strategy employed. As a consequence, in the malicious setting, we will report both the best-case behavior, in which the adversary politely avoids covert cheating, and the worst-case behavior, in which they must run sufficiently many iterations to ensure a modulus should have been sampled with overwhelming probability (and thus there must be a corrupt party present if no moduli are produced).

The protocol of Frederiksen et al. takes as a free parameter a trial-division bound, which determines the amount of trial division to be done before the candidate biprime \(N\) is reconstructed and biprimality testing occurs. Since they do not report the trial-division bound used for their concrete experiments, nor do they make a recommendation about the value other than that it be tweaked to optimize the protocol cost concretely, we choose their trial-division bound to be the same as the largest element in a \(({\kappa },2)\)-near-primorial vector, per Definition 3.4. This is a reasonable choice in terms of concrete efficiency, but it also allows us to easily make a fair comparison, since with this parametrization sampling a biprime will require the same number of invocations of (each with one biprimality test and one consistency check) in our case as there are executions of the biprimality test phase and proof-of-honesty in their case.Footnote 16

The protocol of Frederiksen et al. also takes a second trial division bound, which is used for local trial division on the reconstructed modulus. For the sake of analysis, we assume this feature is not used (we have done likewise with the analogous feature in our own protocol). We calculate concrete costs for their protocol using \({s} =80\) and \({\lambda } =128\) and report the results alongside our own for the semi-honest setting in Table 6, and for the malicious setting in Table 7.

Table 6 Comparison against Frederiksen et al: semi-honest

In the semi-honest setting, the asymptotic and concrete advantages of our approach are very clear: the overall expected cost advantage of our protocol is a factor of at least 75 and increases with the size of the biprime to be sampled. This advantage is a direct consequence of our CRT-form sampling strategy, since the two semi-honest protocols are otherwise very similar.

Table 7 Comparison against Frederiksen et al: malicious

In the malicious setting, the relationship between the two protocols is more complex. It is still apparent that for non-successful instances, our protocol is both asymptotically and concretely better. This comes at the price of a larger circuit to be evaluated when an instance succeeds in sampling a biprime. We believe this to be a beneficial trade: only one successful instance is required to sample a biprime, whereas thousands of unsuccessful instances are to be expected in the best case. However, the most noticeable difference between the two arises due to the ability of a malicious adversary to covertly force instances of the Frederiksen et al. protocol to fail. This can cause the number of instances they require to be inflated by a factor of around fifty, assuming sequential iteration, giving our approach a clear advantage.