Skip to content

debuggor/schnorrkel-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

schnorrkel-java

Java implementation of the sr25519 signature algorithm (schnorr over ristretto25519). The existing rust implementation is here.

This library is currently able to create sr25519 keys, import sr25519 keys, and sign and verify messages.

usage

Example: signing and verification

import com.debuggor.schnorrkel.utils.HexUtils;

public class SignTest {

    public static void main(String[] args) throws Exception {
        KeyPair keyPair = KeyPair.fromSecretSeed(HexUtils.hexToBytes("579d7aa286b37b800b95fe41adabbf0c2a577caf2854baeca98f8fb242ff43ae"), ExpansionMode.Ed25519);

        byte[] message = "test message".getBytes();
        SigningContext ctx = SigningContext.createSigningContext("good".getBytes());
        SigningTranscript t = ctx.bytes(message);
        Signature signature = keyPair.sign(t);
        byte[] sign = signature.to_bytes();
        System.out.println(HexUtils.bytesToHex(sign));


        SigningContext ctx2 = SigningContext.createSigningContext("good".getBytes());
        SigningTranscript t2 = ctx2.bytes(message);
        KeyPair fromPublicKey = KeyPair.fromPublicKey(keyPair.getPublicKey().toPublicKey());
        boolean verify = fromPublicKey.verify(t2, sign);
        System.out.println(verify);
    }
}

other

Go implementation

Thanks to @str4d and @isislovecruft for the open source Curve25519 library

About

schnorr signature on the Ristretto group

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages