Skip to main content

Python bindings for FAEST post-quantum signature scheme

Project description

PyFAEST - Python Bindings for FAEST

PyPI version Python 3.7+ License: MIT

Python wrapper for the FAEST (Fast AES-based Signature with Tight security) post-quantum digital signature scheme.

Overview

FAEST is a post-quantum signature scheme submitted to the NIST PQC standardization process. This Python package provides high-level bindings to the C reference implementation:

  • 🔐 Quantum-resistant signatures based on symmetric cryptography
  • 🚀 High performance - Direct binding to optimized C code via CFFI
  • 🛡️ Memory-safe - Automatic private key clearing
  • 🎯 Pythonic API - Clean, intuitive interface
  • 📦 12 parameter sets - All FAEST variants supported

Installation

From PyPI (Recommended)

pip install pyfaest

From Source

git clone https://github.com/Shreyas582/pyfaest.git
cd pyfaest
pip install -e .

Note: Currently supports Linux only. Windows users should use WSL.

Quick Start

from faest import Keypair, sign, verify

# Generate a keypair
keypair = Keypair.generate('128f')

# Sign a message
message = b"Hello, quantum-resistant world!"
signature = sign(message, keypair.private_key)

# Verify the signature
is_valid = verify(message, signature, keypair.public_key)
print(f"Valid: {is_valid}")  # True

Parameter Sets

PyFAEST supports all 12 FAEST parameter sets:

Parameter Set Security Level Public Key Private Key Signature
128f NIST Level 1 32 bytes 32 bytes 5,924 B
128s NIST Level 1 32 bytes 32 bytes 4,506 B
192f NIST Level 3 48 bytes 40 bytes 14,948 B
192s NIST Level 3 48 bytes 40 bytes 11,260 B
256f NIST Level 5 48 bytes 48 bytes 26,548 B
256s NIST Level 5 48 bytes 48 bytes 20,696 B
em_128f NIST Level 1 32 bytes 32 bytes 5,060 B
em_128s NIST Level 1 32 bytes 32 bytes 3,906 B
em_192f NIST Level 3 48 bytes 48 bytes 12,380 B
em_192s NIST Level 3 48 bytes 48 bytes 9,340 B
em_256f NIST Level 5 64 bytes 64 bytes 23,476 B
em_256s NIST Level 5 64 bytes 64 bytes 17,984 B

Suffix meanings:

  • f = Fast (optimized for speed)
  • s = Small (optimized for signature size)
  • em_* = Extended mode variants

Note: 192-bit variants have asymmetric key sizes (private=40, public=48) by design.

API Reference

Key Generation

from faest import Keypair

# Generate a new keypair
keypair = Keypair.generate('128f')

# Access individual keys
public_key = keypair.public_key
private_key = keypair.private_key
param_set = keypair.param_set

# Validate keypair
is_valid = keypair.validate()

Signing and Verification

from faest import sign, verify

# Sign a message
signature = sign(message, private_key)

# Verify a signature  
is_valid = verify(message, signature, public_key)

Key Serialization

# Export keys as bytes
pk_bytes = public_key.to_bytes()
sk_bytes = private_key.to_bytes()

# Import from bytes
keypair = Keypair.from_bytes(pk_bytes, sk_bytes, '128f')

# Or create keys individually
from faest import PublicKey, PrivateKey
public_key = PublicKey(pk_bytes, '128f')
private_key = PrivateKey(sk_bytes, '128f')

Error Handling

from faest import (
    FaestError,           # Base exception
    KeyGenerationError,   # Key generation failed
    SignatureError,       # Signing failed
    VerificationError,    # Verification failed
    InvalidKeyPairError,  # Keypair validation failed
)

try:
    keypair = Keypair.generate('128f')
    signature = sign(message, keypair.private_key)
except KeyGenerationError as e:
    print(f"Key generation failed: {e}")
except SignatureError as e:
    print(f"Signing failed: {e}")

Examples

Complete examples in the examples/ directory:

  • basic_usage.py - Simple signing and verification
  • all_parameter_sets.py - Testing all 12 parameter sets
  • key_serialization.py - Key import/export patterns

