pymonocypher
raw JSON → 4.0.2.6 verified Fri May 01 auth: no python
Python ctypes bindings to the Monocypher library. Current version: 4.0.2.6, requires Python ~=3.10. Release cadence: irregular, tied to Monocypher updates.
pip install pymonocypher Common errors
error AttributeError: module 'pymonocypher' has no attribute 'crypto_sign_keypair' ↓
cause Incorrect import: using 'import pymonocypher' without accessing the inner module.
fix
Import correctly: from pymonocypher import pymonocypher as m; then use m.crypto_sign_keypair().
error TypeError: compute_signing_public_key() takes exactly 1 argument (0 given) ↓
cause Passing a 32-byte key instead of 64-byte secret key (deprecated 32-byte variant removed).
fix
Pass the full 64-byte secret key returned by crypto_sign_keypair().
error ValueError: nb_block is not a valid parameter for argon2i_32 ↓
cause Using the old parameter name nb_block instead of nb_blocks (fixed in v4.0.2.4).
fix
Use nb_blocks instead of nb_block.
Warnings
breaking Upgraded from Monocypher 3.1.3 to 4.0.2 in v4.0.2.1; incremental SignatureVerify removed. ↓
fix Use crypto_sign_verify instead of IncrementalSignatureVerify.
breaking compute_signing_public_key now requires a 64-byte secret key (full keypair output). The 32-byte variant is deprecated as of v4.0.2.3. ↓
fix Pass the full 64-byte secret key (sk) to compute_signing_public_key. For the deprecated 32-byte variant, update your code to use the full key.
deprecated compute_signing_public_key 32-byte variant deprecated in v4.0.2.3 and will be removed in a future release. ↓
fix Use the 64-byte secret key variant.
gotcha argon2i_32 had incorrect parameter nb_block (should be nb_blocks) fixed in v4.0.2.4. ↓
fix Use nb_blocks instead of nb_block when calling argon2i_32.
gotcha Python 3.10 support dropped as of v4.0.2.6/v3.1.3.5. ↓
fix Use Python >=3.11 or pin to an older version (v4.0.2.5 supports 3.10).
Imports
- pymonocypher wrong
import pymonocyphercorrectfrom pymonocypher import pymonocypher as m - crypto_sign wrong
pymonocypher.crypto_sign(msg, sk)correctm.crypto_sign(msg, sk)
Quickstart
from pymonocypher import pymonocypher as m
key = m.crypto_sign_keypair()
print('Public key:', key.pk.hex())
msg = b'Hello'
sig = m.crypto_sign(msg, key.sk)
print('Signature:', sig.hex())
# Verify
m.crypto_sign_verify(sig, msg, key.pk)
print('Verified OK')