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

Mike Ounsworth <ounsworth+ietf@gmail.com> Tue, 21 October 2025 18:35 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 26CFC79BC526 for <cfrg@mail2.ietf.org>; Tue, 21 Oct 2025 11:35:13 -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 0kBbLNvIe5Xk for <cfrg@mail2.ietf.org>; Tue, 21 Oct 2025 11:35:12 -0700 (PDT)
Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) (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 9870A79BC521 for <cfrg@irtf.org>; Tue, 21 Oct 2025 11:35:12 -0700 (PDT)
Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-430e1f19a1aso992355ab.1 for <cfrg@irtf.org>; Tue, 21 Oct 2025 11:35:12 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761071712; x=1761676512; 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=/xMX8aiMvD7gYUNzq67p9PdVPDSLximEkFF4J6uSL6s=; b=XgklQWsRvIlMyfxrgU3f/aIb7FDzuGgDfsDPbqIwsCAw3PDyOvpXvCz4ei5njQMVDy IrrRTMSAK0iXXSZmSrGsbSfpcX6WDFFAIL+ZpUIXvldaas6RU1/70Q/XRpwLM06dmpk+ rzyAuU60YpI7ZC7dvMfGuPAauKr8SRFnQiLbi3phDDnml63plpj2Q97cWmZaFVu4aP3G HeSg9vebZFJwciFn9F80WHktGTphJpBVa7HyfYZIOxkkZlQwBxHg9v7YuJLGeE2qaGYM g6Vf+UT+ulTE3s3vP8Yae3cx6WLWQZQshmKdnlvYzw6I6tREQezHm/mtyYBoY/thOIds UxUg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761071712; x=1761676512; 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=/xMX8aiMvD7gYUNzq67p9PdVPDSLximEkFF4J6uSL6s=; b=Sg+MjAPtALLzxTNsP48gvrfFra48qCNa1ksebMd8V68C3BNHbTAQATEDmNwfe0DzoX DnyJXhq8phgTRpsEo3rCr/i+N5lvbbu0tAREWs65m9Ick3Hqyd77UZ7ItP0fuRLeEPRe 2d8nnvD/dbyIvSP3oBrcOG5UqeVBtBsF49gpKuK25BLeACAyTWp1ChIJKTYIB3EpxNbR lWQ5Smw/Ztd3mXg0kIw2/5BalROxJEPQgAG6aSowmDX0csEmUNP5OwzmYI96XSIK5+nJ kix4Efa4nDBCVgYJ75r3ZK5xLHHSBiYjqeQ4ALKnkyyHqjJpIh71ol2IHt8wq6ei6T8R wfzQ==
X-Forwarded-Encrypted: i=1; AJvYcCVqRlffBikYOrZhYtDY1vFj5+kL8DuX6aCJxhtNJFvM4HHzdbw86E5VeOzLaG0ewokyaPi4@irtf.org
X-Gm-Message-State: AOJu0Yy9w4HEo1DrVgJo95jqL8YjESqqLCugMz2aI4GmuUKBajN6PS1O NEETpRDOjrE/RjaFESqXkvle80uSjGJ0mGPAFJuZX4NCnERLfosAgQwfMXIsH00CfsPEQxC1Oac EiuPfdLDdI0Zi7uw2Ir3PzbyQ7akieLw=
X-Gm-Gg: ASbGnctpHSAGuUti6fA7qGll/TfEEXD5OqtZayL+z9XApFnVCpNMhC74+VTZk0IAhmJ +RyLmAZs87qko8o3h9fFfyiqtslMPljNdl7UnxL6aGpG+Y/0dZbIC314hAl9RIy0YnUmfkvXrM/ a3TMgYTbifXcpBJc7A4E8mBywHmx0fxGsWpcz5frB0FtFQGhJCWPJvP5SPBh9R7v5IF40aeEr1h qkezge7YnKZRRwGdh3NmwqiVFlW/CT68dwovz6WJH/qAIg3Js4VXsdjGN9StzjOW9NQat3UOww+ OcQn0kL0
X-Google-Smtp-Source: AGHT+IGgNV+qB9k7QdYQEZFBnYiuGyByi5pfay0ulZ6P6mMp2TDxpxSlNxNCHg/R3ZmXDYTmsRZjgwhK0By8VkCgshI=
X-Received: by 2002:a05:6e02:1988:b0:424:805a:be98 with SMTP id e9e14a558f8ab-431d31b765emr8337595ab.9.1761071711695; Tue, 21 Oct 2025 11:35:11 -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>
In-Reply-To: <CAJfyev290iHbckqaQJaX4pnySVwnp4_oSfbL1M8JQgji1MQsEg@mail.gmail.com>
From: Mike Ounsworth <ounsworth+ietf@gmail.com>
Date: Tue, 21 Oct 2025 13:34:50 -0500
X-Gm-Features: AS18NWBoLZC3JMl766FO1-MwAXriYQarlYzRvDGYe6qfGClVbcihuSv05opv94w
Message-ID: <CAKZgXHovWwAErpaUcW_KxW0Xx5-0TQT_=SWp9cCf6OZokxeeNQ@mail.gmail.com>
To: Tushar Patel <tjpatel.tl@gmail.com>
Content-Type: multipart/alternative; boundary="000000000000ccb7480641af75b3"
Message-ID-Hash: 3ADCNSKKPBXFUVPXLQ3GR6H375HXIK6V
X-Message-ID-Hash: 3ADCNSKKPBXFUVPXLQ3GR6H375HXIK6V
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/GX2hHXxnr2UfAhnGw4LlXSekgx8>
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>

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
>>
>