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 KeyPairgenerateKeyPair()Generates a private key and a corresponding public key using a random seed.KeyPairgenerateKeyPair(byte[] seed)Generates a private key and a corresponding public key using aseedbyte array.byte[]signMessage(byte[] message, PrivateKey privateKey)Given aprivateKey, computes and returns a signature for the suppliedmessage.booleanverify(byte[] message, byte[] signature, PublicKey publicKey)Given apublicKey, verifies thatsignatureis a valid signature for the suppliedmessage.
-
Method Details
-
generateKeyPair
Generates a private key and a corresponding public key using aseedbyte 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
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
Given apublicKey, verifies thatsignatureis a valid signature for the suppliedmessage.- Returns:
- true if signature is valid, false otherwise
-