Binius Models is a collection of Python models of cryptographic algorithms and protocols. They are intended for purposes of readability and communication rather than high-performance.
For now, the goal is to present a minimal implementation of FRI-Binius, a multilinear polynomial commitment scheme over binary tower fields, developed in [DP24]. Also included is an implementation of the Vision Mark-32 hash function, as developed in [AMPŠ24].
This project uses
- pyenv to manage Python versions. Installation.
- poetry to manage the Python environment and dependencies. Installation.
- pre-commit to automatically deal with simple code issues (e.g., formatting and static analysis). Installation.
- SageMath to validate Python implementations against.
SageMath is a popular open-source language for math, based on Python.
We use Sage to generate data for tests, specifically vision. However, Sage is not required to run any of the tests.
We require Sage version 10, which unfortunately is not currently distributed by standard Linux package managers like apt on Ubuntu.
The recommended workaround is to run Sage in a Docker container using the standard sagemath/sagemath Docker image.
In this case, install Docker and test it with the following:
$ docker run --rm sagemath/sagemath sage --version
SageMath version 10.0, Release Date: 2023-05-20Then set the environment variable export SAGE_IN_DOCKER=1 before running tests.
With pyenv correctly installed and configured, install the currently used version of Python:
$ pyenv install # this will install Python 3.12 (set in ./.python-version)Check that the pyenv local version is correct:
$ pyenv version
3.12.9 (set by <CWD>/.python-version)Set up the poetry environment using pyenv:
$ poetry env use $(pyenv which python)Install dependencies with
$ poetry installRun the type checker with
$ poetry run mypyRun tests with
$ poetry run pytest -m "not slow"Install and configure pre-commit
pre-commit can be installed locally with:
pip install pre-commit
The pre-commit hooks are configured in the file .pre-commit-config.yaml at the root directory. The hooks can be installed with the following command.
pre-commit install
The pre-commit hooks, once installed, will be triggered automatically when commit is made. However, it is possible to run it manually with the following command.
pre-commit run --all-files
To update hooks from time to time run
pre-commit autoupdate
Copyright 2023-2024 Irreducible Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.