Re: [CFRG] compact representation and HPKE

Michael Scott <mike.scott@miracl.com> Wed, 10 February 2021 12:29 UTC

Return-Path: <mike.scott@miracl.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 BC4F83A0E47 for <cfrg@ietfa.amsl.com>; Wed, 10 Feb 2021 04:29:27 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.098
X-Spam-Level:
X-Spam-Status: No, score=-2.098 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=miracl.com
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 267YAfhSl-uX for <cfrg@ietfa.amsl.com>; Wed, 10 Feb 2021 04:29:23 -0800 (PST)
Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 9FD703A0E3F for <cfrg@irtf.org>; Wed, 10 Feb 2021 04:29:23 -0800 (PST)
Received: by mail-yb1-xb31.google.com with SMTP id r2so1776330ybk.11 for <cfrg@irtf.org>; Wed, 10 Feb 2021 04:29:23 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=miracl.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=VTDDi68ddGfIwaCLOmhP64t3ei/+hDLSJvPnUrpXMJE=; b=dsBqo1qO6w1YO0N+ikF12zRf8yJkLgwYxaRZF88B7t6lDhwJwBqbSaBDeinGWmBObz FL9Bz+SMqAvU0ZHKwfy6vmeO3Bfy7I+Qu/dtlERNi3Geu2PDedDUa6Em/fw13J1Z3JFO ZwEnZuGgDY9ErnguS0qEyp9A3HY3e64+5/i8M0IJZdYmevg9lMsR67uo4us52EwXdqrj 3Oi3oSZSNQ96720RJFi672AUdPW6QMa02Xly2TimLFXYthO2BOtf++WIgwVr5kMfM5yq b0KccFDejDafuIcPISbLYpEPaWBQZWOSEBua2889all80w9ZpJPbW7mjjpdPorJYLjPu 6wxQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=VTDDi68ddGfIwaCLOmhP64t3ei/+hDLSJvPnUrpXMJE=; b=olcV5IjEUsHdUsmfH2Oooa9LHf0fWdcq+qEqkMhUg8Ay9LFJJxEBlYEBEfANWRl1fv xmjqZYbfuU4L4SmBXCuFWPA3tAiafwP1eGw4OqDrtXEaPcJ4/Hr+N9yQfpmu2Ta1IMAT SmVl4o9ecqGaduHj88W8maq+fd6300FyB2OE7uxlxiyHAA05v58/v4SSXPB7qySp32b1 +N/Hr1vh8XF3Px9ULM2Jv3SvUp/H2/+NhJDHCPd8iAsNVtcsViNpJfMEWuupdk+z1RiC jR3TqJN0wAyFkbRc6yg7gUx6ljA47M203TYF6qmyFuaCKwqXyATOOLEJRxgDAM/iMNVL hblQ==
X-Gm-Message-State: AOAM530UP0y6YvawEEjwFqUIMQFjEOOsLlWr2AeNjE3Uc7nwiEUUWmhL m6ZCiEcAmkenKN2L/9zSGEd6TXM5xX1GRx7qFC5VmDTQ9nc=
X-Google-Smtp-Source: ABdhPJwW3gbUaqEPuuCPHm7Ji0yzBLsFGYGD/py2YXAXF2lyh62X/l/4/f2q2M1uJkKG5t/r9ky+7S9bYYR4FKnCAdM=
X-Received: by 2002:a5b:887:: with SMTP id e7mr3779316ybq.15.1612960162369; Wed, 10 Feb 2021 04:29:22 -0800 (PST)
MIME-Version: 1.0
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>
In-Reply-To: <CAEseHRpZE7=smgZs-te4yDb1kTD6aSg92mASn_WZrsB=FqdisQ@mail.gmail.com>
From: Michael Scott <mike.scott@miracl.com>
Date: Wed, 10 Feb 2021 12:29:38 +0000
Message-ID: <CAEseHRr4TZ9hf1KLhVh+A3ku=RYm8Ycn2b5KdLsamO7sio1v5g@mail.gmail.com>
To: CFRG <cfrg@irtf.org>
Content-Type: multipart/alternative; boundary="00000000000083eedf05bafa8dbd"
Archived-At: <https://mailarchive.ietf.org/arch/msg/cfrg/5V48hzWeT99nRLr0lc-Is_Fl3as>
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 12:29:28 -0000

