charm-crypto-lite
Minimal elliptic curve cryptography for Python — a lightweight subset of the Charm Crypto Framework.
Why charm-crypto-lite?
| charm-crypto-lite | charm-crypto-framework | |
|---|---|---|
| Python dependencies | None | pyparsing |
| C library dependencies | OpenSSL only | OpenSSL + GMP + PBC |
| Scope | secp256k1 EC operations | Full crypto toolkit |
| Use case | ECDSA, Schnorr, ECDH | ABE, IBE, pairing-based crypto |
Use charm-crypto-lite if you:
- Only need elliptic curve operations on secp256k1 (Bitcoin/Ethereum curve)
- Want zero Python dependencies and minimal C dependencies
- Need a lightweight package for serverless/containerized environments
Use charm-crypto-framework if you:
- Need pairing-based cryptography (ABE, IBE, signatures)
- Need multiple curve types or pairing groups
- Are building advanced cryptographic protocols
Installation
pip install charm-crypto-lite
Prerequisites: OpenSSL development libraries
# macOS
brew install openssl
# Ubuntu/Debian
sudo apt-get install libssl-dev python3-dev build-essential
Quick Start
from charm_lite.toolbox.ecgroup import ECGroup, ZR, G
from charm_lite.toolbox.eccurve import secp256k1
group = ECGroup(secp256k1)
# Get the generator point
g = group.generator()
# Generate random scalar (private key)
x = group.random(ZR)
# Scalar multiplication: public_key = g^x
pk = g ** x
# Point addition (multiplicative notation): p = h * k
h = g ** group.random(ZR)
p = pk * h
# Serialization
data = group.serialize(pk)
pk2 = group.deserialize(data)
assert pk == pk2
API Reference
ECGroup Operations
| Operation | Syntax | Description |
|---|---|---|
| Generator | group.generator() |
Get curve generator point G |
| Random scalar | group.random(ZR) |
Random scalar in field |
| Random point | group.random(G) |
Random point on curve |
| Scalar multiply | g ** x |
Point × scalar |
| Point add | h * k |
Point + point (multiplicative notation) |
| Point negate | -h |
Additive inverse |
| Scalar add | x + y |
Field addition |
| Scalar multiply | x * y |
Field multiplication |
| Scalar invert | ~x |
Multiplicative inverse |
| Serialize | group.serialize(elem) |
To bytes |
| Deserialize | group.deserialize(data) |
From bytes |
| Group order | group.order() |
Curve order n |
PKEnc Base Class
For building encryption schemes:
from charm_lite.toolbox.PKEnc import PKEnc
class MyScheme(PKEnc):
def keygen(self): ...
def encrypt(self, pk, msg): ...
def decrypt(self, sk, ct): ...
Migrating to Full Charm
pip uninstall charm-crypto-lite
pip install charm-crypto-framework
Change imports from charm_lite to charm:
# Before
from charm_lite.toolbox.ecgroup import ECGroup
# After
from charm.toolbox.ecgroup import ECGroup
License
LGPL-3.0-or-later
Links
Metadata
Release files for charm-crypto-lite 0.61.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| charm_crypto_lite-0.61.2.tar.gz | 33.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| charm_crypto_lite-0.61.2-cp314-cp314-macosx_10_15_universal2.whl | CPython 3.14 | CPython 3.14 | macOS 10.15+ universal2 (ARM64, x86-64) | Details |
Total release size: 115.4 kB
Release files / charm_crypto_lite-0.61.2.tar.gz
| Download URL | charm_crypto_lite-0.61.2.tar.gz |
|---|---|
| Size | 33.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1354d955f81ef98ddef35bad176e71605aaf3c9cb77e47c66019363489d4b78d
|
|
BLAKE2b-256 checksum How to use checksums |
bc36c1fc20ff98af9c32aeb53be3f81d16d9d00bb69f8435536bc81b2963d65f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / charm_crypto_lite-0.61.2-cp314-cp314-macosx_10_15_universal2.whl
| Download URL | charm_crypto_lite-0.61.2-cp314-cp314-macosx_10_15_universal2.whl |
|---|---|
| Size | 82.0 kB |
| Tags | CPython 3.14 macOS 10.15+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
c5e71ba031c447667bf1d93a44f9d6a167c4a1b4c4f9b336b496e86d420f497c
|
|
BLAKE2b-256 checksum How to use checksums |
f45e547be600c031831bb3e33e3731a48cb1c2208b0b3e17460553b30ea5ac2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|