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