Caution
This code is for academic and educational use only. It is not constant-time and omits production hardening. It should not be used for real cryptographic applications.
PERK is a digital signature schemes whose security relies on the hardness of the Permuted Kernel Problem.
This repository contains a pure Python3 KAT-compliant implementation of PERK v.2.2.0 in the variant using SHA3 for commitments and seed expansion. The purpose of this repository is educational and testing. The code is not optimized and quite slow, especially for level 5 parameters sets.
Install the Python test/runtime dependencies with:
pip install -r requirements.txtMinimal example for keygen, sign, and verify:
from perk import Perk
perk = Perk("perk-1-fast")
pk, sk = perk.keygen()
message = b"hello perk"
sig = perk.sign(message, pk, sk)
res = perk.verify(message, sig, pk)
print("verified:", res)From repo root, ensure Python can import src:
PYTHONPATH=src pytest -vvPYTHONPATH=src pytest tests/test_sign.py -vvRun KAT tests with the following command. Limit KATs to test per variant for speed reasons via PERK_KAT_LIMIT (default 3, max 100):
PYTHONPATH=src PERK_KAT_LIMIT=1 pytest tests/test_kat.py -vvSkip signature generation in KAT tests:
PYTHONPATH=src PERK_KAT_LIMIT=1 PERK_VERIFY_ONLY=1 pytest tests/test_kat.py -vvRun benchmarks:
PYTHONPATH=src PERK_BENCH=1 PERK_BENCH_LOOPS=5 pytest tests/test_sign.py -k benchmark -vv -sAlessandro Budroni