Package com.exonum.binding.common.crypto
Interface CryptoFunction
public interface CryptoFunction
A crypto function that provides several signature system crypto methods.
All method arguments can't be null otherwise
NullPointerException
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 Details
-
generateKeyPair
Generates a private key and a corresponding public key using aseed
byte array.- Throws:
java.lang.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
Given aprivateKey
, computes and returns a signature for the suppliedmessage
.- Returns:
- signature as a byte array
- Throws:
java.lang.IllegalArgumentException
- if the private key is not valid for this cryptographic function
-
verify
Given apublicKey
, verifies thatsignature
is a valid signature for the suppliedmessage
.- Returns:
- true if signature is valid, false otherwise
-