Security
Special thanks my followers for supporting me:
VDF4J is a Java-based Verifiable Delay Function (VDF) implementation, developed primarily for educational and research purposes for Adrestus cryptocurrency project. Part of the code is forked from previous libraries that failed to provide consistent and robust functionality, resulting in memory leaks and significant issues on the JVM. VDFs require a predetermined amount of sequential time to compute yet are very fast to verify, making them attractive for use cases like blockchain consensus, randomness beacons, and anti-front-running measures.
This VDF implementation is written in Java. The GMP library is used for arithmetic and greatest common divisor (GCD) calculations. We use class groups to implement the approaches described in the following papers:
A Verifiable Delay Function (VDF) is a function that:
In practice, VDFs use repeated or iterative cryptographic operations (often exponentiation in a group with specific properties). The verification step uses cryptographic checks that confirm the original computation was done correctly. By introducing a time delay during evaluation, VDFs prevent malicious actors from influencing output. The output cannot be differentiated from a random number until the final result is computed. See https://eprint.iacr.org/2018/712.pdf for more details.
The latest release is: 0.1.1.
It is available in Maven Central as: com.security.VDF4J:VDF4J:0.1.1:
JDK 21 is required to build and run this project.
<dependency>
<groupId>io.github.l16h7n1n6s</groupId>
<artifactId>VDF4J</artifactId>
<version>0.1.1</version>
</dependency>
public class ExamplesTest {
private static byte[] challenge;
private static long difficulty;
private static Random random;
@BeforeAll
public static void Setup() {
challenge = new byte[20];
difficulty = 100;
random = new Random();
random.setSeed(200);
}
@Test
public void test_vdf_Pietrzak() throws NoSuchAlgorithmException {
random.nextBytes(challenge);
VdfEngine vdf = new VdfEnginePietrzak(2048);
byte[] solution = vdf.solve(challenge, difficulty);
assertEquals("0035e80b6a54563d78c34e365fd17f83fdb8946793b8d3c9fcda2bc257f57e806f72a8faee112a8b07c8cb4afa0d83a7f4e3bc87c4b2a63718a096f4bea1dc9fbb419c58131dc828ea9485ba24e8ef2ca5e68541545b859a106fc3d5da04ed6ede2614d7a7722334531cb4a8b9d6c2d50c68674c5e47b5eea2d89a720250fdf1d400134de5d604874b3c524a9ed4dfa4b892d8065d76f11d1d902561c56bc0960ed2f698caae3ab4c53e14b0cef2018313c6f4325944c44bebb56eb546871979b3242a938c9f3038e2ac2d9026b2c84867df2b2034aea6b2eec10c36b98975473a847cb004fb29a80e66777ed1e0feef4739b25a28defb6e1f7fc3e1e0985b2c6ecd", Hex.toHexString(solution));
assertTrue(vdf.verify(challenge, difficulty, solution));
vdf.cleanup();
}
}
Important: This implementation is intended for demonstration. It may not have production-grade security optimizations.
src/main/java/
Contains the core Java source code implementing the VDF logic:
pom.xml
The Maven configuration file that defines build dependencies and plugins.
appveyor.yml
Potential integration/build instructions for AppVeyor continuous integration (not always used in Java projects, but
can be adapted).
dependency-reduced-pom.xml
An auxiliary Maven file generated during shading/assembly processes.
LICENSE
MIT License details.
README.md
You’re reading it!
git clone https://github.com/PanagiotisDrakatos/VDF4J.git
cd VDF4J
mvn clean install
mvn -Dtest=MyTest ExamplesTest test
Replace com.example.vdf.Main with the actual main class path from the repository. This example shows how you might launch a test or demonstration of the VDF functionality.
Below are instructions for building the libgmp library that ships with this module
There is an included Dockerfile that can be used to compile libgmp with
First build the Docker image. Navigate to the nativeCode folder of the project and run the following command:
docker build -t jnagmp-linux-x86-64 -f linux-x86-64.dockerfile .
Next run the Docker image which will execute the Makefile and output the compiled library in to src/main/resources
docker run -v "$(pwd)/src/main/resources:/build/src/main/resources" -t jnagmp-linux-x86-64
After running the above command, the compiled library will be available in the resources folder.
setup-x86_64.exe
for 64-bit Windowssetup-x86.exe
for 32-bit WindowsTip: If you’re unsure of your system architecture, press
Windows Key + Pause/Break
to open system properties and check your system type.
setup-x86_64.exe
(or setup-x86.exe
for 32-bit).i686-w64-mingw32-gcc: For 32-bit Windows applications. Not exist on packet manger run version command to check it on cygwin
x86_64-w64-mingw32-gcc: For 64-bit Windows applications. Not exist on packet manger run version command to check it on cygwin
mingw64-i686-gcc-g++ - The GNU Compiler Collection (C++ compiler). For 32-bit Windows applications.
mingw64-x86_64-gcc-g++ - The GNU Compiler Collection (C++ compiler). For 64-bit Windows applications.
install cygwin on setup make sure all this installed
gcc-core - The GNU Compiler Collection (C compiler).
gcc-g++ - The GNU Compiler Collection (C compiler).
libgcc - The GNU Compiler Collection (C compiler).
make - The GNU version of the 'make' utility.
autoconf - A tool for automatically configuring source code.
automake - A tool for automatically generating Makefile.in files.
libtool - A generic library support script.
m4 - A macro processing language.
curl - A tool to transfer data from or to a server.
Add the following to your PATH environment variable
C:\cygwin64\bin
Make sure you have the following run:
i686-w64-mingw32-gcc --version For 32-bit Windows applications
x86_64-w64-mingw32-gcc --version For 64-bit Windows applications
Navigate to the directory where you want to install run commands
cd /cygdrive/c/Users/User/mypath...
Runs the following command to compile the library
cd gmp-6.3.0
Run the following command to compile the library
./configure --disable-static --enable-shared --host=x86_64-w64-mingw32
Or better run this command to compile the library from a ready to use Makefile fro windows
make -f WindowsMakefile.libgmp install
Then run the following command to move the files into the resources folder that the program reads
mv libgmp-10.dll libgmp.dll
Input / Setup:
Iterated Computation:
Output + Proof:
The key to a VDF is that computing the output from the input must take at least t steps (each step depends on the previous step’s result).
Even with many parallel processors, you cannot skip or batch these steps because each iteration relies on the output of the previous iteration. Proof Generation & Verification
Security Hardening: For real-world usage, consider larger parameters or proven secure group settings (e.g., class groups, pairing-friendly curves, incremental exponentiation in large prime fields, etc.).
Performance Tuning: The Java code works for a demonstration; you may want advanced libraries or native bindings for enhanced big-integer arithmetic.
Expand Proof Options: Different VDF constructions exist (e.g., Wesolowski’s proof, Pietrzak’s proof). This project could implement or compare multiple proof schemes.
Benchmarking: Adding thorough benchmarks to measure performance under various iteration counts, machine architectures, or concurrency scenarios would be beneficial.
Integration with Other Projects: Useful for demonstrating real ownership or usage in blockchains or distributed systems needing delayed computations
While this may be helpful for some, there are significant risks. VDF4J may be used only for Educational Purposes. Do not use it for illegal purposes! You could go to jail if if you will use it for malicious purposes.
For support, email panagiotisdrakatos@gmail.com or join me Discord:panos5427. Meaning, if you liked using this app or it has helped you in any way, I'd like you send me an email about anything you'd want to say about this software. I'd really appreciate it!
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
This project is distributed under the MIT license version 2.0 (see the LICENSE file in the project root).
By submitting a pull request to this project, you agree to license your contribution under the MIT license version 2.0 to this project.