A circuit toolkit mainly for cryptographic usage.
Project description
circkit
circkit
is a small framework for defining, constructing and manipulating computational circuits. It aims to be very generic. circkit
supports both low-level circuits such as bit-based operations, word-based operations, arithmetic circuits over a ring and high-level circuits made up by gates which are customized non-primitive functions.
Installation
For arithmetic circuits working on finite fields, it needs to install Sagemath. For circuits working on decimal numbers, integers, boolean and bitwise, it is not necessary to install Sagemath.
Circuits with Sagemath
-
Install Sagemath.
-
Install
circkit
in Sagemath:
- via
PyPI
:
sage -pip install circkit
- or via
setup.py
sage -pip install .
- Run your script with Sagemath:
sage -python script.py
Or you can open a notebook with Sagemath and build your circuit with the circkit
framework:
sage -n
Circuits without Sagemath
- Install
circuit
:
- via
PyPI
:
pip3 install circkit
- or via
setup.py
pip3 install .
- Run your python script, for example:
python3 script.py
Using a virtual environment
We can use a virtual enviroment to run both circuits with and without Sagemath.
- Create a virtual environment of Sagemath:
sage -python -m venv --system-site-packages .venv
Then, go to the virtual enviroment:
source .venv/bin/activate
- Install
circkit
in the virtual environment.
- via
PyPI
:
pip install circkit
- or via
setup.py
pip install .
- Run your script on the virtual enviroment, for example:
python script.py
Or you can open a python notebook in this virtual enviroment and build your circuit. Again, both circuits working with and without Sagemath can be run on this virtual environment.
Tests
You can run the tests in the tests
folder:
pytest tests
NOTE: you should run the tests in the virtual environment (see installation) because the tests consists of both circuits with Sagemath and circuits without Sagemath. Otherwise, it will fail on the tests requiring Sagemath.
You can run a specific test, for example:
pytest tests/test_simon_cipher.py
Documentation
See circkit.readthedocs.io for the documentations. You can also open the file docs/_build/html/index.html file on your browser.
Tutorials
Some jupyter notebooks are provided to help you play with the circkit
framework:
- How to build an arithmetic circuit
- How to build a bitwise circuit
- How to build a boolean circuit
- How to define a new circuit type
- How to define a transformer and example on ISW transformer
Advanced examples
Some advance examples are also provided. These examples highlight the applications of the circkit
framework in cryptography.
Authors
CryptoExperts Team
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file circkit-0.1.1.tar.gz
.
File metadata
- Download URL: circkit-0.1.1.tar.gz
- Upload date:
- Size: 41.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57647284d1cf5a98350e1702835d8822205442f685f3e0dcbb6abad0a012e759 |
|
MD5 | 4f91e9a75e30c26594859e1071186599 |
|
BLAKE2b-256 | c37c0f09b99a1e71a3dd6d9179f4316f6d462abc0431dce650816397362dee6c |
File details
Details for the file circkit-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: circkit-0.1.1-py3-none-any.whl
- Upload date:
- Size: 51.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa9fe5531c0172b779781a06894f3bfba6359e641c9a8041ef8ff20cc22d18b2 |
|
MD5 | 5f0a118a986474b870d3f85d3fbdf5ef |
|
BLAKE2b-256 | b0294fe303a6ebada045d9d839ea5dd673292199bc40e3a6c44f317b173b8b0f |