Cross Chain Atomic Swaps in The Absence of Time Via Attribute Verifiable Timed Commitments
Cross Chain Atomic Swaps in The Absence of Time Via Attribute Verifiable Timed Commitments
Abstract—A Hash Time Lock Contract (HTLC) is a protocol A Hash Time Lock Contract (HTLC) is a technique
that is commonly used to exchange payments across different of payment in which a depositor can pay a recipient
blockchains. Using HTLC as a building block for cross funds by placing them in an escrow state that can be
blockchain atomic swaps has its drawbacks: The notion of claimed by the recipient only if the latter presents a pre-
time is handled differently in each blockchain, be it private image of a cryptographic hash function in a transaction.
or public. Additionally, if the swap ends up aborted, the To prevent the funds from being held in escrow for ever,
funds are locked in escrow until the safety timeout expires. each HTLC has a time limit (a timeout) after which the
In this work we formulate a new cryptographic primi- funds are returned to the depositor. We outline the standard
tive: Attribute Verifiable Timed Commitment which enables to technique of performing a cross chain atomic swap using
prove that a timed commitment commits to a value which HTLC in Section 3.1 in the preliminaries.
possesses certain attributes. Using our cryptographic prim-
itive, we describe a new cross chain atomic swap protocol 1.1.1. Timeouts. An HTLC has a timeout up to which the
that operates without blockchain derived time and unlike funds are locked. This is needed in order to enforce that
the state of the art, all parties can instantly abort the swap a party will not be able to spend the funds it deposited
without waiting for the safety timeouts to expire. in escrow while claiming the funds of the counter-party.
In order to prove in zero knowledge that a secret A downside of using HTLCs as the building block of
committed to using a timed commitment has a claimed hash atomic swaps is that in case the swap ends up aborted
value, we employ the ”MPC in the head” technique by Ishai (for example, the initiator of the swap has a change of
et al. and implement our zero-knowledge proof protocol and heart) then the funds of both parties are stuck in escrow
evaluate its performance. As part of our techniques, we until their corresponding timeouts expire.
develop a novel and efficient procedure for integer Lower-
Than validation in arithmetic circuits which may be of 1.1.2. Blockchain Derived Time. Each blockchain
independent interest. (whether it is permissionless or permissioned) has its own
different time management and some like Hyperledger
Index Terms—Cryptography, Blockchain, Zero-Knowledge
Fabric [12], [34] don’t even have such. This poses as
Proofs, Cross Chain Swaps, Multi-Party Computation
an obstacle for using HTLCs as an effective building
block for cross blockchain swaps. In particular, in some
1. Introduction blockchains it is not possible to make a transaction valid
only during a certain time frame, or to derive the time from
Blockchains are distributed systems that replicate the blockchain height. Therefore, we ask the following
transactions among distrusting and sometimes opposing question:
parties. While it is common practice to exchange assets or Can we build a protocol for cross blockchain atomic
currency among participants of the blockchain, engaging swaps without using the blockchain as a source of time?
in a similar deal across different blockchains is a more We answer the question in the affirmative by intro-
involved matter, in which the exchange needs to take place ducing a new cryptographic primitive which disposes the
in both blockchains, and ideally without utilizing a trusted need to rely on blockchain derived time in cross chain
third party. Such a protocol is called a cross chain atomic atomic swaps.
swap.
An atomic swap protocol ensures that if all parties 1.2.1. AVTC. We introduce a new cryptographic primitive
comply with the protocol, a swap takes place and each that we call an Attribute Verifiable Timed Commitment
party exchanges its asset with what the counter-party (AVTC). In layman’s terms, a timed commitment [15] is
offers in return. On the other hand, if some party strays a commitment that can be forcibly opened by the receiver
from the protocol then the swap ends up aborted, and without interaction with the sender (committer) by invest-
the system state is left intact. In blockchains, a common ing a predefined amount of sequential computation. An
solution for atomic swaps is having each party use a Hash AVTC can be thought of an enhanced timed commitment
Time Lock Contract. where the receiver can be convinced by the sender that
the committed secret possesses some attribute, as part of state of affairs regarding Hash Time Lock Contracts, give
the reception of the commitment. an introduction to Boneh and Naor’s timed commitment
Our main contribution is the AVTC cryptographic scheme, and briefly explain the transformation from multi-
primitive. To construct an AVTC, we augment the timed party computation to zero knowledge proofs (“MPC in the
commitment with an interactive zero knowledge proof for head”), in sections 4 and 5 we describe our protocol for
arbitrary properties of the value that is committed to. Our cross chain atomic swap and explain our proposed AVTC
construction prioritizes minimizing computation time for primitive. We conclude our work in Section 6.
both the prover and verifier and leverages the ”MPC in
the head” technique of Ishai et al [30], and entails a novel 2. Related Work
technique for Lower-Than validation in arithmetic circuits
that doesn’t require bit decomposition, which may be of 2.1. Blockchain Based Time Derivation
independent interest. We implement the zero-knowledge
proof of AVTC in C and evaluate its performance under In this section we discuss different approaches for
different security configurations. time that exist in blockchains, as well as time-related
cryptography.
1.2.2. Blockchain time-agnostic swap. Our second con-
2.1.1. Permissionless Blockchains. Time in permission-
tribution is a novel cross chain atomic swap protocol that
less blockchains is often calculated at a very coarse
operates without blockchain time, which is made possible
grained level, a fact that forces the parties to have high
by using AVTC in a black box manner. We show that
timeouts (several hours at best): Bitcoin: The median time
our protocol is not only “blockchain agnostic”, but has an
of the last 11 blocks [4], where a block is created on
additional beneficial property: our protocol allows parties
average once per 10 minutes. Ethereum: In Ethereum, the
to instantly abort the swap if both parties cooperate, while
block timestamp is set by the node that mined the block,
the current state of the art requires parties to wait until the
and the validity rules dictate that the timestamp should
timeouts expire, keeping their funds idly locked in escrow
be monotonously ascending and each block’s timestamp
in the meanwhile. The downside of our protocol is that in
is earlier than 15 minutes into the future from the current
case the parties do not cooperate in the abort procedure,
time.
they need to invest a moderate (several dozens of minutes
to a couple of hours) time period of serial computation, 2.1.2. Permissioned Blockchains. Permissioned
whereas in the standard cross chain swap it is sufficient blockchains block production rate varies according
to wait that same time period. to the transaction load [34], therefore it is impossible
to correlate a number of blocks produced with time.
1.3. Overview of Our Techniques There are no standards of how the notion of time is
defined in permissioned blockchains: Tendermint: In
Our cross chain atomic swap protocol entails replacing Tendermint [10], applications can define a “locktime”
the time based reclamation condition of the HTLC with which is the number of blocks passed after contract
revealing a pre-image of a hash function. More specif- creation. However this compromises the safety in the
ically, each party gives the counter-party an AVTC and event of an system outage in which no blocks are
a hash. The counter-party escrows its funds with the being created. Hyperledger Fabric: Blocks do not carry
reclamation condition of revealing the pre-image of the timestamps [12]. Mitra et al. [34] proposed a mechanism
hash, which it can open only after a predetermined amount to assign timestamps to the blocks by modifications to
of computation steps. The AVTC primitive ensures that the post consensus validation. Sawtooth: In Hyperledger
hash pre-image can indeed be revealed after investing the Sawtooth [8], there is no block timestamp by default,
computation steps, which prevents a malicious party from but the nodes can be configured to artificially inject a
causing the counter party’s funds to be locked in escrow “Blockchain Info” transaction that contains a timestamp,
forever. at the beginning at every block (see [9]).
Our AVTC primitive is realized by the timed com-
mitment technique of Boneh and Naor, coupled with an 2.1.3. Scientific Literature. There have been several
interactive zero knowledge proof between both parties of proposals for cross chain swaps that do not fully de-
the swap. The zero-knowledge proof of the AVTC is based pend on blockchain based time derivation. Deneuville
on the ”MPC in the head” technique of Ishai et al. [30]. In et al. [47] proposed an asymmetric protocol in which
the zero-knowledge proof, we perform efficient modular one blockchain can verify transactions being put on the
exponentiation by employing a novel technique for LSB second blockchain, however, one of the blockchains still
extraction, which straightforwardly leads to an efficient relies on blockchain derived time. Interledger [6] proposed
comparison protocol. The LSB extraction’s salient prop- a protocol based on connector entities that have access
erty is the prover acting as a dealer and distributing among to both blockchains, and is also time reliant for escrow
the parties blinded plaintext shares of all bits but the LSB release.
itself.
2.2. Time Based Cryptography
1.4. Paper Organization The main time-based cryptographic primitive that is
used in our work, is the ”Timed Commitment” of Boneh
The paper is organized as follows: In Section 2 we and Naor [15], and is explained in Section 3.2 . We give
discuss related work in cross chain atomic swaps and an overview on other cryptographic primitives that possess
time based cryptography. In Section 3 we outline the time-related guarantees.
2.2.1. Verifiable Delay Functions. Proofs that verify a committer of the GaTC. In contrast, our AVTC primitive
computation took a certain amount of steps have been only assumes number theoretical assumptions (see Def-
studied in the past in the context of Verifiable Delay inition 5), and protects against malicious committers by
Functions (VDF) [14] [38] [46]. enforcing honest behavior via zero-knowledge proofs.
Replacing AVTC with a VDF is possible, however it We note that the authors of [11] mention this and state
would take away an important advantage of our protocol: that their semi-honest committer assumption can be
interoperability. In our protocol, the computations done in eliminated by using zero-knowledge proofs.
the blockchain are invocations of hash functions, and the • A party that opened a GaTC can prove in zero-
heavy lifting is done in the application layer. In contrast, knowledge that it did so. While our technique doesn’t
using a VDF would require the blockchain software to be focus on such an ability, we note that our technique can
able to validate the VDF proof, which requires introducing be trivially extended to facilitate that. Indeed, a party
new software into the blockchain validation mechanisms, that has forcefully extracted the input for F (as depicted
thus hindering adoption and making it impossible to be in Figure 2) has the required information to play as the
integrated to conservative blockchains. prover of the AVTC.
2.2.5. Homomorphic Time-Lock Puzzles (HTLP).
2.2.2. Timed Fair Exchange of Signatures. Garay et Malavolta et al. [33] constructed variations of time-lock
al. [22] and Boneh at al. [15] both proposed interactive puzzles that each is homomorphic to an operation1 such as
protocols for timed fair exchange of signatures. Those addition in ZN or multiplication in JN (where JN denotes
protocols, however, do not protect the counter-party from elements in Z∗N with Jacobi symbol +1).
a malicious abort that wastes computation time that is As in the timed commitment, the HT LP has a setup
linear in the total protocol runtime. phase that generates public parameters. However, in the
timed commitment the sender proves to the receiver that
2.2.3. Multi-Party Timed Commitment. Doweck and the forced open (denoted as Solve in HTLP) indeed
Eyal [21] constructed a Multi-Party Timed Commitment yields the committed value within the claimed number of
(MPTC) that enables several parties to jointly commit to computation steps. As we’ll see below, it is not the case
a secret to be later opened by a designated party via in HTLP. We elaborate on one of the variations of HTLP,
brute-force computation. The MPTC primitive of [21] Linearly Homomorphic Time Lock Puzzle (LHTLP) as it
does not allow one to prove an attributes the committed is used as a building block for higher level applications
secret, unlike our AVTC primitive. The MPTC commit- which we discuss later in this section. A Linearly Ho-
ment brute-force opening is trivially parallelizable, unlike momorphic Time Lock Puzzle (LHTLP) is a tuple of the
our AVTC primitive which is not (under number-theoretic four algorithms below:
assumptions, see Definition 5). Consequently, we note λ
• pp ← Setup(1 , T ) On input of security parameter λ,
that in our cross-chain atomic swap protocol, our AVTC hardness parameter T outputs public parameters pp.
primitive cannot be substituted with an MPTC because we • Z ← Gen (pp, s): Output a puzzle Z for a solution s.
require that the commitment brute-force opening cannot • s ← Solve (pp, Z): Recovers s from Z .
be done via parallel computation, as it would harm the • Z ← Eval (⊕, pp, Z1 , ..., Zn ): Outputs Z s.t ∀{Zi ←
security of our atomic swap protocol. Pn
Gen (pp, si )}ni=1 : Solve (pp, Z) = i=1 si (mod N )
where N is specified in pp.
2.2.4. Gage Time Capsules. Almashaqbeh, Benhamouda, Setup samples a safe modulus2 N , samples g ∈ JN
et al. [11] constructed a Gage Time Capsule (GaTC) which T
and computes h = g 2 and outputs pp = (T, N, g, h). If h
allows a party to commit to a value that others are able to
was not honestly constructed then Solve will not output
reveal at a designated total computational cost, and that
the s that was used as input to Gen. We elaborate on
computation is expected to be parallelized among different
this in Section A in the Appendix. The authors of [33]
parties which are incentivised to try out different random
do mention that the setup should be executed by a trusted
decommitment values, and claim a monetary reward in
party.
exchange for their work. While their primitive (GaTC)
seems similar to our AVTC primitive, we note the salient 2.2.6. Verifiable Timed Signatures. Thyagarajan et al.
differences: [44] constructed a Verifiable Timed Signature (VTS) prim-
• Brute-forcing a GaTC can be parallelized, and thus, itive for common elliptic curve based signature schemes
parties with access to parallel computing power gain such as ECDSA [31]. It allows a sender to commit to a
significant advantage over others. In contrast, brute- receiver on a signature and later the receiver can forcefully
forcing an AVTC cannot be parallelized (under number- recover the signature without interaction with the sender
theoretic assumptions, see Definition 5), and this prop- by executing serial computation. Unlike our AVTC prim-
erty is crucial to the security of our novel cross-chain itive (Definition 10), the VTS construction is an ad-hoc
atomic swap protocol described in Section 4. protocol suitable only for signatures, and cannot be used
• The GaTC zero-knowledge proof does not prove any for any arbitrary attribute as in our AVTC primitive.
attribute of the secret that is committed to. Rather, it The VTS construction is based on the Linearly Homo-
contains only a proof of opening. In contrast, our AVTC morphic Time-Lock Puzzle (LHTLP) primitive of Mala-
primitive, proves that a committed secret, possesses an volta et al. [33] and its high-level idea is as follows: First,
attribute of the committer’s choice.
1. The work also shows that a fully homomorphic time lock puzzle
• The GaTC committer does not prove to a counter-party
is feasible assuming indistinguishability obfuscation.
that the commitment can be opened within a timely 2. A safe modulus is a product of two primes p = 2p0 +1, q = 2q 0 +1
manner. Rather, it assumes a semi-honest model on the where p0 , q 0 are also prime
the sender ”encrypts” the signature with secret shares gen- constant complexity, by making the prover compute the
erated with t-out-of-n Shamir’s secret-sharing [42]. Then, LSB itself, but having the verifier validate the prover.
it commits to each share with the LHTLP primitive by
locking each share in a LHTLP puzzle. The sender and the 3. Preliminaries
receiver then engage in a cut-and-choose protocol where
the receiver asks to open t − 1 puzzles and invokes Gen
itself to verify the puzzles sent to it were indeed correctly
3.1. Hash Time Lock Contracts
constructed. Additionally there is also a range proof that
proves that the time-lock puzzles contain ”small” values. A Hash Time Lock Contract (HTLC) [39] is a tech-
As noted in our discussion on the Homomorphic Time- nique of payment in which a depositor can pay a recipient
Lock Puzzle (HTLP), without a trusted setup assumption, a part of its funds by placing them in an escrow state that
even when validating the Gen operation via cut-and- can be claimed by the recipient only if it presents a pre-
choose as done in the VTS construction, a malicious image of a cryptographic hash function in a transaction.
sender may fool the receiver into accepting signatures that To prevent the funds from being held in escrow for ever,
can never be opened without interaction with the sender. In each HTLC has a time limit (a timeout) after which the
contrast, our AVTC primitive enjoys a transparent setup. funds are returned to the depositor.
HTLCs are often used as a building block for atomic
2.2.7. Universal Atomic Swaps: Secure Exchange of cross chain swaps, in which Alice can atomically ex-
Coins Across All Blockchains. A parallel work to ours by change her coins in blockchain A with Bob’s coins in
Thyagarajan et al. [43] that appeared online in December blockchain B. In order for a cross chain atomic swap to
2021 deals with performing cross-chain atomic swaps be useful, it needs to possess both safety and liveness
by substituting blockchain derived time with using the properties [29]:
Verifiable Timed Signature (VTS) (Section 2.2.6) also Definition 1 (Safety). For every execution, either both
by Thyagarajan et al. [44]. The high level idea of their parties claim each other’s funds, or no party claims the
scheme is that the escrow account on each blockchain counter-party’s funds.
is initialized with a public key so that its corresponding
private key is secret shared between the two counter- Definition 2 (Liveness). For every execution, no asset of
parties. Then, to swap the funds the parties engage in a some party is locked in escrow forever.
secure two-party computation protocol to produce a sig- Below we give the well known HTLC based cross
nature (done for each blockchain in parallel). To withdraw chain atomic swap protocol of [28]:
from the swap, the parties recover signatures on withdraw 1) Alice randomly selects a secret s ← {0, 1}λ for some
transactions prepared as part of the prepare phase. security parameter λ and publishes a transaction on
We note that unlike our solution which relies on blockchain A with a hash lock of h = H(s) and a
the blockchain being able to verify hash puzzles as part time lock of T + ∆ for some ∆ > 0.
of its transaction validation logic (an ability that some 2) Bob publishes a similar transaction on blockchain B
blockchains like Monero, lack), the technique of Thya- with a hash lock of h (while not knowing s) and a
garajan et al. does not require that, as the time based time lock of T .
cryptography locks a signature and not a hash pre-image. 3) Alice publishes a transaction on blockchain B which
It is not clear how the authors address the issue we raise includes s0 ∈ H−1 (h) and as a result claims Bob’s
in Section 2.2.5 regarding the trusted setup assumption coins to her account.
of the HTLP and VTS primitives that the construction of 4) Bob, having seen a pre-image s0 such that H(s0 ) =
[43] relies on. h , publishes a transaction on Alice’s blockchain that
claims Alice’s coins to his account.
2.3. LSB extraction in Multi-Party Computation We note that Alice sets a time lock T+∆ compared to T
for Bob, because had Alice put her funds in escrow for an
The AVTC primitive we construct uses the ”MPC in equivalent or shorter period of time than Bob - she could
the head” zero-knowledge framework (see Section 3.3). have first claimed Bob’s funds into her account and then
An important part of our computation uses LSB extraction raced Bob on blockchain A and reclaimed her funds back
of a secret-shared value. before Bob had a chance to claim them.
The current state of the art in MPC enables one to While HTLCs are powerful tools that allow atomic
extract the LSB [19], [32], [37] but with polynomial exchange of assets between two or more blockchains, a
complexity in the binary representation length of elements major limitation in the protocol stems from its safety: If
in the underlying field. Such techniques are expensive a party put its funds in escrow for a time period T , even
to be used in the ”MPC in the head” approach that we if both parties agree to abort the swap, they have to wait
employ for our zero-knowledge proof, since they blow up until T time passes.
the proof size when the field in use is thousands bits long.
There are also techniques [18], [40] that allow to extract 3.2. Timed Commitments
the LSB with a constant communication complexity, how-
R
ever only for values known to be significantly small. In Notations and definitions: We denote by ← X a
our protocol, unfortunately, the verifier cannot trust the uniform random selection from a set X and denote λ ∈ N
prover to uphold any such invariant. to be a security parameter. Let : N → R be a
We devise a novel MPC protocol tailored for zero- negligible function if for every positive polynomial P :
1
knowledge from MPC techniques that extracts an LSB in ∃N ∈ N s.t ∀n > N : (n) < P (n) .
Definition 3 (Commitment scheme). A protocol between proof sub-protocol of timed commitment in Section C,
a sender S and a receiver R with two steps: which was not provided in [15].
λ
• Commit(x, 1 ): S has input x, and outputs to R a
string C ∈ {0, 1}λ and to S a decommitment string d ∈ Setup(1λ ). Let λ be a security parameter. The committer
{0, 1}λ . We denote by (d, C) ←< S(x, 1λ ), R(1λ ) > (also called the sender) picks P, Q: two λ-bit primes s.t
the experiment in which S and R interact. P ≡ Q ≡ 3 (mod 4), and publishes their product N =
• Open: R has C and is given x, d by S . R accepts or
P · Q to the receiver.
rejects. We denote by R (C, x, d) ∈ {0, 1} its output. Commit(M, T ). The Committer (sender) receives as input
A commitment scheme has two security properties: T = 2k for some k ∈ N that determines the difficulty
• Hiding: For any receiver R which chooses {x0 , x1 } ⊂
of the forced open phase by the receiver, and a message
R M ∈ {0, 1}∗ to commit to.
{0, 1}λ and is given C = Commit (xb ) on xb ← 1) The sender picks h ← Zλ at random
{x0, x1 } and outputs b = 0 or b = 1, it holds that: r n
2) The sender computes g = h(Πi=1 qi ) mod N where
P r R x0 , x1 , 1λ = b − 12 = (λ) for a negligible .
λ q1 , q2 , .., qr are the first r primes, with a typical setting
• Binding: For any C ∈ {0, 1} there is at most of r being 128.
one x ∈ {0, 1} such that ∀x0 6= x, ∀d0 :
λ
3) The sender sends the receiver h, g and the latter
P r [R(C, x0 , d0 ) = 1] = (λ) for a negligible . verifies them by computing Q = Πri=1 qiλ and then
Dan Boneh and Moni Naor [15] describe an enhanced g = hQ (mod N )
2k
commitment primitive called a “Timed commitment” that 4) The sender, knowing P, Q computes u = g 2 mod N
k
has a third step: by computing a = 22 mod φ(N ) followed by u =
• Forced Open(C), in which the receiver can invest mod- a
g (mod N ).
erate computation power and time in order to open the 5) The sender hides M ’s bits by XOR-ing them with
commitment C to yield x without any interaction with LSBs of successive roots of u mod N , more formally:
the sender. The number of computation steps required 2k −i
to execute the forced open step is set by the committer Si = Mi ⊕ g 2 mod N where Mi denotes the i-th
as part of the commit step. bit of M . The commitment string is defined as:
We formally define a timed commitment below: C = hS, h, g, ui
Definition 4 (Timed Commitment [15]). A timed com- and is sent to the receiver.
mitment scheme hCommit, Open, F Openi is a triplet of 6) The sender proves that u is constructed properly, mean-
PPT algorithms that satisfy: Given a string x ∈ {0, 1}l , ing that the receiver can indeed open the commitment
a difficulty level k ∈ N, a committer computes a cryp- in time T by computing repeated squaring modulo N
tographic commitment (C, d) ← Commit x, k, 1λ and 2k
convinces the receiver that C can later be opened without starting from g and until u = g 2 . This is done by
interaction with the committer via m ← F Open (C, k) by constructing the following vector W of length k :
executing 2k serial computation steps 3 , or by having x
2i 2k
revealed to the receiver via m ← Open (C, x, d). W = g 2 , g 4 , g 16 , g 256 , ..., 22 , ..., g 2 (mod N )
The timed commitment primitive, possesses the addi-
tional following two properties: followed by proving in Zero Knowledge for each i ∈
• Soundness: The committer proves to the verifier that [k] that for each adjacent pair (ai , bi ) ∈ W : (g, ai , bi )
2
the forced open step indeed yields the committed value is of the form (g, g x , g x ) for some x. This protocol,
within the claimed number of computation steps. as well as its proof, can be found in Section B.
• Serial computation: No parallel algorithm can ob-
tain information about the committed string in time Open. Denote |M | as the bit length of M . The sender
2k −|M |
significantly less than it takes to compute successive sends the receiver
r
vλ 0 = h2 and the receiver com-
squarings. In particular, it relies on the Generalized BBS putes v = (v 0 )Πi=1 qi which is the 2|M | ’th root of u (taking
assumption. square roots |M | times from hu yields v ). Nowi the receiver
|M |−i
BBS assumptionE[15] For k ∈ N
Definition 5. Generalized D can compute: [M ]i = [S]i ⊕ v 2 mod N by repeated
R 2k
and g ← ZN , let Wg,k = g 2 , g 4 , ..., g 2 . The element modular squaring starting from v .
2k+1 Forced-Open(C ). In case the sender never opens the com-
g2 is computationally indistinguishable from a random
quadratic residue for any parallel random access machine mitment for the receiver, the receiver can compute (with
whose running time much less than 2k . some effort) the committed value M by first computing
2k −|M |
v = g2 (mod N ) by using 2k −|M | squaring modulo
Aside from the Generalized BBS assumption needed N to obtain v and proceed as in the open step.
for the serial computation constraint, the hiding property
relies on the Quadratic residuosity assumption [13].
3.3. Zero Knowledge Proofs From Secure Multi-
3.2.1. The timed commitment protocol. We next elab- party Computation
orate on the timed commitment protocol as it appears in
We assume the reader is familiar with secret-sharing
[15]. We also include a full proof for the zero-knowledge
based multi-party computation schemes such as GMW
3. The value k for k ∈ N is a difficulty parameter chosen by the [26], namely that multiplication a scalar and addition
committer. can be done by every party as a local computation, but
multiplication, secret share reconstruction and distribution of a time based hash puzzle requires only a single hash
requires communication among parties. invocation on the candidate solution. In addition, a hash
Ishai, Kushilevitz, Ostrovsky and Sahai proved in [30] puzzle takes up minimal storage space in the blockchain.
that Zero Knowledge Proofs can be built from semi-honest Our realization of a time based hash puzzle is via our
MPC protocols in the following manner: Let L ∈ N P Attribute Verifiable Timed Commitment (AVTC) primitive
and RL its corresponding witness relation. Given x ∈ L that enables a sender to commit to a value M and to
and a witness w such that (x, w) ∈ RL and an MPC prove to a receiver that the message M committed to is
protocol that computes RL (x, w) ∈ {0, 1}, one can build a hash pre-image of a specified hash. The receiver can
a zero knowledge proof where the prover proves in zero open the commitment without interaction with the sender
knowledge that indeed x ∈ L as follows: by executing a predefined number of computation steps
1) Let P1 , ..., Pn be n parties. The L
prover splits w into n (where the number of steps is set by the sender). We define
random shares wi such that w = i∈[n] wi and assigns the AVTC time based hash puzzle here, and in Section 5
each party i private input wi . we generalize the AVTC primitive to any functionality.
2) The prover simulates the MPC protocol for all n parties
“in the head” and maintains records of views and Definition 6. AVTC Timed Based Hash Puzzle Let λ
message transmissions for all parties. be a security parameter and H be a cryptographic hash
3) The prover commits to the views and message trans- function. An AVTC time based hash puzzle is defined by
missions using a statistically binding commitment and four operations:
sends them to the verifier. 1) P ub, P riv ← Setup(1λ ): The sender obtains private
4) The verifier randomly asks the prover to reveal the parameter P riv , both sender and receiver obtain P ub.
commitments for a subset of the parties. 2) (C, y, π) ← Commit(P riv, T, M ): Given the setup’s
5) The prover complies and reveals the requested infor- private parameters, a difficulty level T and a message
mation. M , the sender produces a commitment C , a string y =
6) The verifier validates the commitments revealed and H (M ) and a proof π that y = H(M ).
checks the consistency of the views and message trans- 3) M ← Open(C, P ub): The sender reveals the message
missions, and accepts or rejects accordingly. M to the receiver.
This result has a strong implication: Given (x, w) ∈ RL , 4) M ← F orceOpen(C, P ub): The receiver reveals the
the construction of a multiparty protocol where w is secret message M without interaction with the receiver, by
shared among the parties and the circuit checks whether investing T computation steps.
(x, w) ∈ RL is a scheme to construct a zero knowledge
proof for membership in L.
Security model and assumptions. We model the world
4. Cross Chain Atomic Swaps in the Absence as an interaction between two mutually distrusting and
of Time potentially malicious parties. Each party has an incentive
to deceive the counter-party and has no repercussion if
We describe a novel protocol for cross chain atomic caught cheating. We further assume that a party cannot
swaps that utilizes our Attribute Verifiable Timed Com- deny the counter-party from transacting on the blockchain
mitment (AVTC) primitive. Unlike the state of the art, our indefinitely, but only for a certain known time period. We
protocol operates without blockchain derived time. make the standard requirement that our cryptographic hash
Our protocol’s main difference from the standard cross function is pre-image resistant [41]. We assume the parties
chain atomic swap described in the literature in Section are probabilistic polynomial time Turing machines.
3.1 is that we have each party give the other party a hash
puzzle that can be opened in a timely manner. Each party,
4.2. The Cross Chain Atomic Swap Protocol
escrows its funds in a way that reclaims the funds back
to the party only if the hash puzzle solution is revealed.
By changing the reclamation condition to a hash veri- We lay out our protocol by describing an interaction
fication, we also give the parties a way to immediately between two parties: Alice and Bob, where Alice pays
reclaim their funds in escrow. While it is possible to Bob a fee sum on blockchain BCA in exchange for Bob
construct a condition with the state of the art’s HTLC paying Alice sum on BCB . The protocol consists of two
based swap, it would require adding a multi-signature phases:
condition to the script which would take more space and 1) Prepare: Puts transactions on the blockchains in
computation overhead, hence will increase the cost of preparation for the swap.
using such a transaction. 2) Either Swap: Transact on both blockchains for each
party to claim its payment, or Withdraw: Cancel the
4.1. AVTC as a Time Based Hash Puzzle swap and have each party reclaim the escrow.
Notations: We next elaborate on each of these steps.
Consider a puzzle encoded as a string y so that to solve Let λ be a security parameter and T = 2d be a difficulty
it, one needs to find a hash pre-image x such that y = level, typically d ∈ [30, 50]. We denote appending transac-
H(x) where H is a cryptographic hash function. A time tion X to blockchain BCA as BCA X . We denote Alice
m
based hash puzzle is a puzzle that has an additional way sending a message m to Bob as A → B and similarly,
m
of finding the pre-image x, and this way requires a certain Bob sending m to Alice as B → A. For succinctness,
number of computation steps. Indeed, a time based hash we omit specifying P ub and P riv produced in the Setup
puzzle would fit our needs perfectly: Verifying a solution phase.
Prepare. In steps 1-2 in the prepare phase (depicted in
Figure 1), Alice produces a timed commitment CA for a Prepare
uniformly random hash pre-image a, and sends the other
R
party (Bob) CA and the hash A = H (a) along with proof 1: Bob: b ← {0, 1}λ , B = H(b),
that A = H (F orceOpen (CA )). The proofs are verified (CB , πB ) = Commit (b, T + ∆) , B
(B,CB ,πB )
→ A
by both parties in step 3, and each party aborts the protocol R
if the proof verification fails. Then, in step 4 Alice initiates 2: Alice: a ← {0, 1}λ , A = H(a),
(A,CA ,πA )
the HTLC by selecting a uniformly random secret x and (CA , πA ) = Commit (a, T ) , A → B
publishing its hash y in step 5 on BCA by publishing a 3: Alice: Verify πB ; Bob: Verify πA
transaction that guarantees: R
4: Alice: x ← {0, 1}λ , y = H(x)
1) If Bob appends a transaction that reveals H−1 (y) 5: Alice: BCA hB, y, sumi
before Alice appends a transaction that reveals b0 ∈ 6: Bob: BCB hA, y, sumi
H−1 (B) then Bob claims sum to itself on BCA .
2) If Bob hadn’t appended a transaction that reveals
H−1 (y) and Alice appended a transaction that revealed Swap
b0 ∈ H−1 (B) then Alice claims back sum on BCA . 1: Alice: BCB hxi
Finally, in step 6, Bob finishes the prepare step by 2: Bob: BCA hxi
appending a transaction on BCB which guarantees:
1) If Alice appends a transaction which reveals H−1 (y)
before Bob appends a transaction which reveals a0 ∈ Withdraw(cooperative)
H−1 (A), then Alice claims sum to herself on BCB . a
2) If Alice did not append a transaction which revealed 1: Alice: A → B
H−1 (y) and Bob appended a transaction which re- 2: Bob: BCB hai
b
vealed a0 ∈ H−1 (A), then Bob claims back sum on 3: Bob: B → A
BCB . 4: Alice: BCA hbi
Swap. Alice appends a transaction to BCB which reveals
x and thus claims sum from Bob, just as done in HTLC. WithdrawAlice (non-cooperative)
Bob, having now seen x s.t x ∈ H −1 (y), appends a
transaction that reveals x to BCA and thus claims sum 1: Alice: b ← F orceOpen (CB )
from Alice. 2: Alice: BCA hbi
binding property. Then, we dive into the details of the ing to be 2 u, and the prover will prove that repeated
design of the circuit’s subcomponents and analyze them. squaring modulo N starting from the witness, reaches u
in |x| + 1 iterations.
5.3.1. Opening a Timed Commitment with a Circuit.
5.3.2. Squaring and Modulo Reduction. Reducing a
We recall the timed commitment (Section 3.2) encoding:
2k secret shared number modulo N is an expensive oper-
C = hS, h, g, ui where u = g 2 (mod N ) for a difficulty ation because it either requires bit decomposition [36]
r λ
parameter k , and g = hΠi=1 qi where qi are all primes (decomposing the number to shares of bits), or employing
less than some upper bound r. We wish to prove that the schemes that require random bitwise sharing [35]. Both bit
secret x that we commit to, indeed satisfies F (x) = 1. decomposition and bitwise sharing in a field big enough to
A straightforward way of achieving this, is to execute contain our modulus N means thousands of shares each
the Open phase of timed commitment in our arithmetic thousands bits in size. We sidestep this inefficiency by
circuit, extract the committed value x, and then compute recalling that our circuit only needs to validate the
7. In Section 5.3.5 we show why p > N 2 + n · 2µ is required 8. A Blum prime is a prime such that P ≡ 3 (mod 4)
Algorithm 2: SquareModNExtractLSB Algorithm 3: VerifyLowerThan
Input: [xi ] (from previous hlayer) and pre-computed: Input: [v] , u
x2 −(x2i % N )
i
Output: 1 if v < u, otherwise aborts
I1 = x2i % N , I2 = i N
1: a = LessT hanHalf Order ([v])
Output: x2i % N (to next layer), LSB x2i % N to 2: if a 6= 1 then
sub-circuit which computes F . 3: abort
1: [a] = [xi ] · [xi ] 4: end if
2: [b] = I1 // hx2i % N pre-computed 5: [w] = p − [v]
2 2
i
x −(xi % N )
3: [t] = I2 // i N pre-computed 6: [x] = [w] + u
4: [y] = [a] − [b] − [t] · N 7: b = LessT hanHalf Order ([x])
5: y = Reveal([y]) 8: if b 6= 1 then
6: if y 6= 0 then 9: abort
7: abort 10: end if
8: end if 11: return 1
9: z = V erif yLowerT han ([b] , N )
10: w = V erif yLowerT han [a] , N 2
11: u = LessT hanHalf Order ([t] · N )
Algorithm 4: LessThanHalfOrder
12: if z · w · u 6= 1 then Input: [v]
13: abort Output: 1 if v < p2 , otherwise aborts
14: end if 1: [w] ← 2 · [v]
15: [b0 ] = ComputeLSB ([b]) 2: [b] ←ComputeLSB ([w])
16: Forward [b] to next level 3: b ← Reveal ([b])
17: Forward [b0 ] towards computation of F 4: if b 6= 0 then
5: abort
6: end if
computation, and the prover is free to pre-compute all
7: return 1
intermediate values of the computation and feed them into
the circuit as secret shared inputs.
Specifically, instead of computing a mod N , the a < N 2 , then a < p as well. Therefore, both sides of
prover pre-computes b (denoted as I1 in Algorithm 2) the equality do not overflow p and (F) holds over N,
and t (denoted as I2 in Algorithm 2) such that it holds meaning that without loss of generality, b > b0 and t0 > t.
that: b = a − t · N , and both b and t are given as input to It follows that t0 − t ≥ 1, thus b − b0 > N ⇒ b > N in
the parties, which verify that the equality [a] = [b]+[t]·N contradiction to the fact that b < N .
holds. 5.3.3. Validating Lower-Than. We give a novel and effi-
At a first glance, validating that [a] = [b] + [t] · N cient construction to a secure Multi-Party protocol which
seems trivial. However, the hardness lies in ensuring that validates that a secretly shared value is lower than a public
a cheating prover doesn’t secret share b, t that satisfy the value. Our protocol doesn’t doesn’t require edaBits like
condition but make the computation secretly overflow the the recent work of [32] and unlike the aforementioned
field p of the circuit. By initializing the secret shared state of the art, has constant rounds. The protocol uses
values b, t with numbers that overflow the finite field p, a Algorithm 4 in a black box manner for validating that
cheating prover may manipulate the LSBs extracted from a secret shared value is less than p2 . The protocol and
each layer in the circuit and make the verifier think that Algorithm 4 both draw on the ideas from [18] and [37].
a committed value has an attribute that it doesn’t posses. The protocol (Algorithm 3) receives as input a secret
Therefore, we additionally make Algorithm 2 ensure that: shared value [v] and a public constant u < p2 and returns
1) b < N 1 if and only if [v] < u, otherwise aborts.We prove its
2) a < N 2 correctness:
3) t · N < p2
Ensuring (1), (2) is done via Algorithm 3 and ensuring Lemma 15. For every u < p2 , Algorithm 3 returns 1 if it
(3) is done via Algorithm 4, where both are comparison is input with [u] < u, otherwise it aborts.
algorithms and are possible to be computed efficiently Proof. Algorithm 3 checks if [v] > p2 . If so, then v > u,
thanks to our novel LSB extraction algorithm. therefore it aborts. Otherwise, both v and u are smaller
Algorithm 2’s correctness immediately follows from than p2 , therefore (F) v > u ⇔ u − v (mod p) > p2 . In
the following lemma: lines 5 − 6 we compute [x] = u − [v] (mod p) and then
Lemma 14. For an equality a = b + t · N where check if it’s less than p2 (line 7). If it is the case, then it
{a, b, t, N } ⊂ Zp for p > 4 and N 2 < p, if b < N , follows from (F) that v < u.
a < N 2 and [t] · N < p2 then there is a single b that
5.3.4. Validating that a value is less than p2 . We show
satisfies the equality.
how to validate that [v] < p2 . The protocol relies on the
Proof. Assume in contradiction there are b, b0 , t, t0 that fact that if v < 12 p then multiplying it by 2 yields a
satisfy the equality, i.e a = b + t · N and a = b0 + t0 · N . number that is less than p, and then there is no wrap-
Then it holds that b + t · N = b0 + t0 · N , thus we
√
get: around p and the LSB of the result becomes 0 for an odd
(F) b−b0 = N ·(t0 − t). Since N 2 < p, so N < p < p2 , p. The protocol is shown in Algorithm 4 and uses the
therefore b < N < p2 and thus b + t · N < p. And since ComputeLSB protocol.
smaller than the field size. Our protocol immediately leads
to constant round efficient comparison validation protocols
in arithmetic circuits and do not require bit decomposition
or binary share assisted schemes.
Notations: We denote [x] to be a secret sharing
of x among n parties. When referring to an operation
done by every party, we shall denote ∀i ∈ [n]. Let
S = 2 · α α ∈ 0, 2|N |+µ−1 : be the set of legal
blinded plaintext shares in our algorithm.
The technique: For simplicity, we first describe the
technique for a semi-honest 1-secure setting (which as-
sumes parties do not collude), as shown in Figure 3. A
modification to a semi-honest k-secure case, where parties
may collude appears later on. In the offline phase, the
prover first represents v as a sum of an even number a
and the LSB of v denoted by b: v = a+b (line 1). Then, it
splits a into n shares a(1) +a(2) +...+a(n) < p and it splits
Figure 3: The prover secret-shares v into plaintext shares b into bits such that: b(1) ⊕b(2) ⊕...⊕b(n) (line 2). Finally,
and then blinds each share with a blinding factor given to it statistically hides each share a(i) with an even uniformly
one of the remaining two parties (1-secure MPC). R
random variable r(i) ← {2 · x x ∈ (0, 2|N |+µ−1 )}
(line 3) where |N | is the number of bits in N , n is the
Algorithm 5: ComputeLSB Algorithm number of parties and µ is a security parameter such that
Input: [v] p > N 2 + n · 2µ . Similarly, it blinds each share b(i) with a
Output: [v0 ], the LSB of v random bit e(i) . The prover sets each party i’s input (line
Offline phase (performed by the prover): 4) to be the following plaintext shares: a(i) + r(i) ; r(i+1) ;
1: Set a = v − v0 and b = v0 b(i) ⊕ e(i) ; e(i+1) .
2: Set a = a(1) + a(2) + ... + a(n) where ∀i : a(i) is even, For a k-secure MPC protocol, each share a(i) is
and set b = b(1) ⊕ b(2) ⊕ ... ⊕ b(n) blinded with k blinding factors, e.g in a 2-secure MPC
3: ∀i ∈ [n] : protocol with 3 parties, the share a(1) is blinded with r(1,2)
R R
r(i) ← {2 · x x ∈ (0, 2|N |+µ−1 )}; e(i) ← {0, 1} which is given to party 2 and with r(1,3) which is given
4: ∀i ∈ [n] :
to party 3.
Give party i :< a(i) + r(i) ; r(i+1) ; b(i) ⊕ e(i) ; e(i+1) > In the online phase, each party verifies that its
plaintext share is in the appropriate range (line 5) and
Online phase (performed by the blinding factor for a(i) is even, and secret shares
the simulated parties): the blinded share and the blinding factor among all
5: ∀i ∈ [n] : If a(i) + r(i) , r(i+1) 6⊆ S, abort
6: ∀i ∈ [n] : If b(i) ⊕e(i) , e(i+1) 6⊆ {0, 1} abort parties
(i) (lines 7-10),
after which
the parties compute
a + r(i) , ri+1 , bi ⊕ e(i) , ei+1 and finally ex-
7: ∀i ∈ [n] : a(i) + r(i) = SecretShare a(i) + r(i)
tract the sharings of the LSB (line 11) after which they
jointly validate the plaintext shares given to them in the
8: ∀i ∈ [n] : r(i+1) = SecretShare r(i+1) offline phase (lines 12-15).
9: ∀i ∈ [n] : b(i) ⊕ e(i) = SecretShare b(i) ⊕ e(i)
10: ∀i ∈ [n]L: e(i) = SecretShare (i)
Ln e (i)
n (i) (i) 5.3.6. LSB extraction security proof. We formally prove
11: [v0 ] = i=1 Pnb ⊕ e ⊕ i=1P e
n the correctness and privacy of the LSB extraction protocol.
12: [z] = [v] − i=1 a(i) + r(i) + i=1 r(i) − [v0 ] We give three theorems and prove them in Section D. For
13: z = Reconstruct ([z]) simplicity of notation, we set the number of parties to be
14: if z 6= 0 then three.
15: abort
16: end if Definition 16 (ComputeLSB protocol). Let → −
x =
17: return [v0 ] (x0 , x1 , x2 ) be shares distributed by a dealer and define
3 3
the LSB extraction functionality f : (Zp ) → (Zp ) where
→
−
fi ( x ) is the output of party i, and let π to be the LSB
5.3.5. Extracting the LSB of a Secret Shared Value. extracton protocol (Algorithm 5) and V IEWiπ (→ −
x ) the
We describe our novel protocol LSB extraction protocol view of party i during the execution of π .
shown in (Algorithm 5). The protocol extracts the LSB
of a secret shared value v and is suited to the MPC in Theorem 17 (LSB extraction completeness). On input [v]
the head setting where a prover, knowing v , can act as a with an honest dealer, ComputeLSB outputs [v0 ] (secret
dealer and distribute shares in an offline phase before the shares of the LSB of v ) and never aborts.
online phase takes place among the parties. At the end Theorem 18 (LSB extraction privacy). There exists a PPT
of the online phase, parties obtain a secret sharing of the S such that for a single party j ∈ {0, 1, 2}:
LSB of v , [v0 ]. semi-honest
{S (xj , fj (→
−
x ))} ≡s V IEWjπ (→
−
x)
Our contribution: We construct a novel constant-
round protocol for LSB extraction of a secret shared value Theorem 19 (LSB extraction soundness). ComputeLSB
that is claimed (but not known, as in [18], [40]) to be always either aborts or correctly extracts [v0 ].
Algorithm 6: BooleanizeLSB
Prover Verifier
Input: [v0 ]
Round 1
Output: [v0 ]B
R
p {ij∈[λ] ← {0,1,2}}
1: ∀i ∈ [n] : [ri ] = SecretShare Rand n+1
2: ∀i ∈ [n]L: [bi ]B = SecretShare ([ri % 2]) {C (ij )}j∈[λ]
3: [b]B =
P i∈[n] [bi ]B Round 2
4: [r] = i∈[n] [ri ] {Vj ← F(s)}j∈[λ]
5: [x] = [r] + [v0 ]
6: x = Reconstruct ([x]) {C (v)}v∈Vj , j∈[λ]
7: [v0 ]B = LSB(x) ⊕ [b]B Round 3
{ij }j∈[λ]
Combining the three theorems above yields that an Round 4
honest prover distributes plaintext shares in a fashion that {vi , vi0 ∈ Vj }j∈[λ]
ensures that the verifier always accepts, and the output to Verify:
the next gate in the circuit is indeed the LSB of the secret
shared input value. (*) Commitments
Additionally, the protocol achieves statistical zero (**) views
knowledge, since the view of every single semi-honest
party participating in the protocol is statistically indistin- Figure 4: The MPC in the head interactive protocol
guishable from the simulated view. the OLE oracle O to compute blinded products of each
Lastly, if the dealer is dishonest, the MPC protocol of party’s inputs:
the LSB extraction always aborts. It immediately follows 1) Every party i samples a random value ri,j ∈ Zp for
that the LSB extraction protocol does not degrade the each party j 6= i and sends the share xi and ri,j to O.
soundness of the zero knowledge proof, as the probability 2) party j sends to O the share yj
of a cheating prover to commit to an incorrect protocol 3) The OLE oracle O sends party j si,j = xi · yj + ri,j .
execution does not depent on whether it entails an LSB Afterwards, [z] is defined by having the blinding fac-
extraction or not. Pn sent by party i, subtracted: zi = xi + yi +
tors
j=1,j6=i (sj,i − ri,j ). When simulating O, the prover
commits to the inputs and outputs of O. When verifying
5.3.7. Conversions between different fields. After ex- the multiplication gate, the prover reveals two views to
tracting the LSB of each layer in our circuit, we show the verifier, and the latter verifies they are consistent with
in Algorithm 6 how to convert it from a sharing modulo the commitments. Note, that since we employ a 2-secure
p to the domain of the predicate F . Since our predicate GMW, the prover reveals to the verifier the views of two
of choice in our cross chain swap protocol (Section 4) out of the three parties. Thus, we only need to reveal
is SHA256 comparison, we explain how we convert the the de-commitment of the party which its view is not
arithmetic sharing to a boolean sharing, and denote the revealed, as the verifier can compute the expected de-
shares in the target domain as [·]B . Our technique follows commitments of the rest of the parties. This saves us sig-
[20], and its main idea is to produce masking factors in nificant bandwidth, as our de-commitments are elements
both the arithmetic domain and the boolean domain such in Zp and have thousands of bits each. In each iteration,
that the LSB of both masking factors is identical (lines the verifier opens two out of the three views committed
1-2). Then, the masking factor in the arithmetic domain, by the prover, therefore the probability of the verifier
masking the secret shared LSB (line 5), is revealed (line λ
6) and the LSB is used to cancel out the mask in the accepting an incorrect proof with λ rounds is 31 . Since
arithmetic domain (line 7). our zero-knowledge protocol is interactive, k doesn’t need
to be large, as in the honest-verifier non-interactive zero-
knowledge, because the prover cannot use computation to
5.3.8. Instantiating the MPC Protocol To Be Used In predict the verifier’s challenge.
The ”MPC In The Head” Framework. We instantiate an
MPC protocol using a semi-honest 2-secure9 GMW [26] 5.3.9. Obtaining Zero-Knowledge From MPC. We de-
where the arithmetic part of our circuit uses an arithmetic scribe an interactive protocol (Figure 4) between the
GMW, and the boolean part of our circuit for computing sender of the commitment, playing as the prover, and the
F uses a boolean GMW. Our conversion from an MPC receiver of the commitment, playing as the verifier. Denote
protocol to a zero-knowledge proof using the ”MPC in vi as the view of party i ∈ {0, 1, 2} in an MPC protocol
the head” framework follows [30] and it is outlined in executed on secret input s.
Section 5.3.9. We elaborate on our salient difference from The view includes private input, random tape, and
the state of the art, the secure multiplication, as secret incoming messages received during the protocol from
sharing and addition are done in the standard manner. foreign parties.S Denote C a commitment operation and
To multiply [z] = [x] · [y], we use an Oblivious Linear define Vj = i∈{0,1,2} {vi } as the union of all views
Evaluation (OLE) oracle O: Every pair of parties i, j use in the j ’th simulation of MPC protocol and let λ be a
security parameter. The zero knowledge proof is a four
9. A 2-secure protocol can withstand collusion of two parties out of round protocol:
the remaining three Round 1: The verifier samples λ indices uniformly at
Prover Verifier Total Network
random and commits to them using a perfectly hiding #Rounds Security
time time bandwidth Latency
commitment, and sends the commitment to the prover. 26 240 7.8s 4.9s 577 MB 15s
Round 2: The prover simulates the MPC protocol for F 19 230 5.5s 3.2s 421 MB 11s
on secret input s, λ times and commits (using a perfectly 13 220 3.3s 2s 288 MB 8s
binding commitment) to each view (of each party) sep-
TABLE 1: Performance evaluation of AVTC where the
arately, and sends the λ triplets of commitments to the
attribute F is the SHA2 256 function
verifier.
Round 3: The verifier decommits the vector of λ indices the protocol. In contrast, the standard ”MPC in the head”
{ij }j∈[λ] sent in the first round. approach enables the prover to pre-compute the views of
Round 4: The prover checks the decommitments of the the parties and their commitments long before it comes
verifier, and then replies with the views that correspond into interaction with the verifier, and then when the verifier
to other two remaining requested indices {{0, 1, 2} \ asks for opening of the commitments just send the pre-
{ij }}j∈[λ] . The verifier then: (*) verifies that the com- computed de-commitments.
mitments match the received views, (**) simulates the
execution of each party that its view was sent by the 5.5.2. Quantitative comparison to ZK-SNARKs. Gen-
verifier. Specifically, the verifier ensures that the messages eral purpose zero-knowledge proof systems vary from
that the party should send, match the commitments on the simulations of MPC protocols (fast proving time, but high
received messages of the other parties. bandwidth) to non-interactive arguments of knowledge
5.3.10. Zero knowledge Proof For Membership In LF . (slow proving time, low bandwidth). The analysis of [3]
After proving the correctness and privacy of our LSB compared different systems and showed that the Groth16
extraction protocol (Sections 5.3.5, 5.3.6), as well the [27] scheme is the fastest in both prover time and verfier
correctness and privacy of all other algorithms instantiated time, having an order of magnitude difference from the
with the GMW [26] scheme, we can now prove our slowest scheme (Bulletproofs [17]) in their analysis.
main result for this section, Theorem 11. The proofs of To that end, we implement [2] AVTC with the Groth16
completeness, soundness and zero-knowledge are found ZK-SNARK library of Gnark [16] instantiated with the
in Section E. BN-254 curve. In particular, we implement gadgets for
4096 bit number addition and 4096 bit number multi-
5.4. Evaluation plication and then use them in the successive modular
squaring using pre-computed hints similar to Algorithm
We implement the AVTC zero-knowledge proof used 2 in Section 5.3.2. Finally, the LSBs of each layer are
for our cross chain atomic swap protocol from Section 4, fed into a SHA256 gadget we implemented. We bench-
which requires proving in zero knowledge that an AVTC mark the Groth16 implementation on an AWS c5a.8xlarge
commitment string, commits to a SHA256 pre-image. We machine with a 64GB RAM and 32 CPUs. The time it
re-use code from ZKBoo [24] for the SHA256 circuit, takes to run the trusted setup of the 14 million constraints
and implement the AVTC arithmetic circuit and share circuit is 3 minutes and 38 seconds. The prover runs in 54
conversion in 3,500 lines of C code available online [1]. seconds and verifier in 1.4 milliseconds. The large number
We use the GNU MP library [5] for our arithmetic of constraints is due to the need to represent 4096 bit
share addition and multiplication, and OpenMP [7] for numbers as arrays of smaller numbers (we pick 120 bit
parallel processing of soundness amplification. We exper- words), since the order of the BN-254 curve is only 254
iment on an Intel i7 2.6Ghz with 12 cores and 32GB bits long. However, we use hash pre-images of only 96 bits
RAM with different numbers of rounds for soundness in the Groth16 in contrast to 128 bits in the ”MPC-in-the-
amplification, and in each configuration we compute the head” AVTC. The reason is that the more bits in the hash
network bandwidth sent from the prover to the verifier pre-image, the more layers of successive modular squaring
(see Table 1 and Section G) and estimate the latency for we have. Unlike in our ”MPC-in-the-head” construction
a 300 Mbps network. where the number of iterations is the dominating factor,
in the Groth16 ZK-SNARK it is the depth of the circuit.
5.5. Comparison to Other Schemes
6. Conclusions
In this section we discuss alternative options for
our AVTC implementation. We consider other interac- In this work we explored whether cross chain atomic
tive Zero-Knowledge proofs and also non-interactive ones swaps based on Hash Timed Lock Contracts can be con-
such as ZK-SNARKs and discuss trade-offs. structed without reliance on a time source, and answered
the question in the affirmative by providing a protocol
5.5.1. Lowering the network bandwidth. A recent which replaces the well known blockchain based timeouts
promising zero-knowledge proof scheme that has both fast used for safety with timed commitments. We enforced
proving time and low bandwidth is [45]. It is a flavor honest party behavior for our protocol via our novel AVTC
of ”MPC in the head” where the prover and verifier run primitive, which allows to prove arbitrary attributes for
a two-party MPC protocol (with malicious security) and Boneh and Naor’s timed commitment.
unlike the original ”MPC in the head”, they only do a While there is plenty of room for efficiency improve-
single pass over the circuit. However, the protocol assumes ments in our construction, as it requires substantial net-
a designated verifier because a preliminary setup phase work bandwidth, we make up for it in minimal prover
must take place between the prover and verifier prior to time, and in not requiring a trusted setup.
References [24] I. Giacomelli, J. Madsen, and C. Orlandi. Zkboo: Faster zero-
knowledge for boolean circuits. In 25th USENIX Security Sympo-
sium (USENIX Security 16), pages 1069–1083, Austin, TX, 2016.
[1] AVTC MPC in the head implementation. https://github.com/ USENIX Association.
AVTC-paper/AVTC-MPC.
[25] S. Goldberg, L. Reyzin, O. Sagga, and F. Baldimtsi. Efficient
[2] AVTC ZK-SNARK implementation. https://github.com/
Noninteractive Certification of RSA Moduli and Beyond, pages
AVTC-paper/AVTC-SNARK.
700–727. 11 2019.
[3] Benchmarking zero-knowledge proofs with isekai:
[26] O. Goldreich, S. Micali, and A. Wigderson. How to play any
https://sikoba.com/docs/skor isekai benchmarking 201912.pdf.
mental game. In Proceedings of the Nineteenth Annual ACM
[4] Bitcoin time locks: https://github.com/bitcoin/bips/blob/master/bip- Symposium on Theory of Computing, STOC ’87, page 218–229,
0113.mediawiki. New York, NY, USA, 1987. Association for Computing Machinery.
[5] GMP library. https://gmplib.org/. [27] J. Groth. On the size of pairing-based non-interactive arguments.
Cryptology ePrint Archive, Report 2016/260, 2016. https://ia.cr/
[6] Interledger https://interledger.org/interledger.pdf.
2016/260.
[7] OpenMP library. https://www.openmp.org/.
[28] M. Herlihy. Atomic cross-chain swaps. In Proceedings of the 2018
[8] sawtooth: https://sawtooth.hyperledger.org/. ACM Symposium on Principles of Distributed Computing, PODC
’18, pages 245–254, New York, NY, USA, 2018. ACM.
[9] sawtooth: https://sawtooth.hyperledger.org/faq/transaction-
processing/#why-is-there-no-timestamp-in-a-transaction-header-or- [29] M. Herlihy, B. Liskov, and L. Shrira. Cross-chain deals and
block. adversarial commerce. Proc. VLDB Endow., 13(2):100–113, Oct.
[10] Tendermint htlcs: https://github.com/nomic-io/htlc. 2019.
[11] G. Almashaqbeh, F. Benhamouda, S. Han, D. Jaroslawicz, [30] Y. Ishai, E. Kushilevitz, R. Ostrovsky, and A. Sahai. Zero-
T. Malkin, A. Nicita, T. Rabin, A. Shah, and E. Tromer. Gage knowledge from secure multiparty computation. In Proceedings of
mpc: Bypassing residual function leakage for non-interactive mpc. the Thirty-ninth Annual ACM Symposium on Theory of Computing,
Proceedings on Privacy Enhancing Technologies, 2021:528 – 548, STOC ’07, pages 21–30, New York, NY, USA, 2007. ACM.
2021. [31] D. Johnson, A. Menezes, and S. Vanstone. The elliptic curve digital
[12] E. Androulaki, A. Barger, V. Bortnikov, C. Cachin, K. Christidis, signature algorithm (ecdsa). Int. J. Inf. Secur., 1(1):36–63, aug
A. D. Caro, D. Enyeart, C. Ferris, G. Laventman, Y. Manevich, 2001.
S. Muralidharan, C. Murthy, B. Nguyen, M. Sethi, G. Singh, [32] E. Makri, D. Rotaru, F. Vercauteren, and S. Wagh. Rabbit: Efficient
K. Smith, A. Sorniotti, C. Stathakopoulou, M. Vukolic, S. W. comparison for secure multi-party computation. IACR Cryptol.
Cocco, and J. Yellick. Hyperledger fabric: A distributed operating ePrint Arch., 2021:119, 2021.
system for permissioned blockchains. CoRR, abs/1801.10228,
2018. [33] G. Malavolta and S. Thyagarajan. Homomorphic Time-Lock Puz-
zles and Applications, pages 620–649. 08 2019.
[13] L. Blum, M. Blum, and M. Shub. A simple unpredictable pseudo
random number generator. SIAM J. Comput., 15(2):364–383, May [34] A. Mitra, C. Gorenflo, L. Golab, and S. Keshav. Timefabric:
1986. Trusted time for permissioned blockchains. 2021.
[14] D. Boneh, B. Bünz, and B. Fisch. A survey of two verifiable delay [35] C. Ning and Q. Xu. Multiparty computation for modulo re-
functions. IACR Cryptol. ePrint Arch., 2018:712, 2018. duction without bit-decomposition and a generalization to bit-
decomposition. In M. Abe, editor, Advances in Cryptology - ASI-
[15] D. Boneh and M. Naor. Timed commitments. In Advances in
ACRYPT 2010, pages 483–500, Berlin, Heidelberg, 2010. Springer
Cryptology - CRYPTO 2000, 20th Annual International Cryptology
Berlin Heidelberg.
Conference, Santa Barbara, California, USA, August 20-24, 2000,
Proceedings, pages 236–254, 2000. [36] C. Ning and Q. Xu. Constant-rounds, linear multi-party computa-
[16] G. Botrel, T. Piellard, Y. E. Housni, I. Kubjas, and A. Tabaie. tion for exponentiation and modulo reduction with perfect security.
Consensys/gnark: v0.6.4, Feb. 2022. In D. H. Lee and X. Wang, editors, Advances in Cryptology
– ASIACRYPT 2011, pages 572–589, Berlin, Heidelberg, 2011.
[17] B. Bünz, J. Bootle, D. Boneh, A. Poelstra, P. Wuille, and Springer Berlin Heidelberg.
G. Maxwell. Bulletproofs: Short proofs for confidential transac-
tions and more. In 2018 IEEE Symposium on Security and Privacy [37] T. Nishide and K. Ohta. Multiparty computation for interval,
(SP), pages 315–334, 2018. equality, and comparison without bit-decomposition protocol. In
International Workshop on Public Key Cryptography, pages 343–
[18] O. Catrina and S. de Hoogh. Improved primitives for secure 360. Springer, 2007.
multiparty integer computation. In J. A. Garay and R. De Prisco,
editors, Security and Cryptography for Networks, pages 182–199, [38] K. Pietrzak. Simple verifiable delay functions. In 10th innovations
Berlin, Heidelberg, 2010. Springer Berlin Heidelberg. in theoretical computer science conference (itcs 2019). Schloss
Dagstuhl-Leibniz-Zentrum fuer Informatik, 2018.
[19] I. Damgård, M. Fitzi, E. Kiltz, J. B. Nielsen, and T. Toft. Un-
conditionally secure constant-rounds multi-party computation for [39] J. Poon and T. Dryja. The bitcoin lightning network: Scalable
equality, comparison, bits and exponentiation. In Theory of Cryp- off-chain instant payments, 2016.
tography Conference, pages 285–304. Springer, 2006. [40] T. I. Reistad. Multiparty comparison - an improved multiparty
[20] I. Damgård and R. Thorbek. Efficient conversion of secret- protocol for comparison of secret-shared values. In SECRYPT,
shared values between different fields. IACR Cryptol. ePrint Arch., 2009.
2008:221, 2008. [41] P. Rogaway and T. Shrimpton. Cryptographic hash-function basics:
[21] Y. Doweck and I. Eyal. Multi-party timed commitments. ArXiv, Definitions, implications, and separations for preimage resistance,
abs/2005.04883, 2020. second-preimage resistance, and collision resistance. In B. Roy
and W. Meier, editors, Fast Software Encryption, pages 371–388,
[22] J. A. Garay and C. Pomerance. Timed fair exchange of standard Berlin, Heidelberg, 2004. Springer Berlin Heidelberg.
signatures. In R. N. Wright, editor, Financial Cryptography, pages
190–207, Berlin, Heidelberg, 2003. Springer Berlin Heidelberg. [42] A. Shamir. How to share a secret. Commun. ACM, 22(11):612–613,
nov 1979.
[23] A. Gervais, G. O. Karame, K. Wüst, V. Glykantzis, H. Ritzdorf,
and S. Capkun. On the security and performance of proof of work [43] S. A. Thyagarajan, G. Malavolta, and P. Moreno-Sánchez. Univer-
blockchains. In Proceedings of the 2016 ACM SIGSAC Conference sal atomic swaps: Secure exchange of coins across all blockchains.
on Computer and Communications Security, CCS ’16, page 3–16, Cryptology ePrint Archive, Report 2021/1612, 2021. https://ia.cr/
New York, NY, USA, 2016. Association for Computing Machinery. 2021/1612.
[44] S. A. K. Thyagarajan, A. Bhat, G. Malavolta, N. Döttling, A. Kate, Appendix B.
and D. Schröder. Verifiable timed signatures made practical. In 2k
Proceedings of the 2020 ACM SIGSAC Conference on Computer Proving that u = g 2 (mod N )
and Communications Security, CCS ’20, page 1733–1750, New
York, NY, USA, 2020. Association for Computing Machinery. We describe the protocol executed as part of the
[45] C. Weng, K. Yang, J. Katz, and X. Wang. Wolverine: fast, scalable, Commit phase of AVTC which convinces the receiver
and communication-efficient zero-knowledge proofs for boolean that the commitment can be forcefully opened in 2k se-
and arithmetic circuits. In 2021 IEEE Symposium on Security and k
Proof for the Boneh-Naor Zero Knowledge g γ = aδi ⇒ g γ·δ = ai and aγi = bδi ⇒ aγ·δ i = bi .
Protocol Denote β = γ · δ −1 (mod q). Hence g β
= ai and aβi =
2
bi , so (g, ai , bi ) = g, g β , g β , thus (ai , bi ) ∈ L in
C.1. Completeness contradiction to the assumption.
Proof of Theorem 11 (Completeness). If the sender and For a party j ∈ {i − 1, j + 1} and w.l.o.g j = i + 1,
receiver are honest, then indeed x, the secret input that upon having a share zj that is a result of a multiplication
F is evaluated on, has the required attribute, and every gate, we sample its inputs xj , yj ∈ Zp , sample the random
simulation of the MPC protocol of F on x will always tape entry rj,i−1 to be sent to party i − 1 and then do the
yield F(x) = 1. Furthermore, all commitments open same for party i − 1. Then, we compute the OLE outputs
correctly by both the sender and the receiver, and views to parties j, i − 1 and sample random values for the OLE
are consistent with the messages sent due to the prover with party i (its view is not revealed) such that (F) holds.
honestly emulating all executions of F , therefore the Secret sharing: Let sj be a share that is in possession of
receiver accepts. party j ∈ {i − 1, i + 1} at some point in the backward
evaluation. By definition, the share was sent by a party
Proof of Theorem 11 (Soundness). Since x ∈ / LF , the in {j + 1, j − 1}. We split into two cases: (i) The share
sender cannot simulate the MPC protocol of F honestly, was sent by party i which its view isn’t revealed. In that
and thus it has to cheat at at least a single party simulation case, we add sj to the incoming messages of j . (ii) The
among the n simulations. Observe that the sender commits share was sent by the remaining party, one that is not
to views in round 2, and reveals views selected by the i and also not j and its view is revealed. In that case,
verifier in round 4. The probability that a cheating sender we sample a random value s0 according to its domain
will cheat in one of the three party simulations which the (it might be a plaintext share, or a regular share in Zp )
and then split s0 into three parts: {s01 , s02 , sj } such that
λgoing to ask to reveal in round 4 for all λ
receiver is not
s01 + s02 + sj = s0 (mod p), and then we set the output
indices is 13 , which is negligible for a large enough λ. of the gate whose output is used as input to the secret
sharing operation, and recursively call F .
Proof of Theorem 11 (Zero Knowledge). We describe a LSB extraction: The LSB extraction involves additions
S(x) M
simulator M and show that: V iewR ≡s V iewR . The (local operations), secret sharing, multiplications and
simulator M uses an auxiliary function F to construct the share reconstructions, which were all defined previously
views and outgoing messages for each party i: for F.
1) M receives a vector of commitments for indices from
the verifier, sent in round 1.
2) M sends a commitment to zeroes in round 2. Appendix F.
3) Verifier decommits to indices {ij }j∈[λ] it sent. Hash Pre-Image Prefix Length
4) M rewinds the verifier back to right after round 1.
5) ∀j ∈ [λ], M sends to R in round 2: A malicious party in our cross-chain atomic swap
{C (F ((ij − 1)mod 3)) , C (F ((ij + 1)(mod 3))) , C (0)} protocol is incentivised to find a pre-image for of a
cryptographic hash H with the secret prefix of length d,
6) M Receives indices sent in round 3, and decommits as it can then claim its funds in escrow faster than the
to views and outgoing messages forged by F. specified timeout, and then claim both the counter party’s
The construction of F is defined for the other two parties funds and not lose its own funds in escrow.
that are not i, meaning parties i − 1 and i + 1 that Security model and assumptions: We assume a
their view and outgoing messages are forged. Their output model where malicious parties are computationally bound.
depends on the action performed by the party (gate type, Specifically, we assume that any malicious party that
or operation), the input to that action (gate input, private participates in the cross-chain atomic swap protocol, has
input) as well as the random tape. We define each action’s hashing power less or equal to the entire hashing power
output by emulating the protocol backwards gate by gate: of the Bitcoin network. We also put an upper bound to
Share reconstruction: The public output F(x) for which the delay used for any of the two parties in our protocol,
the verifier accepts, is split into three uniformly random which will be a single day.
shares si−1 mod 3 , si , si−1 mod 3 and let the parties of the We are only interested in protecting honest parties that
views i − 1, i + 1 send their shares to each other. This follow the protocol, therefore we assume that they sample
is possible thanks to the fact that F emulates the MPC their pre-image prefix uniformly at random from {0, 1}d
protocol backwards, so the gates that define the shares of as dictated by our protocol (see Section 4). We assume the
the output reconstruction have not yet been defined at this standard cryptographic assumption on the hash function
stage. [41] we use, in particular that it is pre-image resistant,
Multiplication: We recall the definition of the OLE based and let its input be 256 bits.
multiplication gate: To multiply [z] = [x] · [y], we use an Analysis: Denote the daily hashing rate of a malicious
Oblivious Linear Evaluation (OLE) oracle O: Every pair party to be r. For simplicity, we model the computation
of parties i, j use the OLE oracle O to compute blinded by giving the malicious party oracle access to R:
products of each party’s inputs: R : N → {(x, H0 (x)) x ∈ {0, 1}d }
1) Every party i samples a random value ri,j ∈ Zp for
256−d
each party j 6= i and sends the share xi and ri,j to O. z}|{
0
2) party j sends to O the share yj where H (x) = H(x|| 0..0 ), a function that pads the in-
3) The OLE oracle O sends party j : si,j = xi · yj + ri,j . put with zeroes and then applies H. Informally, R receives
Afterwards, [z] is defined by: a number r ∈ N and then outputs r zero-padded pairs of
pre-image prefixes and hashes, where each padding is of 600
length 256 − d.
We need to ensure that d will be large enough so
6
time (seconds)
2 Prover
Verifier
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Number of rounds
Figure 6: Performance measurement of SHA256-AVTC