https://github.com/syntifi/crypto-keys
Crypto libraries for working with Public and Private Keys cryptography.
https://github.com/syntifi/crypto-keys
crypto cryptocurrency ed25519 java secp256k1
Last synced: 6 months ago
JSON representation
Crypto libraries for working with Public and Private Keys cryptography.
- Host: GitHub
- URL: https://github.com/syntifi/crypto-keys
- Owner: syntifi
- License: apache-2.0
- Created: 2022-02-25T17:47:09.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-15T15:32:25.000Z (over 1 year ago)
- Last Synced: 2025-03-22T18:41:12.729Z (7 months ago)
- Topics: crypto, cryptocurrency, ed25519, java, secp256k1
- Language: Java
- Homepage: https://syntifi.github.io/crypto-keys/
- Size: 1020 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
[](https://github.com/syntifi/crypto-keys/actions/workflows/build.yml)

[](https://www.apache.org/licenses/LICENSE-2.0.txt)# Crypto Keys Java Library
This project wraps public and private keys for common cryptographic functionalities for the following elliptic curves:
- [Ed25519](https://en.wikipedia.org/wiki/EdDSA)
- [Secp256k1](https://www.secg.org/sec2-v2.pdf)## Dependencies
- Java 8
- Maven## Build instructions
```
./mvnw package
```## Maven repository
Using gradle
```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
```xml
...
com.syntifi.crypto
crypto-key-ed25519
VERSION
com.syntifi.crypto
crypto-key-secp256k1
VERSION
```
## How to
### 1. [Read a public key from pem file](https://github.com/syntifi/crypto-keys/blob/d0de1acedd8bfb2d4e7d1074649051af7596f695/crypto-key-ed25519/src/test/java/com/syntifi/crypto/key/Ed25519PublicKeyTests.java#L74-L81)
```Java
Ed25519PublicKey publicKey = new Ed25519PublicKey();
publicKey.readPublicKey("public_key.pem");
``````Java
Secp256k1PublicKey pubKey = new Secp256k1PublicKey();
publicKey.readPublicKey("public_key.pem");
```### 2. [Write a public key to pem file](https://github.com/syntifi/crypto-keys/blob/d0de1acedd8bfb2d4e7d1074649051af7596f695/crypto-key-ed25519/src/test/java/com/syntifi/crypto/key/Ed25519PublicKeyTests.java#L50)
```Java
publicKey.writePublicKey("public_key.pem");
```### 3. [Read a private key from pem file](https://github.com/syntifi/crypto-keys/blob/d0de1acedd8bfb2d4e7d1074649051af7596f695/crypto-key-ed25519/src/test/java/com/syntifi/crypto/key/Ed25519PrivateKeyTests.java#L76-L83)
```Java
Ed25519PrivateKey privateKey = new Ed25519PrivateKey();
privateKey.readPrivateKey("private_key.pem");
``````Java
Secp256k1PrivateKey privateKey = new Secp256k1PrivateKey();
privateKey.readPrivateKey("private_key.pem");
```### 4. [Write a private key to pem file](https://github.com/syntifi/crypto-keys/blob/d0de1acedd8bfb2d4e7d1074649051af7596f695/crypto-key-ed25519/src/test/java/com/syntifi/crypto/key/Ed25519PrivateKeyTests.java#L57)
```Java
privateKey.writPrivateKey("private_key.pem");
```### 5. [Sign message](https://github.com/syntifi/crypto-keys/blob/d0de1acedd8bfb2d4e7d1074649051af7596f695/crypto-key-ed25519/src/test/java/com/syntifi/crypto/key/Ed25519PrivateKeyTests.java#L65-L67)
```Java
byte[] signature = privateKey.sign("Message".getBytes());
```### 6. [Verify Signature](https://github.com/syntifi/crypto-keys/blob/d0de1acedd8bfb2d4e7d1074649051af7596f695/crypto-key-ed25519/src/test/java/com/syntifi/crypto/key/Ed25519PublicKeyTests.java#L58-L71)
```Java
Boolean verified = publicKey.verify(message.getBytes(), Hex.decode(hexSignature));
```