Skip to main content

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

charm_crypto_lite-0.61.2.tar.gz (33.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

charm_crypto_lite-0.61.2-cp314-cp314-macosx_10_15_universal2.whl (82.0 kB view details)

Uploaded CPython 3.14macOS 10.15+ universal2 (ARM64, x86-64)

File details

Details for the file charm_crypto_lite-0.61.2.tar.gz.

File metadata

  • Download URL: charm_crypto_lite-0.61.2.tar.gz
  • Upload date:
  • Size: 33.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for charm_crypto_lite-0.61.2.tar.gz
Algorithm Hash digest
SHA256 1354d955f81ef98ddef35bad176e71605aaf3c9cb77e47c66019363489d4b78d
MD5 084f2ff9c87775d5820c8bac59e2f74b
BLAKE2b-256 bc36c1fc20ff98af9c32aeb53be3f81d16d9d00bb69f8435536bc81b2963d65f

See more details on using hashes here.

File details

Details for the file charm_crypto_lite-0.61.2-cp314-cp314-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for charm_crypto_lite-0.61.2-cp314-cp314-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 c5e71ba031c447667bf1d93a44f9d6a167c4a1b4c4f9b336b496e86d420f497c
MD5 c843a9527e8984f4a5e360a0df572373
BLAKE2b-256 f45e547be600c031831bb3e33e3731a48cb1c2208b0b3e17460553b30ea5ac2a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.61.2 This release

2 files

0.61.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page