Package com.exonum.binding.common.crypto
Interface CryptoFunction
-
- All Known Implementing Classes:
Ed25519CryptoFunction
public interface CryptoFunction
A crypto function that provides several signature system crypto methods. All method arguments can't be null otherwiseNullPointerException
will be thrown.
-
-
Method Summary
Modifier and Type Method Description KeyPair
generateKeyPair()
Generates a private key and a corresponding public key using a random seed.KeyPair
generateKeyPair(byte[] seed)
Generates a private key and a corresponding public key using aseed
byte array.byte[]
signMessage(byte[] message, PrivateKey privateKey)
Given aprivateKey
, computes and returns a signature for the suppliedmessage
.boolean
verify(byte[] message, byte[] signature, PublicKey publicKey)
Given apublicKey
, verifies thatsignature
is a valid signature for the suppliedmessage
.
-
-
-
Method Detail
-
generateKeyPair
KeyPair generateKeyPair(byte[] seed)
Generates a private key and a corresponding public key using aseed
byte array.- Throws:
IllegalArgumentException
- if the specified seed is not valid
-
generateKeyPair
KeyPair generateKeyPair()
Generates a private key and a corresponding public key using a random seed.
-
signMessage
byte[] signMessage(byte[] message, PrivateKey privateKey)
Given aprivateKey
, computes and returns a signature for the suppliedmessage
.- Returns:
- signature as a byte array
- Throws:
IllegalArgumentException
- if the private key is not valid for this cryptographic function
-
verify
boolean verify(byte[] message, byte[] signature, PublicKey publicKey)
Given apublicKey
, verifies thatsignature
is a valid signature for the suppliedmessage
.- Returns:
- true if signature is valid, false otherwise
-
-