Implementation of two time-lock based-Verifiable Delay Functions. The two VDFs are
- Pietrzark's VDF: https://eprint.iacr.org/2018/627.pdf
- Wesoloski's VDF: https://eprint.iacr.org/2018/623
- report/VDF-Luca_Boghos_Mathias.pdf - project report
- clis - directory to handle the Typer CLI
- custom_error - directory containing custom exception classes to facilitate the error handling
- data_transfer_objects - directory containing 'contracts' between functions (input and output pydantic models)
- utils - directory containing some utilities function such has prime number generators, quadratic residues generators and square-and-multiply function
-
verifiable_delay_functions - directory containing the actual VDFs source code
- vdf.py - file containing the VDF abstract class
- pietrzak.py - file containing the Pietrzak VDF (VDF1)
- wesolowski.py - file containing the Wesolowski VDF (VDF2)
- entry_point.py - entrypoint file for the Typer CLI
Ourside of the source folder, the following files can be found
- Makefile
- requirements.txt - dependencies file for the project
- requirements-tests.txt - dependencies file for the tests (dependencies for the project + potential additional dependencies)
- setup.py - installation file for the package
- setup.cfg - file containing additional information for the setup of the project (such as the CLI entry point) and potential settings for linting and test coverage
Install the package using
make setup
To run the VDFs from the CLI run
cryptoVDF --help
and see the options.
For example, suppose you want to run the Pietrzak eval function, use
cryptoVDF pietrzak eval
Without CLI, the source code can be run in a classic manner
python src/crypto_VDF/verifiable_delay_functions/pietrzak.py
To run the unit tests, run
make tests
Delay of 2^(10)
cryptoVDF pietrzak generate-and-verify 359 --delay 1024 --modulus 437 --verbose
Delay of 2^(20)
cryptoVDF pietrzak generate-and-verify 359 --delay 1048576 --modulus 437 --verbose
Delay of 2^(20)
cryptoVDF pietrzak full-vdf --delay 1048576 --security-parameter 128
cryptoVDF wesolowski full-vdf --delay 1048576 --security-parameter 128
cryptoVDF wesolowski full-vdf --delay 1048576 --security-parameter 128 --trapdoor
cryptoVDF wesolowski plots --max-delay-exp 10 --iterations 20 --show
cryptoVDF pietrzak plots --max-delay-exp 10 --iterations 20 --show
cryptoVDF pietrzak plots --max-delay-exp 8 --iterations 2 --security-parameter 4 --show --verbose
cryptoVDF pietrzak plots --max-delay-exp 10 --iterations 400 --security-parameter 4 --show --verbose
cryptoVDF pietrzak plots --max-delay-exp 10 --iterations 10 --security-parameter 128 --show --verbose
cryptoVDF wesolowski plots --max-delay-exp 10 --iterations 10 --security-parameter 128 --show --verbose
cryptoVDF pietrzak plots --max-delay-exp 10 --iterations 10 --security-parameter 128 --show --verbose
cryptoVDF pietrzak full-vdf --delay 1048576 --security-parameter 128
cryptoVDF wesolowski full-vdf --delay 1048576 --security-parameter 128
cryptoVDF wesolowski full-vdf --delay 1048576 --security-parameter 128 --trapdoor
cryptoVDF pietrzak eval --security-parameter 128 --delay 4
cryptoVDF pietrzak verify --x input --y output --proof proof --modulus modulus --security-parameter security-parameter
Example: The following should evaluate to True
cryptoVDF pietrzak verify --x 60165111687309026253618363786070190189 --y 38920676524930194932948449234450122897 --proof 26733557083776090708288610604071675446,54679161191322144951368137116431681903 --modulus 202791651255554990394641179601075112913 --security-parameter 128
cryptoVDF wesolowski eval --security-parameter 128 --delay 4
cryptoVDF wesolowski verify --x input --y output --proof proof --delay delay --modulus modulus
Example: The following will return True
cryptoVDF wesolowski verify --x 95974600194182310684653862122690543205 --y 856966856996350542601758883331119 --proof 95974600194182310684653862122690543205 --delay 4 --modulus 100167473050021300389050029515619897043
cryptoVDF pietrzak plots --max-delay-exp 10 --iterations 200 --security-parameter 4 --show
cryptoVDF wesolowski plots --max-delay-exp 10 --iterations 200 --security-parameter 4 --show