This project wraps public and private keys for common cryptographic functionalities for the following elliptic curves:
- Java 8
- Maven
./mvnw package
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>
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");
5. Sign message
byte[] signature = privateKey.sign("Message".getBytes());
Boolean verified = publicKey.verify(message.getBytes(), Hex.decode(hexSignature));