Skip to content

Cryptocurrency and Cryptographic blockchain Verifiadle Delay Functions project

License

Notifications You must be signed in to change notification settings

programmingAthlete/crypto-VDF

Repository files navigation

crypto-VDF

Implementation of two time-lock based-Verifiable Delay Functions. The two VDFs are

In the case Wesoloski's VDF, our disign and implementation of the optimization of the proof, slightly diverged from the original one. Our solution is more efficient compared to the paper's one when restricting to binary values b_is (binar repreentation of the proof - kappa = 1), but it is not more efficinet in general.

Organisation of the repo

Organisation of the package

  • 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

Files outside of the source directory

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

Setup

Install the package using

make setup

How to run the VFDs

With CLI

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

Without CLI, the source code can be run in a classic manner

python src/crypto_VDF/verifiable_delay_functions/pietrzak.py

How to run unittests

To run the unit tests, run

make tests

Examples

Compute and Verify

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

Full VDF

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

Plots

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

Demo

Full-VDF

Completeness

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

Soundness

VDF1

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

VDF2

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

Plots

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

Releases

No releases published

Packages

No packages published