Re: [CFRG] Small subgroup question for draft-irtf-cfrg-hash-to-curve

Richard Outerbridge <outer@interlog.com> Fri, 09 April 2021 16:46 UTC

Return-Path: <outer@interlog.com>
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 6E3593A272F for <cfrg@ietfa.amsl.com>; Fri, 9 Apr 2021 09:46:22 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.917
X-Spam-Level:
X-Spam-Status: No, score=-1.917 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_BLOCKED=0.001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cxh27pI3TQAk for <cfrg@ietfa.amsl.com>; Fri, 9 Apr 2021 09:46:18 -0700 (PDT)
Received: from mail-1.ca.inter.net (mail-1.ca.inter.net [208.85.220.69]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 11ACC3A2732 for <cfrg@irtf.org>; Fri, 9 Apr 2021 09:46:17 -0700 (PDT)
Received: from localhost (offload-3.ca.inter.net [208.85.220.70]) by mail-1.ca.inter.net (Postfix) with ESMTP id 5F89A2EA40F; Fri, 9 Apr 2021 12:46:16 -0400 (EDT)
Received: from mail-1.ca.inter.net ([208.85.220.69]) by localhost (offload-3.ca.inter.net [208.85.220.70]) (amavisd-new, port 10024) with ESMTP id 3m3AxTguYjWK; Fri, 9 Apr 2021 12:27:18 -0400 (EDT)
Received: from [192.168.168.101] (bras-base-toroon0246w-grc-18-70-30-88-99.dsl.bell.ca [70.30.88.99]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: outer@interlog.com) by mail-1.ca.inter.net (Postfix) with ESMTPSA id 0A5942EA090; Fri, 9 Apr 2021 12:46:15 -0400 (EDT)
From: Richard Outerbridge <outer@interlog.com>
Message-Id: <C92D56C0-C484-4CD3-8FF1-AEFA52F3FECA@interlog.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_9FB09355-BC50-4BB5-9C02-D7C6F2146AC4"
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\))
Date: Fri, 9 Apr 2021 12:46:15 -0400
In-Reply-To: <VI1SPR01MB0357AE729116A79C8DF70516D6739@VI1SPR01MB0357.eurprd01.prod.exchangelabs.com>
Cc: Mike Hamburg <mike@shiftleft.org>, Loup Vaillant-David <loup@loup-vaillant.fr>, CFRG <cfrg@irtf.org>
To: "Hao, Feng" <Feng.Hao=40warwick.ac.uk@dmarc.ietf.org>
References: <e270e62d-941d-0a87-7dc9-cf80f73b5aeb@jacaranda.org> <d0778523-5f5d-4327-b795-279918c1899c@www.fastmail.com> <CAMr0u6=PBX1W5zQFmpxKQ=ViUXN9QK00BREL4M0=2HOkaXaiZw@mail.gmail.com> <VI1SPR01MB03573585C37B871D200ECC23D6739@VI1SPR01MB0357.eurprd01.prod.exchangelabs.com> <4590aaa512acf5a482c9890ebe48f1760e5831a5.camel@loup-vaillant.fr> <F9593D27-3244-470E-89BE-85215B2DC9E7@shiftleft.org> <VI1SPR01MB0357AE729116A79C8DF70516D6739@VI1SPR01MB0357.eurprd01.prod.exchangelabs.com>
X-Mailer: Apple Mail (2.3608.120.23.2.4)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cfrg/5tuGU86Jrcf1AGDh_6kpinrAwnk>
Subject: Re: [CFRG] Small subgroup question for draft-irtf-cfrg-hash-to-curve
X-BeenThere: cfrg@irtf.org
X-Mailman-Version: 2.1.29
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: Fri, 09 Apr 2021 16:46:23 -0000

This is annoyingly reminiscent of whether one should check for weak, semi-weak, and demi-semi-weak DES keys :)
__outer

