Skip to main content

Modular elliptic curve library implementation in Python for experimentations

Project description

py-keum

This is a work in progress

Keum is a modular implementation of cryptographic components which can be used as a toolbox to bootstrap projects and experimentations. The library aims to be the building block of higher level cryptographic protocols like Plonk, Groth16, folding schemes, recursion layer, etc.

It is not supposed to be used in production! It is inefficient and not audited (and will never be).

For instance, keum includes (or will include):

  • Finite field implementation
  • Elliptic curve operations in different forms (Edwards, Montgomery, Weierstrass) and different coordinates (affine, jacobian, projective)
  • Arithmetisation oriented hash functions (Poseidon, Griffin, Anemoi, Rescue)
  • Polynomial operations
  • Polynomial commitments

The generic primitives are instantiated with standard parameters. For instance, the following elliptic curves are currently supported:

API

Finite fields

For a more complete documentation, have a look at ff.py.

from keum import PrimeFiniteField

# Instantiate a finite field is easy as creating a subclass of PrimeFiniteField and define the class attribute ORDER to the actual order of the prime finite field
class F13(PrimeFiniteField):
    ORDER = 13

# generate random values
a = F13.random()
b = F13.random()

# add two field element
a + b

Elliptic curves

For a more complete documentation, have a look at ec.py.

The following curves are currently supported:

Add a new curve

New elliptic curves can be instantiated easily. See the files given above for the structure to use. When a new curve is added, it must be exposed in __init__.py, and added in the test environment in test_ec.py. The CI will take care of running the tests for the newly added curve.

from keum import pallas

# generate random values
p1 = pallas.AffineWeierstrass.random()
p2 = pallas.AffineWeierstrass.random()

# add two points
p1 + p2

How to contribute

Python 3.11 is required. Use pyenv to install it.

Install the dependencies using

poetry install

Run the tests with

poetry run pytest tests/

Format with

poetry run black keum/*.py tests/*.py

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

keum-0.2.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

keum-0.2.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file keum-0.2.0.tar.gz.

File metadata

  • Download URL: keum-0.2.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/6.2.0-37-generic

File hashes

Hashes for keum-0.2.0.tar.gz
Algorithm Hash digest
SHA256 11b7f84c3a879e5e4d2ae2680c1270922817944f21285633af188cd7f7a9c486
MD5 99afc786a3ae3b84293b4f771e9208a2
BLAKE2b-256 36df7daa2db720922cd55a1d76fa41527b67d160fea88deabda9a973c69cbcbb

See more details on using hashes here.

File details

Details for the file keum-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: keum-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/6.2.0-37-generic

File hashes

Hashes for keum-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e84ad7d8a264789f5ba979c73b72872a0ce01b98577a5673f2041184d6b78b9
MD5 00cfbb2dba82f7b1d8942f2d9c2eb113
BLAKE2b-256 b52ee3f15705f2bae3a6ac935aa3cb34eccb8d744ac0703d64bc8fc791fa40b4

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