Re: [CFRG] compact representation and HPKE

Loup Vaillant-David <loup@loup-vaillant.fr> Wed, 10 February 2021 23:12 UTC

Return-Path: <loup@loup-vaillant.fr>
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 2B4DF3A0D63 for <cfrg@ietfa.amsl.com>; Wed, 10 Feb 2021 15:12:08 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.918
X-Spam-Level:
X-Spam-Status: No, score=-1.918 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=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 aPgyPmXGkK7z for <cfrg@ietfa.amsl.com>; Wed, 10 Feb 2021 15:12:06 -0800 (PST)
Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 401253A0D62 for <cfrg@irtf.org>; Wed, 10 Feb 2021 15:12:05 -0800 (PST)
Received: from grey-fade (unknown [78.198.246.40]) (Authenticated sender: loup@loup-vaillant.fr) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 4A0F8240005; Wed, 10 Feb 2021 23:12:00 +0000 (UTC)
Message-ID: <bfa8bca61af8db2f44bf6de39f32c9711546dbe6.camel@loup-vaillant.fr>
From: Loup Vaillant-David <loup@loup-vaillant.fr>
To: Dan Harkins <dharkins@lounge.org>, cfrg@irtf.org
Date: Thu, 11 Feb 2021 00:11:59 +0100
In-Reply-To: <472e7324-4f86-7cff-f266-8c8bd7791b26@lounge.org>
References: <0fcfb0ed-249b-7cd3-09ba-ed1c73122383@lounge.org> <4C4DE4EC-1A5B-48F5-871E-B7D323EF63D5@ericsson.com> <CAL02cgQFGcWjpFV1nFVg2T3aCat6U-uuzUQ_YsUYLHvQq+ZuiQ@mail.gmail.com> <5C12F8B7-99E2-40DA-8A3C-8930E652C77F@shiftleft.org> <99c28b97-332d-af67-0895-a1bd251153bb@lounge.org> <934cbf19-1e16-24cd-7442-85fb8d41fcb1@lounge.org> <CAEseHRpZE7=smgZs-te4yDb1kTD6aSg92mASn_WZrsB=FqdisQ@mail.gmail.com> <CAEseHRr4TZ9hf1KLhVh+A3ku=RYm8Ycn2b5KdLsamO7sio1v5g@mail.gmail.com> <472e7324-4f86-7cff-f266-8c8bd7791b26@lounge.org>
Content-Type: text/plain; charset="UTF-8"
X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2
Mime-Version: 1.0
Content-Transfer-Encoding: 7bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/cfrg/v-tOrD7MZTX_rl0qwg5C2N-AmiA>
Subject: Re: [CFRG] compact representation and HPKE
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: Wed, 10 Feb 2021 23:12:08 -0000

On Wed, 2021-02-10 at 04:42 -0800, Dan Harkins wrote:
>  
> For all of these curves, p = 3 mod 4 so doing a modular square root
> is just exponentiation to (p + 1)/4. Not sure how onerous an
> additional exponentiation is.

I've just checked by removing the final inversion from my X25519
implementation (which uses an x-only ladder), the cost is less than
10%. Comparatively even less if you're using a more expensive ladder.


> But then Mike Hamburg was saying that one can do a x-only Montgomery
> Ladder for these curves if an exponentiation is, indeed, onerous so
> there are options to consider.

To be checked, but an x-only ladder is likely to be faster on its own.
So not only do you gain speed by avoiding an exponentiation, you gain
speed by running a faster ladder.

While we *may* beat x-only ladders by using a complete addition law and
fixed windows, it would be more complex, and require more memory (stack
in most implementations). And a naive x-y ladder is about half the
speed of the x-only ladder, if not less (assuming constant time
implementations). This is horrible for embedded applications.

Alternatively, we could recover the y-coordinate *after* performing an
x-only ladder. With luck, it might not even cost an additional
exponentiation. Still, this feels like an avoidable complication, not
worth the single bit of security you could get by recovering the sign
of a point.

As an implementer, I have a very strong preference for x-only ladders:
not only are they fast, they're easiest to implement. Less room for
error.

Loup.