Documentation

Requirements

  • Python 3.7 or higher
  • Linux (WSL for Windows users)
  • CFFI >= 1.15.0 (automatically installed)

Security Considerations

⚠️ Important Security Notes:

  • Reference implementation - Not yet optimized for production
  • NIST evaluation - FAEST is a candidate, not yet standardized
  • Memory safety - Private keys automatically cleared from memory
  • Side channels - No protection against timing/power analysis attacks
  • Secure storage - Store private keys encrypted at rest

Performance

Typical performance on modern hardware (single core):

Operation 128f 128s 256f 256s
Key generation ~1 ms ~1 ms ~2 ms ~2 ms
Signing ~5 ms ~8 ms ~15ms ~25ms
Verification ~5 ms ~8 ms ~15ms ~25ms

f variants are faster, s variants produce smaller signatures.

Platform Support

Platform Status Notes
Linux x86_64 ✅ Supported Primary platform
Linux aarch64 ✅ Supported ARM support
macOS x86_64 🚧 Planned Coming soon
macOS ARM64 🚧 Planned Coming soon
Windows (WSL) ✅ Supported Use WSL for now
Windows native 🚧 Planned Future release

Development

Running Tests

pip install pytest
pytest tests/ -v

Building from Source

See INSTALLATION.md for detailed instructions.

Quick version:

# Build FAEST C library first
git clone https://github.com/faest-sign/faest-ref.git
cd faest-ref
meson setup build
meson compile -C build

# Install PyFAEST
cd /path/to/pyfaest
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

# Copy library files
FAEST_REF=/path/to/faest-ref bash scripts/update_libraries.sh

# Install in development mode
pip install -e .

# Verify
python verify_install.py

Project Structure

pyfaest/
├── faest/              # Python package
│   ├── __init__.py     # Public API exports
│   └── core.py         # Main implementation (550+ lines)
├── lib/                # Bundled FAEST libraries
├── include/            # C header files  
├── examples/           # Usage examples
├── tests/              # Test suite (37 tests)
├── docs/               # Documentation
├── scripts/            # Build/release scripts
├── faest_build.py      # CFFI build script
└── setup.py            # Package configuration

License

MIT License - See LICENSE file for details.

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes with tests
  4. Submit a pull request

See DEVELOPER_GUIDE.md for more details.

Citation

If you use PyFAEST in research, please cite:

