nkeys
A public-key signature system based on Ed25519 for the NATS ecosystem.
What it is and what it does
nkeys is a Python library that implements Ed25519-based public-key cryptography tailored for the NATS messaging ecosystem. It handles the generation, storage, and use of cryptographic key pairs for identity, authentication, and authorization of NATS entities like accounts, users, servers, and clusters. The library encodes raw 32- and 64-byte keys in a human-readable Base32 format with version prefixes (e.g., 'SU' for a user seed, 'U' for a user public key), making key material easier to work with than raw bytes.
The package wraps Ed25519 operations from pynacl and adds seed-based key derivation, signature generation and verification, and secure memory wiping. It is designed for scenarios where only the seed needs to be stored securely, since both public and private keys can be regenerated from it. The NATS system itself never stores private keys, instead using challenge-response authentication with the public key infrastructure that nkeys provides.
Use it for:
- Generate and manage Ed25519 key pairs for NATS server, cluster, account, and user authentication.
- Sign data with a private key and verify signatures in NATS-based distributed systems.
- Load cryptographic seeds from files and derive public/private key pairs for identity verification.
- Securely wipe key material from memory after use to prevent accidental exposure of secrets.
- Implement custom authentication flows in NATS clients that require Ed25519 signatures.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Generates, manages, and verifies Ed25519-based cryptographic key pairs for NATS ecosystem authentication and authorization, with human-readable key encoding.
Yes, if you are building or integrating with NATS systems that require Ed25519-based authentication. The package is actively maintained, has no known vulnerabilities, and supports modern Python versions. The main trade-off is high install friction due to pynacl's compilation requirement; verify that pre-built wheels are available for your platform before committing.
Install
nkeys on PyPI
pip
pip install nkeysuv
uv add nkeyspoetry
poetry add nkeysInstalling nkeys
Before you install
High install friction due to pynacl dependency, which requires compilation. Package is actively maintained with recent commits and broad Python version support from 3.6 onward.
License in practice
Apache 2.0 permissive license allows commercial and private use with minimal restrictions; you must retain license notices in distributions.
Quickstart
import nkeys
import os
with open('user.nkey', 'rb', buffering=0) as f:
seed = bytearray(os.fstat(f.fileno()).st_size)
f.readinto(seed)
user = nkeys.from_seed(seed)
data = b'arGTKH8q7XDmgy0'
sig = user.sign(data)
user.verify(data, sig)
user.wipe()
pynacl dependency requires a C compiler and libsodium development headers to build from source.
Verify before relying
- Whether pynacl is available as a pre-built wheel for your platform, which would avoid compilation.
- Performance characteristics when signing or verifying large volumes of data.
Package facts
| License | Apache 2 License (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | high — source build required |
| Runtime dependencies | 1 — pynacl |
| Maintenance | actively maintained — 702 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 513,505/month — #6,246 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: nkeys-0.2.1.tar.gz
Tags
More Cryptography packages
Certifi provides Mozilla's curated collection…
copyleft · top 100 on PyPI
cryptographycryptography provides cryptographic recipes and…
permissive · top 100 on PyPI
rsaPure-Python RSA encryption, decryption,…
permissive · top 1,000 on PyPI
pyOpenSSLpyOpenSSL wraps OpenSSL's SSL/TLS functionality…
permissive · top 1,000 on PyPI
azure-identityProvides Microsoft Entra ID token-based…
unclear · top 1,000 on PyPI
PyNaClPyNaCl provides Python bindings to libsodium…
permissive · top 1,000 on PyPI
ed25519-blake2b-forkProvides Python bindings to Ed25519 digital…
permissive · top 15,000 on PyPI
slip10Implements SLIP-0010 hierarchical deterministic…
permissive · top 15,000 on PyPI
pure25519Pure-Python implementation of Curve25519 and…
permissive · top 15,000 on PyPI
taktile-authProvides authentication and authorization…
permissive · top 15,000 on PyPI
bip-utilsGenerates mnemonics, seeds, private/public…
permissive · top 15,000 on PyPI
eth-keysProvides a unified API for Ethereum key…
permissive · top 5,000 on PyPI
signedjsonSigns and verifies JSON objects using ED25519…
unclear · top 15,000 on PyPI
py-ed25519-zebra-bindingsProvides Python bindings to the ed25519-zebra…
permissive · top 15,000 on PyPI
bip32Implements BIP 32 hierarchical deterministic…
permissive · top 15,000 on PyPI
nats-pyAn asyncio Python client for connecting to and…
permissive · top 5,000 on PyPI