Registry / auth-security / x25519

x25519

JSON →
library0.0.2pypiunverified

The `x25519` library (version 0.0.2) provides a pure Python implementation of the Curve25519 elliptic curve for Diffie-Hellman key exchange. It was last released in October 2021 and appears to be unmaintained, with no active development or official GitHub repository discoverable at the provided link. This library is distinct from the more robust and actively maintained X25519 implementations found in the `cryptography` library.

pip install x25519
INSTALL
IMPORT
SIG · X25519
X
x25519
auth-securityenv0.0.2
Install
1.5s avg
Import
22ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.022s · 17.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.5s · import 0.022s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

scalar_base_mult
import x25519 public_key = x25519.scalar_base_mult(private_key)
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey
This library is a separate, pure-Python implementation, not part of the 'cryptography' project.
scalar_mult
import x25519 shared_secret = x25519.scalar_mult(private_key, peer_public_key)
private_key.exchange(peer_public_key)
The API for this `x25519` package uses functional calls, not object methods like the `cryptography` library.

This quickstart demonstrates how to generate X25519 private and public keys and then derive a shared secret using the `x25519` library's `scalar_base_mult` and `scalar_mult` functions. Ensure private keys are truly random bytes in a real-world scenario.

import x25519 from binascii import hexlify # Generate a 32-byte private key (randomly in a real application) private_key_a = b'\x01' * 32 # Example: should be randomly generated private_key_b = b'\x02' * 32 # Example: should be randomly generated # Derive public keys public_key_a = x25519.scalar_base_mult(private_key_a) public_key_b = x25519.scalar_base_mult(private_key_b) print(f"Public Key A: {hexlify(public_key_a).decode()}") print(f"Public Key B: {hexlify(public_key_b).decode()}") # Compute shared secrets shared_secret_ab = x25519.scalar_mult(private_key_a, public_key_b) shared_secret_ba = x25519.scalar_mult(private_key_b, public_key_a) print(f"Shared Secret A->B: {hexlify(shared_secret_ab).decode()}") print(f"Shared Secret B->A: {hexlify(shared_secret_ba).decode()}") assert shared_secret_ab == shared_secret_ba print("Shared secrets match!")
Debug
Known issues
breakingThe GitHub repository linked in the PyPI metadata for this library is non-existent (404 Not Found), indicating the project is likely unmaintained and should not be used for new development.
fix
Migrate to a actively maintained and audited cryptography library, such as `cryptography` (e.g., `cryptography.hazmat.primitives.asymmetric.x25519`).
affects: 0.0.2 and potentially earlier
gotchaPure Python cryptographic implementations, especially for operations like X25519, can be vulnerable to timing attacks due to variations in execution time based on input values. This can leak sensitive information.
fix
For security-critical applications, prefer native code implementations (like those in `cryptography` which wraps OpenSSL) that are designed for constant-time execution.
affects: All versions
gotchaThis `x25519` PyPI package is a distinct, pure-Python implementation and is NOT the X25519 implementation provided by the `cryptography` library, which is the standard and recommended choice for robust cryptography in Python.
fix
If you intend to use the widely-accepted and audited X25519 implementation, install `cryptography` (`pip install cryptography`) and import from `cryptography.hazmat.primitives.asymmetric.x25519`.
affects: All versions
gotchaThe raw shared secret derived from X25519 should generally not be used directly as an encryption key. It should be processed through a Key Derivation Function (KDF) like HKDF to produce a strong, fixed-length key suitable for symmetric encryption.
fix
After obtaining the `shared_secret`, apply a KDF (e.g., from `cryptography.hazmat.primitives.kdf.hkdf`) to derive a secure symmetric key.
affects: All versions
Errors
Common errors & fixes
AttributeError: module 'x25519' has no attribute 'X25519PrivateKey'
Attempting to use `cryptography` library's object-oriented API with the `x25519` pure Python package.
fix
The `x25519` package uses functional calls (e.g., `x25519.scalar_base_mult`). If you intended to use the `cryptography` library, ensure it's installed (`pip install cryptography`) and import `from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey`.
TypeError: 'bytes' object cannot be interpreted as an integer
Incorrect input type for cryptographic functions. X25519 operations typically expect 32-byte `bytes` objects for keys.
fix
Ensure all key material (private keys, public keys) are precisely 32-byte `bytes` objects. Avoid passing strings or integers directly.
Upgrade
Version history
0.0.2latest on PyPI · released Oct 24, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
41 hits · last 30 days
node
34
OpenAI (training)
1
Resources

No resource links recorded.

x25519 — pip install x25519 · libregistry