@software{pyfaest,
  title = {PyFAEST: Python Bindings for FAEST},
  author = {PyFAEST Contributors},
  year = {2025},
  url = {https://github.com/Shreyas582/pyfaest}
}

References

Changelog

See CHANGELOG.md for version history.

Support

Acknowledgments

PyFAEST is built on top of the FAEST reference implementation by the FAEST team. Special thanks to all contributors to the FAEST project.

NOTE from Author

I have created this for a Post-Quantum Cryptography class project at NYU.

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

pyfaest-1.0.15.tar.gz (936.3 kB view details)

Uploaded Source

Built Distributions

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

pyfaest-1.0.15-cp314-cp314-macosx_15_0_universal2.whl (253.0 kB view details)

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

pyfaest-1.0.15-cp313-cp313-macosx_15_0_universal2.whl (253.1 kB view details)

Uploaded CPython 3.13macOS 15.0+ universal2 (ARM64, x86-64)

pyfaest-1.0.15-cp312-cp312-macosx_15_0_universal2.whl (253.1 kB view details)

Uploaded CPython 3.12macOS 15.0+ universal2 (ARM64, x86-64)

pyfaest-1.0.15-cp311-cp311-macosx_15_0_universal2.whl (253.0 kB view details)

Uploaded CPython 3.11macOS 15.0+ universal2 (ARM64, x86-64)

pyfaest-1.0.15-cp310-cp310-macosx_15_0_universal2.whl (253.0 kB view details)

Uploaded CPython 3.10macOS 15.0+ universal2 (ARM64, x86-64)

pyfaest-1.0.15-cp39-cp39-macosx_15_0_universal2.whl (253.0 kB view details)

Uploaded CPython 3.9macOS 15.0+ universal2 (ARM64, x86-64)

pyfaest-1.0.15-cp38-cp38-macosx_15_0_universal2.whl (253.0 kB view details)

Uploaded CPython 3.8macOS 15.0+ universal2 (ARM64, x86-64)

File details

Details for the file pyfaest-1.0.15.tar.gz.

File metadata

  • Download URL: pyfaest-1.0.15.tar.gz
  • Upload date:
  • Size: 936.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for pyfaest-1.0.15.tar.gz
Algorithm Hash digest
SHA256 5dede9f9a5b76677df47f8f7cfed6e30e4d37291cec3e1207511bb698adf4d6e
MD5 bfb5769a209c2e245e465f6ee0f32408
BLAKE2b-256 0626c323b5530f80cac18c862cd455b2084d7de0cd72e2e704d07e4cf31db8e0

See more details on using hashes here.

File details

Details for the file pyfaest-1.0.15-cp314-cp314-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for pyfaest-1.0.15-cp314-cp314-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 0d52b31ccb887c008a916fdc45a8354c9e23e21c340c4c73b7d0562371d85ecf
MD5 41bd676e231f20a1ea6582990feb08ae
BLAKE2b-256 bf3ede2e781b7aa977eaffa961047d93c2f2489fbd4736cea7dd90bbef4ae997

See more details on using hashes here.

File details

Details for the file pyfaest-1.0.15-cp313-cp313-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for pyfaest-1.0.15-cp313-cp313-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 db84d3a4ee0ee1e8606a59822d22e82dc714105d98d38f8ac63614760efaed00
MD5 fc35feb4d27dd170e0b3851cade74b68
BLAKE2b-256 b79649b6da85e370e12744b63a9c2ebac2fc64aa423921bbb3c72e138532de63

See more details on using hashes here.

File details

Details for the file pyfaest-1.0.15-cp312-cp312-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for pyfaest-1.0.15-cp312-cp312-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 646231d707bbcfb1d341860cdcb8d5db5c35e732e07cbb0c7135fa57f5fea73c
MD5 52c82bde7c885e41392e76b12800768c
BLAKE2b-256 f7b32c48e95d6be151ef3e98bc90c71e739d3a9fc4d4219764ee26974fae4358

See more details on using hashes here.

File details

Details for the file pyfaest-1.0.15-cp311-cp311-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for pyfaest-1.0.15-cp311-cp311-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 dc5efef7be8572259fd6a32e06a31d04d6ed51e5b0506f46990601afcb07edef
MD5 041f5660fabb3fd66a688d3d7e451974
BLAKE2b-256 32550a0115bb5faf4e907f19922738b21e0d742e6bdb187888c09cb078a526ad

See more details on using hashes here.

File details

Details for the file pyfaest-1.0.15-cp310-cp310-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for pyfaest-1.0.15-cp310-cp310-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 e4e015809140ce8fda05dd64e79526013bc172243d219bd69197b5b72271a5f8
MD5 e8f75008cf7b8a89ae2ab28d953405ff
BLAKE2b-256 4b7535a3cbb84d7e0084c58578dcb1ba1fd7b5a8e8ff20fca3e9c2d7ce437778

See more details on using hashes here.

File details

Details for the file pyfaest-1.0.15-cp39-cp39-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for pyfaest-1.0.15-cp39-cp39-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 0c0e66fd68dbeedf4fb84a3cd7aa14222b839e542680957cc6bffc6c3915368e
MD5 d5014cd0ee4da83d6c01c236ca74d6d3
BLAKE2b-256 c6ddedc2df04dfc275b91ce8616195a5680444c492761375c6e3c5966c10272a

See more details on using hashes here.

File details

Details for the file pyfaest-1.0.15-cp38-cp38-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for pyfaest-1.0.15-cp38-cp38-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 910ef8f6f0dc897955f12af39c35c68ef88355f56d2e6024d78ca30cdde5e0d3
MD5 274dfee0e43896e640b5c8d200b5d00e
BLAKE2b-256 d086d39272ae0f586c328dfadcf991f4a435499f4d88e937969a56341fa25265

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