> On 2021-04-09 (99), at 12:18:33, Hao, Feng <Feng.Hao=40warwick.ac.uk@dmarc.ietf.org> wrote:
> 
> Hi Loup and Mike,
>  
> Thanks for the comments. As your arguments have something in common, so I will reply together.
>  
> First, let me re-iterate my two main questions:
>  
> Do we agree we need an algorithm specification be “complete”, covering all usual and edge cases? In the current hash-to-curve draft, there is a failure mode that is non-recoverable. I’m concerned about this as I haven’t come across something like this before. My question is not on the probability, but the “completeness” of an algorithm specification.
> If a protocol is provably secure under some assumption, do we agree the assumption should be “precise”? There is a clear discrepancy in what’s assumed in the CPace, OPAQUE and maybe other protocols and what’s actually provided by the concrete construction. Either should the assumption in the security proof be modified to fit the real construction, or the construction modified to fit the actual assumption in the proof.
>  
> Both of you mention that the probability of falling into a small subgroup in common elliptic curves is negligible, and hence should be ignored. However, we should be aware of the function creep once the map-to-curve functions are deployed at scale. For example, if a user already has an input value in F_p, does he still have to go through the hash_to_field step (which is complex on its own)? A conscious implementer will quite likely skip this step. But that will give more freedom to an attacker to engineer the input such that the output falls into a small subgroup. The negligible probability in your analysis will no longer hold. For a safe implementation, precluding small-group points should be built into the map-to-curve function itself (in constant time of course). I know that’s hard, but that’s exactly why the hash-to-curve function has remained so tricky to get right in PAKE since early 2000s.
>  
> Cheers,
> Feng
>  
> > My opinion as an implementer is two fold:
> > 
> > 1. Excluding low-order points is quite the hassle, and it's not
> >   clear how I could do it in constant time.
> > 2. We never generate those points to begin with.
> > 
> > I don't want to deal with (1), which makes (2) very convenient for me.
> 
> > So I'll just justify (2), using Curve25519 as an example:
> > 
> > - The order of the prime subgroup is a little over 2^252.
> > - The cofactor is 8.
> > - Therefore, Curve25519 has a little over 2^255 points.
> > - Selecting a point at random will give a low-order point about
> >  once every 2^252 trials. That means never.
> > 
> > The security of a curve is basically the square root of its prime
> > order. Here, 2^125 or so. Breaking it with standard brute force methods
> > is incommensurately easier than stumbling upon a low-order point by
> > chance.
> > 
> > In security parlance, a probability of 1/2^255 isn't just "extremely
> > small", it's "flat out impossible". I can therefore justify my laziness
> > and chose not to check for that event.
> > 
> > ---
> > 
> > Note that generating a small-subgroup point *on purpose* will not work
> > either: Curve25519 has 8 low-order points, and a maximum of 16
> > representatives for those points (maybe a couple more if we allow
> > representatives over 2^255 - 19). The inputs are hashed before we map
> > the hash to the curve. So it's not enough to pick a matching
> > representative, we need to pick a hash whose image is one of those
> > representatives.
> > 
> > To do this, we need to conduct a multi-preimage attack on a 2^255-bit
> > hash, with 16 images. The difficulty of that attack is roughly 2^251.
> > Again, this is impossible if the hash is secure.
> > 
> > As a consequence, I cannot generate test vectors that account for this
> > edge case even if I wanted to. Even if I wasn't lazy, accounting for
> > low-order points means writing code I cannot trigger even if I want to
> > —dead code. That will only harm security in practice.
> > 
> > 
> >> In CPace and OPAQUE, both protocols use the output of hash-to-curve
> >> as a base generator. The implicit assumption is that the returned
> >> value from hash-to-curve must be a non-identity point in a subgroup
> >> of the large prime order.
> > 
> > This assumption is correct as far as I can tell: yes, in *theory*, we
> > have a couple exceptions. In *practice*, those exceptions will never
> > occur. The probabilities are low enough to be considered negligible.
> > 
> > 
> >> Has this issue been considered? Apologies if I missed any discussion
> >> on this before.
> > 
> > Likely. I haven't followed past discussions though, so I cannot say.
> > 
> > Loup.
> 
> Yeah, the usual answer is: if an event happens with negligible probability,
> and an adversary can’t cause it to happen more often, and it only breaks
> one thing, then it doesn’t affect security.  Any reasonable adversarial
> strategy has some chance to break the protocol anyway (e.g. just guess
> someone’s private key), and this unlikely event doesn’t significantly
> contribute to that chance.  I haven’t checked the details for CPace and
> OPAQUE, but for cases I’ve looked at it’s been fine.
> 
> Of course, implementations will not be fully compliant with the spec
> unless they can properly handle the identity point.  They would have to
> do another analysis to see whether this sort of non-compliance is itself
> a security issue, but the answer would probably again be: not unless
> an adversary can cause it to happen.
> 
> Cheers,
> — Mike
> 
> _______________________________________________
> CFRG mailing list
> CFRG@irtf.org <mailto:CFRG@irtf.org>
> https://www.irtf.org/mailman/listinfo/cfrg <https://www.irtf.org/mailman/listinfo/cfrg>