@ApiAudience.Public @ApiStability.Unstable public class AergoKey extends java.lang.Object implements KeyPair, Signer, MessageSigner
Modifier and Type | Field and Description |
---|---|
protected AccountAddress |
address |
protected ECDSAKey |
ecdsakey |
protected org.slf4j.Logger |
logger |
protected AergoSignVerifier |
verifier |
Constructor and Description |
---|
AergoKey(ECDSAKey ecdsakey)
AergoKey constructor.
|
AergoKey(EncryptedPrivateKey encryptedPrivateKey,
java.lang.String password)
AergoKey constructor.
|
AergoKey(java.lang.String encodedEncryptedPrivateKey,
java.lang.String password)
AergoKey constructor.
|
Modifier and Type | Method and Description |
---|---|
EncryptedPrivateKey |
export(java.lang.String password)
Return encrypted private key.
|
AccountAddress |
getPrincipal()
Get principal of a signer.
|
java.security.PrivateKey |
getPrivateKey()
Get private key.
|
java.security.PublicKey |
getPublicKey()
Get public key.
|
protected byte[] |
getRawPrivateKey() |
static AergoKey |
of(EncryptedPrivateKey encryptedPrivateKey,
java.lang.String password)
Create a key pair with encrypted private key and password.
|
static AergoKey |
of(java.lang.String encodedEncryptedPrivateKey,
java.lang.String password)
Create a key pair with encoded encrypted private key and password.
|
Transaction |
sign(RawTransaction rawTransaction)
Sign to raw transaction.
|
Signature |
signMessage(BytesValue message)
Sha256 hash to
message and sign to it. |
java.lang.String |
signMessage(java.lang.String message)
Sha256 hash to
message and sign to it. |
java.lang.String |
signMessage(java.lang.String message,
Encoder encoder)
Sha256 hash to
message and sign to it. |
java.lang.String |
toString() |
boolean |
verify(Transaction transaction)
Check if
Transaction is valid. |
boolean |
verifyMessage(BytesValue message,
Signature signature)
Check if
signature is valid for current accountAddress and message . |
boolean |
verifyMessage(Hash hashedMessage,
Signature signature)
Check if
signature is valid for hash and current address. |
boolean |
verifyMessage(java.lang.String message,
java.lang.String base64EncodedSignature)
Check if
base64EncodedSignature is valid for current accountAddress and
message . |
boolean |
verifyMessage(java.lang.String message,
java.lang.String encodedSignature,
Decoder decoder)
Check if
base64EncodedSignature is valid for current accountAddress and
message . |
protected final transient org.slf4j.Logger logger
protected final AergoSignVerifier verifier
protected final ECDSAKey ecdsakey
protected final AccountAddress address
public AergoKey(java.lang.String encodedEncryptedPrivateKey, java.lang.String password)
encodedEncryptedPrivateKey
- base58 with checksum encoded encrypted private keypassword
- password to decryptpublic AergoKey(EncryptedPrivateKey encryptedPrivateKey, java.lang.String password)
encryptedPrivateKey
- encrypted private keypassword
- password to decryptpublic AergoKey(ECDSAKey ecdsakey)
ecdsakey
- keypairpublic static AergoKey of(java.lang.String encodedEncryptedPrivateKey, java.lang.String password)
encodedEncryptedPrivateKey
- base58 with checksum encoded encrypted private keypassword
- password to decryptpublic static AergoKey of(EncryptedPrivateKey encryptedPrivateKey, java.lang.String password)
encryptedPrivateKey
- encrypted private keypassword
- password to decryptpublic java.security.PrivateKey getPrivateKey()
KeyPair
getPrivateKey
in interface KeyPair
public java.security.PublicKey getPublicKey()
KeyPair
getPublicKey
in interface KeyPair
public AccountAddress getPrincipal()
WithPrincipal
getPrincipal
in interface WithPrincipal
public Transaction sign(RawTransaction rawTransaction)
Signer
public java.lang.String signMessage(java.lang.String message)
MessageSigner
message
and sign to it.signMessage
in interface MessageSigner
message
- a message to signpublic java.lang.String signMessage(java.lang.String message, Encoder encoder)
MessageSigner
message
and sign to it.signMessage
in interface MessageSigner
message
- a message to signencoder
- an encoder to encode signed messagepublic Signature signMessage(BytesValue message)
MessageSigner
message
and sign to it.signMessage
in interface MessageSigner
message
- a message to signpublic boolean verify(Transaction transaction)
Transaction
is valid.transaction
- transaction to verifypublic boolean verifyMessage(java.lang.String message, java.lang.String base64EncodedSignature)
base64EncodedSignature
is valid for current accountAddress
and
message
. It hashes message
and verify hashed one.message
- a messagebase64EncodedSignature
- a base64 encoded signaturepublic boolean verifyMessage(java.lang.String message, java.lang.String encodedSignature, Decoder decoder)
base64EncodedSignature
is valid for current accountAddress
and
message
. It hashes message
and verify hashed one.message
- a messageencodedSignature
- an encoded signaturedecoder
- a decoder to decode encoded signaturepublic boolean verifyMessage(BytesValue message, Signature signature)
signature
is valid for current accountAddress
and message
. It
hashes message
and verify hashed one.message
- a messagesignature
- signaturepublic boolean verifyMessage(Hash hashedMessage, Signature signature)
signature
is valid for hash
and current address.hashedMessage
- a hashed messagesignature
- signature to verifypublic EncryptedPrivateKey export(java.lang.String password)
password
- encrypt keyprotected byte[] getRawPrivateKey()
public java.lang.String toString()
toString
in class java.lang.Object