Skip to content

Latest commit

 

History

History
52 lines (34 loc) · 1.58 KB

README.md

File metadata and controls

52 lines (34 loc) · 1.58 KB

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