... but then again if y is definitely not needed, maybe there truly is no
downside.

Mike

On Wed, Feb 10, 2021 at 12:28 PM Michael Scott <mike.scott@miracl.com>
wrote:

> Well, there is a minor downside - the recipient has to do some extra work
> (a modular square root) to reconstitute the y coordinate.
>
> For an enfeebled recipient this might be quite onerous.
>
> Mike
>
> On Mon, Feb 8, 2021 at 10:42 PM Dan Harkins <dharkins@lounge.org> wrote:
>
>>
>>   Hello again,
>>
>>   I'd like to resurrect this before it becomes "it's too late to make
>> changes
>> that affect the wire". I created a pull request on github some time ago
>> but
>> it's been ignored so let me try again here (we still technically do our
>> work
>> on mailing lists).
>>
>>   When I brought it up initially there was a +1 and, as Mike notes, the
>> y-coordinate is not needed. This 04 || x || y format for a key is just
>> some
>> ancient Certicom proposal and there's really no reason to perpetuate that.
>>
>>   The y-coordinate is extraneous. Getting rid of it for the NIST curves
>> will
>> make the API much cleaner and consistent.
>>
>>   This will reduce the size of the serialized public key by more than 50%
>> and for apps that care about such things this would be a tremendous
>> improvement.
>>
>>   Richard noted that one can lop off the 04 and the y-coordinate after
>> serialization and pass x alone as part of the app using HPKE and then have
>> the other size reconstruct it (with either y since the sign doesn't
>> matter) before passing it on to be deserialized. While technically true,
>> that completely defeats the whole point of formalizing this process.
>>
>>   In my pull request I noted that it does change the test vectors and that
>> I would be happy to generate them. Well, I did it. I have new test vectors
>> (based on -07) and will happily contribute them if asked. If the test
>> vectors
>> get changed again (with a new version string) I can reproduce new ones
>> minus
>> the y-coordinate in a matter of minutes.
>>
>>   Please consider this request. There is no downside to it.
>>
>>   regards,
>>
>>   Dan.
>>
>> On 11/6/20 4:44 PM, Dan Harkins wrote:
>>
>>
>>   Yes, this is exactly right. The y-coordinate is not needed for these
>> KEMs
>> as the sign is unimportant.
>>
>>   The spec will be simpler and the interface more uniform if you do this.
>>
>>   The whole point of HPKE is to make a callable API out of this process
>> that
>> had been done ad hoc. Requiring a app that is taking advantage of this
>> API
>> to take the output of the API and parse through it, throwing away one half
>> of one of the output strings and lopping off the first octet, is defeating
>> the whole purpose and is expecting a lot. The more this is a black box the
>> better.
>>
>>   regards,
>>
>>   Dan.
>>
>> On 11/6/20 3:19 PM, Mike Hamburg wrote:
>>
>> Hello Richard,
>>
>> I haven’t paid much attention to HPKE, so it’s likely I’m missing
>> something here, but why not use the x-only Montgomery ladder on NIST
>> curves?  That’s the fastest and simplest approach, and it can operate with
>> or without the y-coordinates.
>>
>> Also, some implementations do not compute both the x- and y-coordinates,
>> and it would be more convenient not to compute or send even a sign bit if
>> you’re intending to use an x-only ladder.
>>
>> Cheers,
>> — Mike
>>
>> On Nov 6, 2020, at 10:19 PM, Richard Barnes <rlb@ipv.sx> wrote:
>>
>> Nothing about this says that you have to *send* the keys uncompressed.
>> You can use whatever representation you want on the wire.  You just have to
>> decompress them before you put them into the key schedule. Which you're
>> probably doing anyway, because you need both coordinates to do point
>> multiplication with these curves.  So I am inclined not to make this change.
>>
>> --Richard
>>
>> On Fri, Nov 6, 2020 at 4:52 PM John Mattsson <john.mattsson=
>> 40ericsson.com@dmarc.ietf.org> wrote:
>>
>>> +1
>>>
>>> Sending the keys uncompressed makes HPKE unsuitable for constrained IoT.
>>>
>>> -----Original Message-----
>>> From: CFRG <cfrg-bounces@irtf.org> on behalf of Dan Harkins <
>>> dharkins@lounge.org>
>>> Date: Friday, 6 November 2020 at 21:00
>>> To: CFRG <cfrg@irtf.org>
>>> Subject: [CFRG] compact representation and HPKE
>>>
>>>    Hello,
>>>
>>>    When doing a DH-based KEM with the NIST curves, HPKE specifies that
>>> SerializePublicKey and DeserializePublicKey use the uncompressed format
>>> from SECG. This ends up using 2*Ndh+1 octets to represent the serial
>>> form of the public key.
>>>
>>>    Since compact output is being used in DH-based KEMs-- that is, the
>>> secret result of DH() is the x-coordinate of the resulting EC point--
>>> it would also be possible to use compact representation (per RFC 6090)
>>> and have SerializePublicKey merely do integer-to-octet string
>>> conversions of the x-coordinate. DeserializePublicKey would then
>>> do octet string-to-integer conversion for the x-coordinate and use the
>>> equation of the curve to choose the y-coordinate. The sign isn't
>>> important because we're doing compact output.
>>>
>>>    This would make the interface for the NIST curves and the Bernstein
>>> curves be uniform-- Serialize would produce an octet string of Ndh
>>> and Deserialize would consume an octet string of Ndh-- at the cost
>>> of some CPU inside DeserializePublicKey.
>>>
>>>    Please consider this suggestion.
>>>
>>>    regards,
>>>
>>>    Dan.
>>>
>>> --
>>> "The object of life is not to be on the side of the majority, but to
>>> escape finding oneself in the ranks of the insane." -- Marcus Aurelius
>>>
>>> _______________________________________________
>>> CFRG mailing list
>>> CFRG@irtf.org
>>>
>>> https://protect2.fireeye.com/v1/url?k=513cd874-0ea7e231-513c98ef-867b36d1634c-ce26b08a2499b9a3&q=1&e=4f2b4ce0-8d52-4a80-b41e-0f7537355d35&u=https%3A%2F%2Fwww.irtf.org%2Fmailman%2Flistinfo%2Fcfrg
>>>
>>> _______________________________________________
>>> CFRG mailing list
>>> CFRG@irtf.org
>>> https://www.irtf.org/mailman/listinfo/cfrg
>>>
>> _______________________________________________
>> CFRG mailing list
>> CFRG@irtf.org
>> https://www.irtf.org/mailman/listinfo/cfrg
>>
>>
>>
>> _______________________________________________
>> CFRG mailing listCFRG@irtf.orghttps://www.irtf.org/mailman/listinfo/cfrg
>>
>>
>> --
>> "The object of life is not to be on the side of the majority, but to
>> escape finding oneself in the ranks of the insane." -- Marcus Aurelius
>>
>>
>> _______________________________________________
>> CFRG mailing listCFRG@irtf.orghttps://www.irtf.org/mailman/listinfo/cfrg
>>
>>
>> --
>> "The object of life is not to be on the side of the majority, but to
>> escape finding oneself in the ranks of the insane." -- Marcus Aurelius
>>
>> _______________________________________________
>> CFRG mailing list
>> CFRG@irtf.org
>> https://www.irtf.org/mailman/listinfo/cfrg
>>
>