Skip to content

Add ELIP: Hybrid Key Encapsulation for secp256k1 Keys - #46

Open
juja256 wants to merge 13 commits into
ElementsProject:mainfrom
juja256:main
Open

juja256 wants to merge 13 commits into
ElementsProject:mainfrom
juja256:main

Conversation

@juja256

@juja256 juja256 commented Oct 15, 2026 •

Copy link
Copy Markdown

This ELIP specifies a new cryptographic primitive, Hybrid Key Encapsulation (HKE), for secp256k1. Built on the UG combiner of Hybrid PQ/T Key Encapsulation Mechanisms, it augments Elliptic Curve Diffie-Hellman (ECDH) key exchange on secp256k1 with the post-quantum key encapsulation mechanism ML-KEM-768 from FIPS203. HKE aims to protect the confidentiality of protocols that rely on ECDH on secp256k1 (e.g. Confidential Assets, BIP47 reusable payment codes and NIP-44 Nostr encrypted messages) against attackers with a cryptographically relevant quantum computer (CRQC).

Comment thread elip-hybrid-key-encapsulation.mediawiki Outdated
Particularly, it solves the Computational Diffie-Hellman (CDH) problem, so the protocols that use Elliptic Curve Diffie-Hellman (ECDH) key agreement are vulnerable.
The retroactive CRQC attacks typically affect the privacy of users in such protocols.
This document specifies '''HKE''', a hybrid key encapsulation built on top of the QSF framework from [https://eprint.iacr.org/2024/039 X-Wing] that derives a 32-byte secret <code>K</code> from two parts: an ECDH on <code>secp256k1</code> and a post-quantum key-encapsulation mechanism [https://csrc.nist.gov/pubs/fips/203/final <code>ML-KEM-768</code>], combined so that <code>K</code> remains pseudorandom even if either component is compromised.
Compared to <code>ML-KEM-768</code> deployment in isolation, HKE provides a classic ECDH fallback if some advances in lattice-based cryptography become available.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this to motivation

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is already a similar sentence, so just removed

Comment thread elip-hybrid-key-encapsulation.mediawiki Outdated

<code>KeyGen</code> draws <code>msk</code> uniformly at random to keep the description self-contained.
In practice, wallets derive <code>msk</code> deterministically under the key derivation rules of the application, so that a wallet restored from its backup recomputes <code>msk</code> and recovers its outputs.
This document does not fix that derivation: any derivation is acceptable if <code>msk</code> is indistinguishable from a uniformly random 32-byte string to anyone who does not hold the wallet's secret, and the [[#security|Security]] argument is then unchanged.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the requirements for msk derivation should be slightly different.

We need to protect msk from an adversary who can calculate discrete logs of every known (published) secp256k1 pubkey.

Because if msk derived from the key whose pubkey has ever appeared somewhere public (legacy CT address for the same script, or a non-hardened xpub path, etc) -- CRQC recovers msk and all derivatives.

My proposal is to change it to something like: "derive msk only via hash, HMAC, or hardened derivation from secrets whose public keys are never published, under its own domain separation, ..."

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored that, gave a good and a bad example of msk derivation

Comment thread elip-0222.mediawiki
===KEM interface===

For the <code>ML-KEM-768</code> parameter set of [https://csrc.nist.gov/pubs/fips/203/final FIPS 203], the KEM interface is as follows:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to give a definition for all parameters, it would be clearer for the reader, and some of them do not match with ones from the standard (like K_q is K from FIPS)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, refactored that

Comment thread elip-0222.mediawiki
The vendored copy of secp256k1lab keeps its own MIT License.

===Motivation===

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameter rationale is missing

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

…n the ROM

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RuvTE3pn1NGH8WzhwUfMkC

@jonasnick jonasnick left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

Comment thread elip-hybrid-key-encapsulation.mediawiki Outdated
# '''The strong Diffie–Hellman problem on <code>secp256k1</code> is hard.''' This protects <code>K</code> against classical adversaries if <code>ML-KEM-768</code> is broken: computing <code>K_c</code> requires <code>e*B</code> from <code>B</code> and <code>E</code>, and, as in X-Wing, the proof answers decapsulation queries with a strong Diffie–Hellman oracle.

HKE additionally hashes <code>c</code> and <code>ek</code>, which X-Wing omits.
Because <code>c</code> is hashed, condition 1 needs only that <code>ML-KEM-768</code> is IND-CCA secure; X-Wing omits <code>c</code> and therefore relies on further properties of <code>ML-KEM-768</code>.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm being told that this isn't quite right. condition 1 needs only ML-KEM IND-CCA whether or not c is hashed (X-Wing's Theorem 2 proves this for a combiner without c). What hashing c buys is condition 2: if ML-KEM is broken and c is omitted, an attacker who finds c' != c* with the same K_q can query Decaps(E*, c') and get the challenge key, which is why X-Wing's classical proof (Theorem 1) needs ML-KEM to be ciphertext collision resistant.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, elaborated on that more

Comment thread elip-0222.mediawiki
Replacing <code>ECDH(e, B)</code> with HKE and using its shared secret <code>K</code> as the range-proof seed requires the recipient's address to carry the ML-KEM encapsulation key <code>ek</code> alongside <code>B</code>, and each confidential output to carry the ciphertext <code>c</code> alongside <code>E</code>.
The range-proof code is unchanged, since it takes a 32-byte seed either way.

===BIP47 reusable payment codes===

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the new payment-code version only protects the notification. Per-payment addresses would still come from ECDH between the payment codes' points, which are meant to be public.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, the previous description of a new payment-code version was too vague; fixed that a bit

Comment thread elip-hybrid-key-encapsulation.mediawiki Outdated

==Description==

''HKE'' proposed in this ELIP is a slightly modified instantiation of '''QSF''' (''Quantum Superiority Fighter'') — the generic hybrid-KEM combiner framework the [https://eprint.iacr.org/2024/039 X-Wing paper] specifies.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is QSF really the closest cousin to this ELIP? Because it hashes c and ek, it may be more closely related to the generic combiner of Giacon–Heuer–Poettering (PKC 2018). This is specified in a CFRG draft as "UG": https://datatracker.ietf.org/doc/draft-irtf-cfrg-hybrid-kems/. Either way, I think we should cite (or even increase compatibility with) the CFRG draft because it validates our approach. Similar to NIST SP 800-227, "Recommendations for Key-Encapsulation Mechanisms", which recommends the combiner shape.

@juja256 juja256 Nov 9, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, it's better move to a GHP instantiation. For the moment this was written I was unaware of UG framework so this draft was heavily inspired by X-Wing design, but adding missing terms to the transcript was merely an intuitive decision rather then the deliberate framework choice. I think we should aslo reorder the arguments order in the combiner to match the UG interface, it's not the big deal though (have to adjust the test vectors).

@delta1

delta1 commented Nov 9, 2026

Copy link
Copy Markdown
Member

Thank you @juja256 - let's assign ELIP number 222

  [https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hybrid-kems-12]
  instad of X-Wing’s QSF;
- elaborate on BIP47 application a bit
- adjust the test vectors
- assign the ELIP number 222
- removed label
- reworked description
- expand rationale with combiner choice and other details
- other minor refinements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants