2 files were added to this release more than 14 days after its initial publication. Inspect the release files before installing.
ed25519-orlp -- a python wrapper around Orson Peters' ANSI C ed25519 implementation.
This package is only suggested for use in situations where you have a need to interoperate with ed25519 keys generated by Peters' original library (or the Node library @noble/ed25519, which derives from it), which used a private key representation derivative of the seed but not reversible to it, and whose keys are incompatible with most other ed25519 libraries (including all known Python implementations).
If you need ed25119 for any other purpose, consider pynacl.
Installing
Available in PyPI, or run
pip install ed25519-orlp.
License
ed25519-orlp inherits the zlib license, available for perusal in the LICENSE file.
Original README from Peters' library
Ed25519
This is a portable implementation of Ed25519 based on the SUPERCOP "ref10" implementation. Additionally there is key exchanging and scalar addition included to further aid building a PKI using Ed25519. All code is licensed under the permissive zlib license.
All code is pure ANSI C without any dependencies, except for the random seed
generation which uses standard OS cryptography APIs (CryptGenRandom on
Windows, /dev/urandom on nix). If you wish to be entirely portable define
ED25519_NO_SEED. This disables the ed25519_create_seed function, so if your
application requires key generation you must supply your own seeding function
(which is simply a 256 bit (32 byte) cryptographic random number generator).
Performance
On a Windows machine with an Intel Pentium B970 @ 2.3GHz I got the following speeds (running on only one a single core):
Seed generation: 64us (15625 per second)
Key generation: 88us (11364 per second)
Message signing (short message): 87us (11494 per second)
Message verifying (short message): 228us (4386 per second)
Scalar addition: 100us (10000 per second)
Key exchange: 220us (4545 per second)
The speeds on other machines may vary. Sign/verify times will be higher with longer messages. The implementation significantly benefits from 64 bit architectures, if possible compile as 64 bit.
Usage
Simply add all .c and .h files in the src/ folder to your project and include
ed25519.h in any file you want to use the API. If you prefer to use a shared
library, only copy ed25519.h and define ED25519_DLL before importing. A
windows DLL is pre-built.
There are no defined types for seeds, private keys, public keys, shared secrets
or signatures. Instead simple unsigned char buffers are used with the
following sizes:
unsigned char seed[32];
unsigned char signature[64];
unsigned char public_key[32];
unsigned char private_key[64];
unsigned char scalar[32];
unsigned char shared_secret[32];
Note: this library stores private keys in a different format than some other
libraries, notably libsodium. They tend to store the concatenation of the seed
and public_key as their private key representation. If you wish to be compatible
with these libraries you must keep the seed around.
API
int ed25519_create_seed(unsigned char *seed);
Creates a 32 byte random seed in seed for key generation. seed must be a
writable 32 byte buffer. Returns 0 on success, and nonzero on failure.
void ed25519_create_keypair(unsigned char *public_key, unsigned char *private_key,
const unsigned char *seed);
Creates a new key pair from the given seed. public_key must be a writable 32
byte buffer, private_key must be a writable 64 byte buffer and seed must be
a 32 byte buffer.
void ed25519_sign(unsigned char *signature,
const unsigned char *message, size_t message_len,
const unsigned char *public_key, const unsigned char *private_key);
Creates a signature of the given message with the given key pair. signature
must be a writable 64 byte buffer. message must have at least message_len
bytes to be read.
int ed25519_verify(const unsigned char *signature,
const unsigned char *message, size_t message_len,
const unsigned char *public_key);
Verifies the signature on the given message using public_key. signature
must be a readable 64 byte buffer. message must have at least message_len
bytes to be read. Returns 1 if the signature matches, 0 otherwise.
void ed25519_add_scalar(unsigned char *public_key, unsigned char *private_key,
const unsigned char *scalar);
Adds scalar to the given key pair where scalar is a 32 byte buffer (possibly
generated with ed25519_create_seed), generating a new key pair. You can
calculate the public key sum without knowing the private key and vice versa by
passing in NULL for the key you don't know. This is useful for enforcing
randomness on a key pair by a third party while only knowing the public key,
among other things. Warning: the last bit of the scalar is ignored - if
comparing scalars make sure to clear it with scalar[31] &= 127.
void ed25519_key_exchange(unsigned char *shared_secret,
const unsigned char *public_key, const unsigned char *private_key);
Performs a key exchange on the given public key and private key, producing a
shared secret. It is recommended to hash the shared secret before using it.
shared_secret must be a 32 byte writable buffer where the shared secret will
be stored.
Example
unsigned char seed[32], public_key[32], private_key[64], signature[64];
unsigned char other_public_key[32], other_private_key[64], shared_secret[32];
const unsigned char message[] = "TEST MESSAGE";
/* create a random seed, and a key pair out of that seed */
if (ed25519_create_seed(seed)) {
printf("error while generating seed\n");
exit(1);
}
ed25519_create_keypair(public_key, private_key, seed);
/* create signature on the message with the key pair */
ed25519_sign(signature, message, strlen(message), public_key, private_key);
/* verify the signature */
if (ed25519_verify(signature, message, strlen(message), public_key)) {
printf("valid signature\n");
} else {
printf("invalid signature\n");
}
/* create a dummy keypair to use for a key exchange, normally you'd only have
the public key and receive it through some communication channel */
if (ed25519_create_seed(seed)) {
printf("error while generating seed\n");
exit(1);
}
ed25519_create_keypair(other_public_key, other_private_key, seed);
/* do a key exchange with other_public_key */
ed25519_key_exchange(shared_secret, other_public_key, private_key);
/*
the magic here is that ed25519_key_exchange(shared_secret, public_key,
other_private_key); would result in the same shared_secret
*/
License
All code is released under the zlib license. See LICENSE for details.
Metadata
Release files for ed25519-orlp 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Files added late
2 files were uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release files before installing.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ed25519_orlp-0.1.3.tar.gz | 66.4 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ed25519_orlp-0.1.3-py3-none-musllinux_1_2_x86_64.whl | Python 3 | none | Linux musl 1.2+ x86-64 | Details |
| ed25519_orlp-0.1.3-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64, Linux glibc 2.5+ x86-64 | Details |
| ed25519_orlp-0.1.3-py3-none-macosx_26_0_arm64.whl | Python 3 | none | macOS 26.0+ ARM64 | Details |
Total release size: 553.5 kB
Release files / ed25519_orlp-0.1.3.tar.gz
| Download URL | ed25519_orlp-0.1.3.tar.gz |
|---|---|
| Size | 66.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5dfa52e8f63687f028ed0e3f8e2b385bffd22a630c740be642d73a532d0137dd
|
|
BLAKE2b-256 checksum How to use checksums |
c342d2bbe2ee047b3c37dd16ac0eec567f168ae141507d2641ec5060e54efad7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ed25519_orlp-0.1.3-py3-none-musllinux_1_2_x86_64.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | ed25519_orlp-0.1.3-py3-none-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 186.3 kB |
| Tags | Linux musl 1.2+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
5df6142e307d2db4b10e1a5a63fd2db787f3f9a9c3546abbf1be6b8f4aaf8459
|
|
BLAKE2b-256 checksum How to use checksums |
dfc0761a963f0b6fd5e59633d38d22d50b71a265df8c135eb50533b582bbd68f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / ed25519_orlp-0.1.3-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | ed25519_orlp-0.1.3-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 185.3 kB |
| Tags | Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
bc3d7aa7fa4570c6671e8b39604cf028709289e2681748e8185ad691815f75a3
|
|
BLAKE2b-256 checksum How to use checksums |
4e7147657d7bd1d88473450622f9a3418895e29de2474fbd494a23051a447db9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / ed25519_orlp-0.1.3-py3-none-macosx_26_0_arm64.whl
| Download URL | ed25519_orlp-0.1.3-py3-none-macosx_26_0_arm64.whl |
|---|---|
| Size | 115.6 kB |
| Tags | Python 3 macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b0711068ef1bd97986624ecf6c42a253199618d7aa291e7e9369a52030b0800c
|
|
BLAKE2b-256 checksum How to use checksums |
fdfa9e4aa13129bfbed54aeffcb7ea56c96d1dc2aa98e70a4300d6c58e180652
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|