Package com.klaytn.caver.wallet.keyring
Class AbstractKeyring
- java.lang.Object
-
- com.klaytn.caver.wallet.keyring.AbstractKeyring
-
- Direct Known Subclasses:
MultipleKeyring
,RoleBasedKeyring
,SingleKeyring
public abstract class AbstractKeyring extends java.lang.Object
Represents an abstract class defines the field and method of Keyring.- See Also:
SingleKeyring
,MultipleKeyring
,RoleBasedKeyring
-
-
Constructor Summary
Constructors Constructor Description AbstractKeyring(java.lang.String address)
Create a AbstractKeyring instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract AbstractKeyring
copy()
Returns a copied keyring instance.abstract java.util.List<SignatureData>
ecsign(java.lang.String txHash, int role)
Signs a transaction hash with all private keys in specific role group and returns signature list.abstract SignatureData
ecsign(java.lang.String txHash, int role, int index)
Signs a transaction hash with a private key in specific role group and returns signatureKeyStore
encrypt(java.lang.String password)
Encrypts a keyring and returns a KeyStore.(according to KeyStore V4) This function automatically operates SCRYPT KDF Functionabstract KeyStore
encrypt(java.lang.String password, KeyStoreOption options)
Encrypts a keyring and returns a KeyStore.(according to KeyStore V4)KeyStore
encryptV3(java.lang.String password)
Encrypts a keyring and returns a KeyStore.(according to KeyStore V3)KeyStore
encryptV3(java.lang.String password, KeyStoreOption options)
Encrypts a keyring and returns a KeyStore.(according to KeyStore V3)java.lang.String
getAddress()
java.lang.String
getKlaytnWalletKey()
Returns a KlaytnWalletKey formatboolean
isDecoupled()
Returns true if keyring has decoupled key.abstract java.util.List<SignatureData>
sign(java.lang.String txHash, int chainId, int role)
Signs a transaction hash with all private keys in specific role group and return signature list.abstract SignatureData
sign(java.lang.String txHash, int chainId, int role, int index)
Signs a transaction hash with a private key in specific role group and return signature.java.util.List<SignatureData>
sign(java.lang.String txHash, java.lang.String chainId, int role)
Signs a transaction hash with all keys in specific role group and return signature list.SignatureData
sign(java.lang.String txHash, java.lang.String chainId, int role, int index)
Signs a transaction hash with key in specific role group and return signature.abstract MessageSigned
signMessage(java.lang.String message, int role)
Signs a hashed data with all private keys in specific role group and return MessageSigned instance.abstract MessageSigned
signMessage(java.lang.String message, int role, int index)
Signs a hashed data with a private key in specific role group and return MessageSigned instance.
-
-
-
Method Detail
-
sign
public abstract java.util.List<SignatureData> sign(java.lang.String txHash, int chainId, int role)
Signs a transaction hash with all private keys in specific role group and return signature list.- Parameters:
txHash
- The hash of transaction.chainId
- The chainId specific to the network.role
- A number indicating the role of the key.- Returns:
- List
-
sign
public abstract SignatureData sign(java.lang.String txHash, int chainId, int role, int index)
Signs a transaction hash with a private key in specific role group and return signature.- Parameters:
txHash
- The hash of transaction.chainId
- The chainId specific to the network.role
- A number indicating the role of the key.index
- The index of the key to be used in the specific role group.- Returns:
- SignatureData
-
ecsign
public abstract java.util.List<SignatureData> ecsign(java.lang.String txHash, int role)
Signs a transaction hash with all private keys in specific role group and returns signature list.- Parameters:
txHash
- The hash of transaction.role
- A number indicating the role of the key.- Returns:
- List<SignatureData>
-
ecsign
public abstract SignatureData ecsign(java.lang.String txHash, int role, int index)
Signs a transaction hash with a private key in specific role group and returns signature- Parameters:
txHash
- The hash transactionrole
- A number indicating the role of the key.index
- The index of the key to be used in the specific role group.- Returns:
- SignatureData
-
signMessage
public abstract MessageSigned signMessage(java.lang.String message, int role)
Signs a hashed data with all private keys in specific role group and return MessageSigned instance.- Parameters:
message
- The data string to signrole
- A number indicating the role of the key- Returns:
- MessageSigned
-
signMessage
public abstract MessageSigned signMessage(java.lang.String message, int role, int index)
Signs a hashed data with a private key in specific role group and return MessageSigned instance.- Parameters:
message
- The data string to signrole
- A number indicating the role of the keyindex
- The index of the key to be used in the specific role group- Returns:
- MessageSigned
-
encrypt
public abstract KeyStore encrypt(java.lang.String password, KeyStoreOption options) throws org.web3j.crypto.CipherException
Encrypts a keyring and returns a KeyStore.(according to KeyStore V4)- Parameters:
password
- The password to be used for encryption. The encrypted in KeyStore can be decrypted with this password.options
- The options to use when encrypt a keyring.- Returns:
- KeyStore
- Throws:
org.web3j.crypto.CipherException
-
copy
public abstract AbstractKeyring copy()
Returns a copied keyring instance.- Returns:
- Keyring
-
sign
public java.util.List<SignatureData> sign(java.lang.String txHash, java.lang.String chainId, int role)
Signs a transaction hash with all keys in specific role group and return signature list.- Parameters:
txHash
- The hash of transaction.chainId
- The chainId specific to the network.role
- A number indicating the role of the key.- Returns:
- List
-
sign
public SignatureData sign(java.lang.String txHash, java.lang.String chainId, int role, int index)
Signs a transaction hash with key in specific role group and return signature.- Parameters:
txHash
- The hash of transaction.chainId
- The chainId specific to the network.role
- A number indicating the role of the key.index
- The index of the key to be used in the specific role group.- Returns:
- SignatureData
-
encrypt
public KeyStore encrypt(java.lang.String password) throws org.web3j.crypto.CipherException
Encrypts a keyring and returns a KeyStore.(according to KeyStore V4) This function automatically operates SCRYPT KDF Function- Parameters:
password
- The password to be used for encryption. The encrypted in KeyStore can be decrypted with this password.- Returns:
- KeyStore
- Throws:
org.web3j.crypto.CipherException
-
encryptV3
public KeyStore encryptV3(java.lang.String password, KeyStoreOption options) throws org.web3j.crypto.CipherException
Encrypts a keyring and returns a KeyStore.(according to KeyStore V3)- Parameters:
password
- The password to be used for encryption. The encrypted in KeyStore can be decrypted with this password.options
- The options to use when encrypt a keyring.- Returns:
- KeyStore
- Throws:
org.web3j.crypto.CipherException
-
encryptV3
public KeyStore encryptV3(java.lang.String password) throws org.web3j.crypto.CipherException
Encrypts a keyring and returns a KeyStore.(according to KeyStore V3)- Parameters:
password
- The password to be used for encryption. The encrypted in KeyStore can be decrypted with this password.- Returns:
- KeyStore
- Throws:
org.web3j.crypto.CipherException
-
getKlaytnWalletKey
public java.lang.String getKlaytnWalletKey()
Returns a KlaytnWalletKey format- Returns:
- String
-
isDecoupled
public boolean isDecoupled()
Returns true if keyring has decoupled key.- Returns:
- boolean
-
getAddress
public java.lang.String getAddress()
-
-