Skip to main content

Lightweight elliptic curve cryptography from the Charm framework (OpenSSL-only, no GMP/PBC)

Project description

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

Project details


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.1.tar.gz (32.0 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.1-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.1.tar.gz.

File metadata

  • Download URL: charm_crypto_lite-0.61.1.tar.gz
  • Upload date:
  • Size: 32.0 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.1.tar.gz
Algorithm Hash digest
SHA256 1379a2f5d1c097f09fc008dd1c3d5a157aaf41587934e43b4614be5373660207
MD5 36e08018a731daaa4f116c4e20ac953e
BLAKE2b-256 ddd639fdfb4f817ed50393efd4912e99a6d2c7ecbf728869c6e20f681fa4feb6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for charm_crypto_lite-0.61.1-cp314-cp314-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 2bab6d9faa0dbac941a551176364561097dfe7b260fe381a7ae82fc5c75ac550
MD5 c1641ddba8f436eedf53e367ae30c296
BLAKE2b-256 4f3f41aa013cbad7f87cc8cccdb10fb56bf41a879217e8afe18dffc7bcdcf02e

See more details on using hashes here.

Supported by

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