LPsLux Proposals
Q-Chain
LP-4160

lp-4160-x25519-key-exchange


lp: 4160 title: X25519 Key Exchange description: EVM precompile for X25519 Diffie-Hellman, the standard ECDH function over Curve25519 in Montgomery form author: Lux Core Team (@luxfi) discussions-to: https://github.com/luxfi/lps/discussions status: Final implementation-rust: none implementation-cpp: none implementation-go: shipped type: Standards Track category: Core tags: [evm, precompile, x25519, diffie-hellman, key-exchange, classical-curve]

  • lp-4130
  • lp-9015

Abstract

This LP specifies X25519 Diffie-Hellman as an EVM precompile. X25519 is the ECDH function over Curve25519 in Montgomery form — the one used by TLS 1.3, the Signal protocol, age, and WireGuard. Contracts use it to derive a shared secret on-chain for encrypted communication or key agreement.

The interface is deliberately narrower than LP-4130's raw point arithmetic. X25519 hides the group: it takes a scalar and a peer's public value and returns a shared secret, and the clamping and low-order-point handling that make that safe are inside the function rather than the caller's responsibility.

Specification

Address

0x0000000000000000000000000000000000009203 — Privacy range.

Interface

The operation selector is the first byte of input.

0x01 ScalarMult: scalar(32) + point(32) -> shared_secret(32)
0x02 Basepoint:  scalar(32) -> public_key(32)

ScalarMult computes the Diffie-Hellman shared secret from a private scalar and a peer's public key. Basepoint computes a public key from a private scalar using the Curve25519 basepoint.

Gas Schedule

OperationGas
ScalarMult3,000
Basepoint3,000

Security Considerations

  1. Implementation uses golang.org/x/crypto/curve25519 with constant-time scalar multiplication.
  2. The raw DH output is not a key. It is a curve point coordinate, and its bits are not uniformly distributed. Feed it through a KDF (HKDF-SHA256) before using it as a symmetric key.
  3. Roughly 128-bit security. Not post-quantum — for PQ key exchange use X-Wing (LP-4920) or ML-KEM (LP-4600).
  4. Low-order point checks are handled inside the X25519 function per RFC 7748.
  5. A scalar passed to this precompile arrives in calldata, which is public. That is acceptable only for ephemeral scalars whose corresponding secret is discarded after the exchange. A long-lived private key must never be an argument to an on-chain call.

References

  • RFC 7748 — Elliptic Curves for Security (X25519, X448)
  • Source: github.com/luxfi/precompile/x25519/

Copyright (C) 2024-2026, Lux Industries Inc. All rights reserved.

Licensed under the MIT License.