Metadata-Version: 2.4
Name: tessera-pqc
Version: 0.1.1
Summary: Simulation of Atomic Post-Quantum Cryptography on Intermittent Power
Author-email: Abhinav Gulisetty <abhinavgulisetty@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Tessera-PQC Contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/abhinavgulisetty/tessera-pqc
Project-URL: Repository, https://github.com/abhinavgulisetty/tessera-pqc
Project-URL: Issues, https://github.com/abhinavgulisetty/tessera-pqc/issues
Keywords: post-quantum,cryptography,kyber,ntt,lattice,intermittent-computing,iot,simulation,pqc
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security :: Cryptography
Classifier: Topic :: Scientific/Engineering
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Requires-Dist: simpy>=4.0
Requires-Dist: matplotlib>=3.7
Requires-Dist: rich>=13.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Provides-Extra: notebook
Requires-Dist: jupyter>=1.0; extra == "notebook"
Dynamic: license-file

# Tessera-PQC

[![CI](https://github.com/abhinavgulisetty/tessera-pqc/actions/workflows/ci.yml/badge.svg)](https://github.com/abhinavgulisetty/tessera-pqc/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/tessera-pqc)](https://pypi.org/project/tessera-pqc/)
[![Python](https://img.shields.io/pypi/pyversions/tessera-pqc)](https://pypi.org/project/tessera-pqc/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

**Tessera** is a research simulation framework for **Post-Quantum Cryptography (PQC)** on **intermittent-power** (battery-free IoT) devices.

It models *Atomic Cryptography* — breaking lattice-based operations (NTT, Kyber KEM) into small checkpointed tiles that survive arbitrary power failures by persisting state to Non-Volatile Memory (NVM) after every layer. Side-channel power leakage is modelled using the Hamming Weight of each NVM write.

---

## Features

- **Baby-Kyber KEM** — full Module-LWE key generation, encapsulation, and decapsulation (k=2, q=3329, n=256, η=2)
- **NTT engine** — Cooley-Tukey DIT forward transform + Gentleman-Sande DIF inverse over ℤ_3329\[X\]/(X²⁵⁶+1)
- **Atomic scheduler** — SimPy discrete-event simulation with exponential on/off power model; checkpoints every NTT layer to NVM
- **Hamming Weight leakage model** — records side-channel power trace on every NVM write
- **Rich terminal demo** — live animated panels showing hardware state, NTT progress, event log, and leakage trace
- **62 tests** across math, KEM, memory, and scheduler

---

## Installation

```bash
pip install tessera-pqc
```

Requires Python ≥ 3.10.

### Development install

```bash
git clone https://github.com/abhinavgulisetty/tessera-pqc.git
cd tessera-pqc
pip install -e ".[dev]"
pytest
```

---

## CLI Usage

```bash
tessera verify          # NTT round-trip correctness (5 tests)
tessera kem             # Baby-Kyber key exchange demo
tessera run             # Atomic NTT simulation with SimPy
tessera demo            # Full animated Rich terminal demo
```

### Example — KEM

```
============================================================
 Tessera — Baby-Kyber KEM Demo
============================================================
[KEM] Generating key pair...
      pk length = 672 bytes
      sk length = 768 bytes
[KEM] Encapsulating...
      ciphertext length = 768 bytes
      shared secret (enc) = 1292eb5807fd564239ffa78ab484e840...
[KEM] Decapsulating...
      shared secret (dec) = 1292eb5807fd564239ffa78ab484e840...
[KEM] SUCCESS — shared secrets match! ✓
```

---

## Architecture

```
tessera-pqc/
├── src/tessera/
│   ├── core/
│   │   ├── math.py          # NTT / inverse-NTT / polynomial ring
│   │   └── primitives.py    # Baby-Kyber KEM (keygen / encaps / decaps)
│   ├── hardware/
│   │   ├── memory.py        # NVM simulator + Hamming Weight leakage model
│   │   └── power.py         # SimPy intermittent-power chaos source
│   ├── scheduler.py         # Atomic tile scheduler with NVM checkpointing
│   ├── cli.py               # CLI entry point
│   └── demo.py              # Rich animated terminal demo
└── tests/                   # 62 pytest tests
```

### Key parameters

| Symbol | Value | Meaning |
|--------|-------|---------|
| n | 256 | Polynomial degree |
| q | 3329 | NTT prime |
| ω | 3061 | Primitive 256th root of unity (mod q) |
| k | 2 | Module rank (Baby-Kyber) |
| η | 2 | CBD noise parameter |
| D_U | 10 bits | Ciphertext u compression |
| D_V | 4 bits | Ciphertext v compression |

---

## Publishing workflow

Releases are published to PyPI automatically via [GitHub Actions OIDC Trusted Publisher](https://docs.pypi.org/trusted-publishers/).  
No API tokens are stored — publishing is triggered by creating a GitHub Release.

---

## License

MIT — see [LICENSE](LICENSE).
