class Zilliqa::Account::Account
Attributes
address[R]
private_key[R]
public_key[R]
Public Class Methods
from_file(file, passphrase)
click to toggle source
Takes a JSON-encoded keystore and passphrase, returning a fully instantiated Account
instance.
# File lib/zilliqa/account/account.rb, line 13 def self.from_file(file, passphrase) key_store = Zilliqa::Crypto::KeyStore.new private_key = key_store.decrypt_private_key(file, passphrase) Account.new(private_key) end
new(private_key)
click to toggle source
# File lib/zilliqa/account/account.rb, line 5 def initialize(private_key) @private_key = private_key @public_key = Zilliqa::Crypto::KeyTool.get_public_key_from_private_key(private_key, true) @address = Zilliqa::Crypto::KeyTool.get_address_from_public_key(@public_key) end
Public Instance Methods
sign_transaction(tx)
click to toggle source
sign the passed in transaction with the account's private and public key
# File lib/zilliqa/account/account.rb, line 26 def sign_transaction(tx) message = tx.bytes message_hex = Util.encode_hex(message) Zilliqa::Crypto::Schnorr.sign(message_hex, @private_key, @public_key) end
to_file(passphrase, type)
click to toggle source
Convert an Account
instance to a JSON-encoded keystore.
# File lib/zilliqa/account/account.rb, line 20 def to_file(passphrase, type) key_store = Zilliqa::Crypto::KeyStore.new json = key_store.encrypt_private_key(@private_key, passphrase, type); end