Metadata-Version: 2.4
Name: charm-crypto-lite
Version: 0.61.1
Summary: Lightweight elliptic curve cryptography from the Charm framework (OpenSSL-only, no GMP/PBC)
Author-email: "J. Ayo Akinyele" <jakinye3@jhu.edu>
Maintainer-email: "J. Ayo Akinyele" <jakinye3@jhu.edu>
Project-URL: Homepage, https://github.com/JHUISI/charm
Project-URL: Documentation, https://jhuisi.github.io/charm/
Project-URL: Repository, https://github.com/JHUISI/charm
Project-URL: Issues, https://github.com/JHUISI/charm/issues
Keywords: cryptography,elliptic curves,secp256k1,hash-to-curve,openssl
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: C
Classifier: Topic :: Security :: Cryptography
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"

# charm-crypto-lite

**Minimal elliptic curve cryptography for Python** — a lightweight subset of the [Charm Crypto Framework](https://github.com/JHUISI/charm).

## 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](https://pypi.org/project/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

```bash
pip install charm-crypto-lite
```

**Prerequisites:** OpenSSL development libraries

```bash
# macOS
brew install openssl

# Ubuntu/Debian
sudo apt-get install libssl-dev python3-dev build-essential
```

## Quick Start

```python
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:

```python
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

```bash
pip uninstall charm-crypto-lite
pip install charm-crypto-framework
```

Change imports from `charm_lite` to `charm`:

```python
# Before
from charm_lite.toolbox.ecgroup import ECGroup

# After
from charm.toolbox.ecgroup import ECGroup
```

## License

LGPL-3.0-or-later

## Links

- [Charm Crypto Framework](https://github.com/JHUISI/charm)
- [Documentation](https://jhuisi.github.io/charm/)

