Re: [CFRG] Curve25519 security level is better than stated in RFC 7748

"D. J. Bernstein" <djb@cr.yp.to> Wed, 14 December 2022 14:54 UTC

Return-Path: <djb-dsn2-1406711340.7506@cr.yp.to>
X-Original-To: cfrg@ietfa.amsl.com
Delivered-To: cfrg@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 3DF81C1522A7 for <cfrg@ietfa.amsl.com>; Wed, 14 Dec 2022 06:54:26 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.895
X-Spam-Level:
X-Spam-Status: No, score=-1.895 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id l55tVJTCEnTZ for <cfrg@ietfa.amsl.com>; Wed, 14 Dec 2022 06:54:22 -0800 (PST)
Received: from salsa.cs.uic.edu (salsa.cs.uic.edu [131.193.32.108]) by ietfa.amsl.com (Postfix) with SMTP id 08BB7C1522A3 for <cfrg@irtf.org>; Wed, 14 Dec 2022 06:54:21 -0800 (PST)
Received: (qmail 32243 invoked by uid 1010); 14 Dec 2022 14:54:20 -0000
Received: from unknown (unknown) by unknown with QMTP; 14 Dec 2022 14:54:20 -0000
Received: (qmail 51621 invoked by uid 1000); 14 Dec 2022 14:54:00 -0000
Date: Wed, 14 Dec 2022 14:54:00 -0000
Message-ID: <20221214145400.51619.qmail@cr.yp.to>
From: "D. J. Bernstein" <djb@cr.yp.to>
To: cfrg@irtf.org
Mail-Followup-To: cfrg@irtf.org
In-Reply-To: <HE1PR0701MB3050285EF57A80DE425BD20289199@HE1PR0701MB3050.eurprd07.prod.outlook.com>
Archived-At: <https://mailarchive.ietf.org/arch/msg/cfrg/qj_KLhOrlHx5kE2BCSo1BTtPCnI>
Subject: Re: [CFRG] Curve25519 security level is better than stated in RFC 7748
X-BeenThere: cfrg@irtf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: Crypto Forum Research Group <cfrg.irtf.org>
List-Unsubscribe: <https://www.irtf.org/mailman/options/cfrg>, <mailto:cfrg-request@irtf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cfrg/>
List-Post: <mailto:cfrg@irtf.org>
List-Help: <mailto:cfrg-request@irtf.org?subject=help>
List-Subscribe: <https://www.irtf.org/mailman/listinfo/cfrg>, <mailto:cfrg-request@irtf.org?subject=subscribe>
X-List-Received-Date: Wed, 14 Dec 2022 14:54:26 -0000

John Mattsson writes:
> When using AES-128 and Curve25519 together, AES-128 is the weakest
> link (considering known classical attacks). Comparing asymmetric and
> symmetric "operations" are like comparing apples to oranges. When you
> make a fair comparison, it is very clear that Curve25519 is stronger
> than AES-128 based on known classical attacks.

Just writing to fill in some numbers here.

First of all, a standard negating rho attack takes about sqrt(pi l/4)
iterations on average.

https://cr.yp.to/papers.html#grumpy showed that the constant sqrt(pi/4)
isn't optimal in cost models that allow free memory access, and it's
conceivable that the same is true in realistic cost models, but the
potential improvement here was already well known to be limited by
Nechaev--Shoup: a generic negating attack can't do better than 2/3.
Let's assume 2/3 is achievable, so 2^125.4 iterations for Curve25519.

This number 2^125.4 is below the number of AES-128 keys, namely 2^128.
More to the point, it's below the average number of guesses in a
brute-force AES-128 key search, which is about 2^127.

However, as John notes, the 2^125.4 and 2^127 here have different units.
For a valid comparison, we need the same units. Let's count bit
operations.

An unrolled 255-bit multiplication circuit, including Karatsuba and many
lower-layer speedups, uses 95126 XORs and 78828 ANDs/ORs, for a total of
173954 bit operations. https://cr.yp.to/papers.html#qisog includes code
to count this.

An optimized elliptic-curve attack iteration costs 5 multiplications
plus overhead, about 2^20 bit operations overall. Footnote 5 of
https://cr.yp.to/papers.html#sect113r2 is tantamount to reducing 5 to
4.5+o(1) asymptotically (if one ignores the bit operations involved in
RAM access), but it's structurally clear that the o(1) is positive, so
this is below 0.2 bits of difference in security.

To summarize, the ~2^125.4 iterations are above ~2^145.2 bit operations.
The only gap I see in the literature is that there's a missing analysis
of bit operations for more complicated multipliers; I'd guess that Toom
does _marginally_ better than Karatsuba at this size.

For comparison, there are more gaps in the literature analyzing the cost
of AES-128 attacks (e.g., how many bit operations can be shared across
key guesses? what's the impact of bicliques on bit-operation counts?),
but it's reasonably clear that plugging existing AES-128 single-input
optimizations into a naive AES-128 attack brings each iteration below
2^15 bit operations, so the average ~2^127 AES-128 attack iterations are
below 2^142 bit operations.

In short, an X25519 key is an order of magnitude more costly to break
than an AES-128 key by known attacks. (Until the attacker has a quantum
computer, a big caveat noted in the Curve25519 paper.)

Bitcoin is currently around 2^111 bit operations per year, which might
make 2^142 sound safe. An important cautionary note is that multi-target
AES-128 attacks are already feasible for large-scale attackers today;
see generally https://blog.cr.yp.to/20151120-batchattacks.html. As the
Curve25519 paper explains, low-probability attacks and multi-target
attacks have less impact on X25519 security than on cipher security.

Beyond bit operations, there's more to say about exact hardware costs. I
expect a detailed analysis to show that hardware overheads are a bigger
issue for Curve25519 attacks than for AES-128 attacks, most importantly
because of routing overheads. This prediction is based on considering
the high-level data flow in a rho attack against Curve25519 (see the
diagrams in https://cr.yp.to/papers.html#opb for the similar case of
binary elliptic curves), the low-level data flow inside multipliers, the
low-level data flow inside an AES attack, and the mix of bit operations
(which can matter: e.g., NAND is cheaper than XOR in hardware). It would
be interesting to see papers analyzing this.

---D. J. Bernstein