Skip to content

syntifi/crypto-keys

Repository files navigation

Java CI GitHub tag (latest SemVer) Project license

Crypto Keys Java Library

This project wraps public and private keys for common cryptographic functionalities for the following elliptic curves:

Dependencies

  • Java 8
  • Maven

Build instructions

./mvnw package

Maven repository

Using gradle

// for using ed25519 key pair
implementation com.syntifi.crypto:crypto-key-ed25519:VERSION

// for using secp256k1 key pair
implementation com.syntifi.crypto:crypto-key-secp256k1:VERSION

Using maven

<dependencies>
    ...
    <!-- for using ed25519 key pair -->
    <dependency>
        <groupId>com.syntifi.crypto</groupId>
        <artifactId>crypto-key-ed25519</artifactId>
        <version>VERSION</version>
    </dependency>

    <!-- for using secp256k1 key pair -->
    <dependency>
        <groupId>com.syntifi.crypto</groupId>
        <artifactId>crypto-key-secp256k1</artifactId>
        <version>VERSION</version>
    </dependency>
</dependencies>

How to

Ed25519PublicKey publicKey = new Ed25519PublicKey();
publicKey.readPublicKey("public_key.pem");
Secp256k1PublicKey pubKey = new Secp256k1PublicKey();
publicKey.readPublicKey("public_key.pem");
publicKey.writePublicKey("public_key.pem");
Ed25519PrivateKey privateKey = new Ed25519PrivateKey();
privateKey.readPrivateKey("private_key.pem");
Secp256k1PrivateKey privateKey = new Secp256k1PrivateKey();
privateKey.readPrivateKey("private_key.pem");
privateKey.writPrivateKey("private_key.pem");
byte[] signature = privateKey.sign("Message".getBytes());
 Boolean verified = publicKey.verify(message.getBytes(), Hex.decode(hexSignature));