plugins.aea-ledger-solana.aea_ledger_solana.crypto
This module contains the Crypto implementation for the solana ledger.
SolanaCrypto Objects
class SolanaCrypto(Crypto[Keypair])
Class wrapping the Account Generation from Solana ledger.
__init__
def __init__(private_key_path: Optional[str] = None,
password: Optional[str] = None,
extra_entropy: Union[str, bytes, int] = "") -> None
Instantiate a solana crypto object.
Arguments:
private_key_path: the private key path of the agentpassword: the password to encrypt/decrypt the private key.extra_entropy: add extra randomness to whatever randomness from OS.
pubkey
@property
def pubkey() -> Pubkey
Pubkey object.
private_key
@property
def private_key() -> str
Return a private key.
64 random hex characters (i.e. 32 bytes) prefix.
Returns:
a private key string in hex format
public_key
@property
def public_key() -> str
Return a public key in hex format.
Returns:
a public key string in hex format
address
@property
def address() -> str
Return the address for the key pair.
Returns:
an address string in hex format
load_private_key_from_path
@classmethod
def load_private_key_from_path(cls,
file_name: str,
password: Optional[str] = None) -> Keypair
Load a private key in base58 or bytes format from a file.
Arguments:
file_name: the path to the hex file.password: the password to encrypt/decrypt the private key.
Returns:
the Entity.
sign_message
def sign_message(message: bytes, is_deprecated_mode: bool = False) -> str
Sign a message in bytes string form.
Arguments:
message: the message to be signedis_deprecated_mode: if the deprecated signing is used
Returns:
signature of the message in string form
sign_transaction
def sign_transaction(transaction: JSONLike,
signers: Optional[list] = None) -> JSONLike
Sign a transaction in bytes string form.
Arguments:
transaction: the transaction to be signedsigners: list of signers
Returns:
signed transaction
generate_private_key
@classmethod
def generate_private_key(cls,
extra_entropy: Union[str, bytes,
int] = "") -> Keypair
Generate a key pair for Solana network.
Arguments:
extra_entropy: add extra randomness to whatever randomness your OS can provide
Returns:
keypair object
encrypt
def encrypt(password: str) -> str
Encrypt the private key and return in json.
Arguments:
password: the password to decrypt.
Returns:
json string containing encrypted private key.
decrypt
@classmethod
def decrypt(cls, keyfile_json: str, password: str) -> str
Decrypt the private key and return in raw form.
Arguments:
keyfile_json: json str containing encrypted private key.password: the password to decrypt.
Returns:
the raw private key.