[CFRG] Re: Cross-testing update on LAMPS Composite and cfrg-concrete-hybrid-kems

Mike Ounsworth <ounsworth+ietf@gmail.com> Tue, 21 October 2025 19:14 UTC

Return-Path: <ounsworth@gmail.com>
X-Original-To: cfrg@mail2.ietf.org
Delivered-To: cfrg@mail2.ietf.org
Received: from localhost (localhost [127.0.0.1]) by mail2.ietf.org (Postfix) with ESMTP id E428D79C2F8F for <cfrg@mail2.ietf.org>; Tue, 21 Oct 2025 12:14:06 -0700 (PDT)
X-Virus-Scanned: amavisd-new at ietf.org
X-Spam-Flag: NO
X-Spam-Score: -1.098
X-Spam-Level:
X-Spam-Status: No, score=-1.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, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=no autolearn_force=no
Authentication-Results: mail2.ietf.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
Received: from mail2.ietf.org ([166.84.6.31]) by localhost (mail2.ietf.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BDb5qRNWGc3x for <cfrg@mail2.ietf.org>; Tue, 21 Oct 2025 12:14:06 -0700 (PDT)
Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail2.ietf.org (Postfix) with ESMTPS id 47E5879C2EA9 for <cfrg@irtf.org>; Tue, 21 Oct 2025 12:13:37 -0700 (PDT)
Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-430b621ec08so49576615ab.0 for <cfrg@irtf.org>; Tue, 21 Oct 2025 12:13:37 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761074011; x=1761678811; darn=irtf.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=PJq3+VUFzj8aYxEh7eqGPash01CTexCBWjBuTanTR8s=; b=atWBlVOmOcOYz8Z5YCGkdBtx4dPudxWNkvSHG9oW/350tlsvHVMuJUuwYZ4mxNS5Kw 05S7Hfpin1KOib1MihEex7KwCmOQs+a780fg41iW/gpSbQ8waqc/nlLJArwpDSMS/WvE h4jUOI59ARVRQsDchs3r1nqird6t6swF+qC6c5MWatthnc0tsOr11lefp1jNPAr8Xeqo 7p8rSPqIAX/pNg5wb82l92FPE2wfU0Xm4337l3fNaO3hXM1MrlLXZSFNkLiZBn9ZQpK6 9xVZVdD+jyCfUq12obZOLHKoxLJwAW07x9PVmGRzyxYwhU5HU6ewjOsCSTe7WrJFOw5N A/fg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761074011; x=1761678811; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PJq3+VUFzj8aYxEh7eqGPash01CTexCBWjBuTanTR8s=; b=Dbl/011vNmZt9fifiECCHdZxZYjKgGxuyh1fVPw0o/KIaGxeWnN4IBEq+VIWRxse+r 0vGHt0AR+xN1CJj3arpv5oCQ48PZS3jPN9Lx1/UAUtCkwRsC7PHG9fKAWGoF1pJL/jCD QBf0oDFHXtiGag80+ecSv/VmBSn2Y9HNkWbClNC0CKju+D5HVeIV7jzzyvPg0knB7PyR uqwuLAfVjIrAGCLt4k28nr9BjkasiTcossyoBS7Nl6xC4wS6Y3ClK2WzDcons70NaTES 3UVCnX3Au9xEgoa/5XxviyyIQ9dD4PYdQXr5hrI9pBhZuj327+IZwdSLigEccIWKxLLi CbzA==
X-Forwarded-Encrypted: i=1; AJvYcCURf+43epMCexlqgd9SKu2sACczgQ/dUBJ34CtM1WbZIxcKJv7zEh3cIjcRPlIUWtygQ5ri@irtf.org
X-Gm-Message-State: AOJu0YztcszN1ktNGhgb9/zcNQ1tpG2TGryK4SQUr9lXS4t7oJEDvcqI xVqTBY+f7R3sP/lIeaFC52e4hotAp/cOSiywmh/5TxjzgSveMylNWaktOZ+W8QJLpmXkGxQ1Oka TH/pF363H2YAAKL3gHzSqMWF1Nckkg8A=
X-Gm-Gg: ASbGncvWd2szEmxD7GejhhGUf2Dc7ozaejsO0UNNjpbJPAmvGTshI549uFH5EP962vu AAO/VF2EjSiLTGRAu86NhzCNEK+yxFokjSjPg+Y1un8N1FOmnIKPxzLgI1e8je2eindr8pxPNDy BykMxsYDxLu5qK1Sjiu220ZJfwpxQGCNl8P3iIPrnv08zwUBS/aEQ5/g1aRly83vR50JN93Sv8a qqFfbbGafUV9MGUOMnHUmeeCgqQLgib4CKi/Xo+8DQLl1rTibAHsaTZF41Tmo4=
X-Google-Smtp-Source: AGHT+IHOYmsLsrNRY79zle+oUZO1M0IIvWQPMDwcdKhiqGePIAbmAsidO6gl8MFNzskVwsWzvUigwSWoxrcRbUp//BM=
X-Received: by 2002:a05:6e02:1a2b:b0:430:ab98:7b27 with SMTP id e9e14a558f8ab-430c527d375mr257490935ab.20.1761074011330; Tue, 21 Oct 2025 12:13:31 -0700 (PDT)
MIME-Version: 1.0
References: <CAKZgXHoi88=hETRtacXgph0pscmU4VreGxOHTsEgbecLJT1opQ@mail.gmail.com> <21e583cf-a58c-4ff2-8ef6-e4c894525dd9@app.fastmail.com> <CAKZgXHpJKUVurxvWYKdrioMH1yKRFot8svAsuc2VXYwGxZ2jNw@mail.gmail.com> <CAJfyev290iHbckqaQJaX4pnySVwnp4_oSfbL1M8JQgji1MQsEg@mail.gmail.com> <CAKZgXHovWwAErpaUcW_KxW0Xx5-0TQT_=SWp9cCf6OZokxeeNQ@mail.gmail.com>
In-Reply-To: <CAKZgXHovWwAErpaUcW_KxW0Xx5-0TQT_=SWp9cCf6OZokxeeNQ@mail.gmail.com>
From: Mike Ounsworth <ounsworth+ietf@gmail.com>
Date: Tue, 21 Oct 2025 14:13:20 -0500
X-Gm-Features: AS18NWBlPlRXnn1BfKAFUrqtkhQmHRjNUV0l9Zlz91RIlhsPvnMU1PDDKcr4m_U
Message-ID: <CAKZgXHo-BQzVARL-jxDDA+veXs1ytj-LmDLDWcviH5M8SpDEWg@mail.gmail.com>
To: Tushar Patel <tjpatel.tl@gmail.com>
Content-Type: multipart/alternative; boundary="000000000000de62e40641affee1"
Message-ID-Hash: JYM26CO4W5D7F7Q2MPBCXKSWANWXEZY2
X-Message-ID-Hash: JYM26CO4W5D7F7Q2MPBCXKSWANWXEZY2
X-MailFrom: ounsworth@gmail.com
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-cfrg.irtf.org-0; header-match-cfrg.irtf.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
CC: CFRG <cfrg@irtf.org>, hpke@ietf.org, LAMPS WG <spasm@ietf.org>
X-Mailman-Version: 3.3.9rc6
Precedence: list
Subject: [CFRG] Re: Cross-testing update on LAMPS Composite and cfrg-concrete-hybrid-kems
List-Id: Crypto Forum Research Group <cfrg.irtf.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/cfrg/iG5TjPVVpKE7a7iWepfj8yl0gfk>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cfrg>
List-Help: <mailto:cfrg-request@irtf.org?subject=help>
List-Owner: <mailto:cfrg-owner@irtf.org>
List-Post: <mailto:cfrg@irtf.org>
List-Subscribe: <mailto:cfrg-join@irtf.org>
List-Unsubscribe: <mailto:cfrg-leave@irtf.org>

Follow-up: I see that DHKEM.DeriveKeyPair(ikm) is defined in RFC9180:
https://datatracker.ietf.org/doc/html/rfc9180#derive-key-pair

That makes liberal use of HPKE's LabelledExtract(), which fully explains
why this is not compatible with the python API.

That means that a seed-based key derivation is defined for P-256, P-384,
and P-521, but only within the confines of the DHKEM primitive within
the HPKE protocol. It is still the case that a seed-based key derivation is
not defined for ECDH in general.

So, on that grounds, I object to draft-irtf-cfrg-concrete-hybrid-kems
RECOMMENDING a seed-based priv on exactly the same grounds that anyone else
would object to it RECOMMENDING an ASN.1 based encoding: this is a CFRG
document that normatively depends on a building block that only exists in
one single IETF protocol, and most importantly to me, does not exist in
FIPS or current cryptographic libraries.

On Tue, 21 Oct 2025 at 13:34, Mike Ounsworth <ounsworth+ietf@gmail.com>
wrote:

> Hi CFRG and HPKE,
>
> I just want to give an update on this. Richard and I did some more
> cross-testing this week, and we are at an impasse on the SEC-P curves, and
> it has to do with the seeds. The CFRG /HPKE draft stores the hybrid private
> keys as a seed, so you have to re-derive the P256 half from a seed. My
> problem is that ECDH is a thing that has been standardized for like 20
> years in [SEC1] and [SP.800-56A], and those two documents do not specify or
> allow a seed-based EC keygen, and as a consequence, many crypto libraries
> don't support a seed-based EC keygen API. For example, I'm doing my
> reference implementation for Composites on top of the core python
> cryptography library, and I cannot implement the CRFG / HPKE draft that
> way. Python crypto has this:
>
> https://cryptography.io/en/latest/hazmat/primitives/asymmetric/ec/#cryptography.hazmat.primitives.asymmetric.ec.derive_private_key
> but that appears to not derive the same keys as Richard's implementation.
>
> The issue is that EC.derive_priv_from_seed() is not a standardized
> function. You can probably infer from a careful read of [SEC1] or
> [SP.800-56A] what it needs to be, but it is not actually standardized or
> FIPS-allowed. It requires mucking around with EC point multiplication. The
> fact that it's not a standardized thing means that I will likely not be the
> last person to have interop problems with this. Maybe my issues are as
> simple as not using that python ec.derive_private_key() properly, maybe his
> scalar is 'big' rather than 'little' or something. If that's the case, I'd
> be happy -- but this is the kind of mess you get into when you use
> non-standardized APIs for existing 20 year-old primitives.
>
> So at this point, I think we have to declare non-compatibility between
> LAMPS and HPKE Hybrid KEMs. Since our X-Wings are compatible, we know that
> our QSF frameworks are identical, so in principle our P256's should work
> too, but we're been incapable of testing it because this off-spec seed
> stuff is getting in the way.
>
> On Thu, 16 Oct 2025 at 17:40, Tushar Patel <tjpatel.tl@gmail.com> wrote:
>
>> Sorry, jumping in a running train and
>> many years ago while working through JSON bindings for the tests, I ran
>> into a sign bit conversion error on big numbers and had to rewrite part of
>> the library, the fixed code is with a previous employer, 64-bit and 128-bit
>> in JSON libs are a mess or sign bit issues in general.
>>
>> Also, please make sure that you are parsing the compressed notations for
>> ECC correctly, some libraries pack those incorrectly and also wrote my own
>> ASN.1 parsers for some elements, you might be surprised where I hit these
>> areas, can’t disclose, though both were from reputed organizations.
>>
>> Last, please make sure you have matching generators and incorporate the
>> affine and infinity checks, these may translate to all sorts of weird
>> issues that are impossible to debug through OSS macros in most cases.
>>
>> There is substandard ECC, ECDSA and ECDHE at many places in OSS libs and
>> you may have to debug these.
>>
>> Personally, I think NIST should mandate pristine implementations as
>> companies spend a lot more time fixing other implementations than their own.
>>
>> Hope it’s Useful,
>> Tushar
>>
>> On Thu, Oct 16, 2025 at 8:45 AM Mike Ounsworth <ounsworth+ietf@gmail.com>
>> wrote:
>>
>>> Thanks Filippo,
>>>
>>> Richard and I did some debugging last night. He gave me new test vectors
>>> that include that bug fix to the P256 / P384 constants.
>>>
>>> My current theory is that the code I quickly whipped up to do a P256
>>> private key expansion from seed does not match Richard's. Since this is
>>> wholly out of scope for LAMPS Composite (we store the full P256 private
>>> key), I'm hoping that Richard can give me a dump of intermediate values
>>> that includes the expanded P256 / P384 private key so that we don't need to
>>> debug through the P256-from-seed stuff. Anyway, this is all good validation
>>> of both our test vectors.
>>>
>>> Anyway, making progress!
>>>
>>> On Thu, 16 Oct 2025 at 10:29, Filippo Valsorda <filippo@ml.filippo.io>
>>> wrote:
>>>
>>>> 2025-10-16 03:55 GMT+02:00 Mike Ounsworth <ounsworth+ietf@gmail.com>:
>>>>
>>>> Results: we are cross-compatible on X-Wing, but not on P256 (and that's
>>>> after hacking my script to use the CFRG label not the LAMPS label, so
>>>> there's clearly some other bug at play, but I have no idea what, so of
>>>> course I assume it's on the cfrg reference impl side 😋).
>>>>
>>>>
>>>> Could be
>>>> https://github.com/cfrg/draft-irtf-cfrg-concrete-hybrid-kems/pull/21.
>>>>
>>> _______________________________________________
>>> CFRG mailing list -- cfrg@irtf.org
>>> To unsubscribe send an email to cfrg-leave@irtf.org
>>>
>>