Class: Nano::Account
- Inherits:
-
Object
- Object
- Nano::Account
- Defined in:
- lib/nano/wallet/account.rb
Instance Method Summary collapse
- #address(prefix = "xrb") ⇒ Object (also: #to_s)
-
#initialize(seed, index = 0) ⇒ Account
constructor
A new instance of Account.
- #private_key ⇒ Object
- #public_key ⇒ Object
Constructor Details
#initialize(seed, index = 0) ⇒ Account
Returns a new instance of Account.
8 9 10 11 12 |
# File 'lib/nano/wallet/account.rb', line 8 def initialize(seed, index = 0) @seed = seed @seed_bin = Util.hex_to_bin(@seed) @index = index end |
Instance Method Details
#address(prefix = "xrb") ⇒ Object Also known as: to_s
22 23 24 |
# File 'lib/nano/wallet/account.rb', line 22 def address(prefix = "xrb") Util.public_key_to_address(prefix, public_key) end |
#private_key ⇒ Object
14 15 16 |
# File 'lib/nano/wallet/account.rb', line 14 def private_key Util.hex_to_bin(Blake2b.hex(@seed_bin + [@index].pack('L>'), Blake2b::Key.none, 32)) end |
#public_key ⇒ Object
18 19 20 |
# File 'lib/nano/wallet/account.rb', line 18 def public_key Ed25519Blake2b.public_key(private_key) end |