public class SigningService
extends java.lang.Object
| Constructor and Description |
|---|
SigningService() |
| Modifier and Type | Method and Description |
|---|---|
java.security.PublicKey |
fromClPublicKey(CLPublicKey publicKey)
Obtains the java security public keys raw and converts to a casper labs public key.
|
java.security.KeyPair |
generateKeyPair(Algorithm algorithm)
Generates a key pair for the specified algorithm.
|
java.security.KeyPair |
generateKeyPair(Algorithm algorithm,
byte[] seed)
Generates a key pair for the specified algorithm.
|
<T extends java.security.Key> |
loadKey(java.io.InputStream keyIn) |
java.security.KeyPair |
loadKeyPair(java.io.File publicKeyFile,
java.io.File privateKeyFile)
Loads the key pairs from the provide file
|
java.security.KeyPair |
loadKeyPair(java.io.InputStream publicKeyIn,
java.io.InputStream privateKeyIn)
Loads the key pairs from the provided streams
|
byte[] |
signWithPrivateKey(java.security.PrivateKey privateKey,
byte[] message)
Signs a message using the provided key
|
CLPublicKey |
toClPublicKey(java.security.PublicKey publicKey)
Obtains the java security public keys raw and converts to a casper labs public key.
|
boolean |
verifySignature(java.security.PublicKey publicKey,
byte[] message,
byte[] signature)
Verifies a signed message
|
void |
writeKey(java.io.OutputStream out,
java.security.Key key)
Writes a key to a PEM file
|
public java.security.KeyPair generateKeyPair(Algorithm algorithm)
algorithm - the algorithm of new key pair to generatepublic java.security.KeyPair generateKeyPair(Algorithm algorithm, byte[] seed)
algorithm - the algorithm of new key pair to generateseed - the entropy source to be used when generating a key pairpublic java.security.KeyPair loadKeyPair(java.io.File publicKeyFile,
java.io.File privateKeyFile)
publicKeyFile - the public key .pem fileprivateKeyFile - the private key .pem filepublic java.security.KeyPair loadKeyPair(java.io.InputStream publicKeyIn,
java.io.InputStream privateKeyIn)
publicKeyIn - the public key .pem file input streamprivateKeyIn - the private key .pem file input streampublic byte[] signWithPrivateKey(java.security.PrivateKey privateKey,
byte[] message)
privateKey - the private key to sign withmessage - the message to signpublic CLPublicKey toClPublicKey(java.security.PublicKey publicKey)
publicKey - the public key to obtain the raw bytes frompublic java.security.PublicKey fromClPublicKey(CLPublicKey publicKey)
publicKey - the public key to obtain the raw bytes frompublic boolean verifySignature(java.security.PublicKey publicKey,
byte[] message,
byte[] signature)
publicKey - the public key to verify signature withmessage - the message to signsignature - the signed messagepublic void writeKey(java.io.OutputStream out,
java.security.Key key)
out - the stream to write a key tokey - the key to write in a .PEM filepublic <T extends java.security.Key> T loadKey(java.io.InputStream keyIn)