Skip to content

The Hybrid Public Key Encryption (HPKE) standard in Python

License

Notifications You must be signed in to change notification settings

capeprivacy/hybrid-pke

Repository files navigation

py-hpke-spec

The Hybrid Public Key Encryption (HPKE) standard in Python.

This HPKE implementation is simply a thin Python wrapper around hpke-spec, the hacspec implementation written by Franziskus Kiefer. This package mirrors the hpke-spec constructions as much as possible, to avoid any discrepancy from the HPKE standard.

Why hpke-spec?

The hpke-spec library has two primary advantages:

  • hpke-spec is written in hacspec which can be compiled into F* for formal verification.
  • The cargo documentation for hpke-spec is simply the text of the HPKE RFC 9180, with all the RFC's constructions linked directly to the hacspec code that implements it.

As a result, it's much more straightforward to evaluate hpke-spec for security and correctness. Indeed, both hacspec and RFC 9180 have received thorough vetting from cryptographers in Project Everest and the Internet Research Task Force, respectively.

Installation

Wheels for various platforms and architectures can be found in the wheelhouse.zip archive from latest Github release.

THe library can also be installed from source with maturin; see below.

Development

We use maturin to build and distribute the PyO3 extension module as a Python wheel.

For users of cmake, we provide a Makefile that includes some helpful development commands.

Other useful tips:

  • maturin develop builds & installs the Python package into your Python environment (venv or conda recommended)
  • pytest . tests the resulting Python package
  • maturin build --release -o dist --sdist builds the extension module in release-mode and produces a wheel for your environment's OS and architecture.
  • The -i/--interpreter flag for maturin can be used to swap out different Python interpreters, if you have multiple Python installations.

Related Projects