class Crypto::Keys::PublicKey

Attributes

network[R]

Public Class Methods

from_bytes(bytes, network = MAINNET) click to toggle source
# File lib/crypto/keys/public_key.rb, line 15
def self.from_bytes(bytes, network = MAINNET)
    PublicKey.new(KeyUtils.to_hex(bytes), network)
end
from_hex(hex, network = MAINNET) click to toggle source
# File lib/crypto/keys/public_key.rb, line 11
def self.from_hex(hex, network = MAINNET)
    PublicKey.new(hex, network)
end
new(public_key_hex, network = MAINNET) click to toggle source
# File lib/crypto/keys/public_key.rb, line 5
def initialize(public_key_hex, network = MAINNET)
    @public_key_hex = public_key_hex
    @network = network
    raise AxentroError, "invalid public key: #{@public_key_hex}" unless is_valid?
end

Public Instance Methods

address() click to toggle source
# File lib/crypto/keys/public_key.rb, line 27
def address
    Address.new(KeyUtils.get_address_from_public_key(self), @network)
end
as_bytes() click to toggle source
# File lib/crypto/keys/public_key.rb, line 23
def as_bytes
 KeyUtils.to_bytes(@public_key_hex)
end
as_hex() click to toggle source
# File lib/crypto/keys/public_key.rb, line 19
def as_hex
    @public_key_hex
end
is_valid?() click to toggle source
# File lib/crypto/keys/public_key.rb, line 31
def is_valid?
    !@public_key_hex.nil? && @public_key_hex.size == 64
end