Skip to content

Dependency-free NIST's Dilithium algorithm implementation in java

License

Notifications You must be signed in to change notification settings

Telamone/Dilithium

Repository files navigation

Dilithium

This is a modified version of this repository adapted to my needs.

It's also included in my personal java libraries as it's used for secure data authentication.

In future updates I'll probably try improving code quality and speed attaching some benchmarks.
As for now, this is only a simple rework of the already existing library.

For more information, I would recommend to visit the original repository.

Demo

Code:

    Security.addProvider(new DilithiumProvider());

    final KeyPairGenerator kpg = KeyPairGenerator.getInstance("Dilithium");
    kpg.initialize(DilithiumParameterSpec.LEVEL_5);

    final KeyPair kp = kpg.generateKeyPair();

    final PrivateKey prvK = kp.getPrivate();
    final PublicKey pubK = kp.getPublic();

    final Signature signature = Signature.getInstance("Dilithium");

    final byte[] message = "Message!".getBytes();

    signature.initSign(prvK);
    signature.update(message);
    final byte[] sign = signature.sign();

    signature.initVerify(pubK);
    signature.update(message);
    System.out.println("This works, right? " + signature.verify(sign));

    System.out.println("Let's try changing the message...");

    signature.update("MODIFIED!!!".getBytes());
    System.out.println("This doesn't work, right? " + !signature.verify(sign));

Output:

    This works, right? true
    Let's try changing the message...
    This doesn't work, right? true

About

Dependency-free NIST's Dilithium algorithm implementation in java

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages