class Universa::KeyAddress

The com.icodici.crypto.KeyAddress extension. As it is immutable, caching is used to avoid unnecessary UMI calls.

Public Class Methods

from_packed(binary_string) click to toggle source

Unpack from binary bytes @param [String] binary_string with binary packed bytes

# File lib/universa/keys.rb, line 154
def self.from_packed(binary_string)
  binary_string.force_encoding 'binary'
  KeyAddress.new(binary_string)
end

Public Instance Methods

==(other) click to toggle source

Compare KeyAddress with another KeyAddress or its string or even binary representation. Analyzes string length to select proper strategy.

Calls superclass method
# File lib/universa/keys.rb, line 167
def == other
  if other.is_a?(KeyAddress)
    super
  elsif other.is_a?(String)
    case other.size
      when 37, 53
        # it is for sure packed representation
        packed == other
      else
        # is should be string representation then
        to_s == other
    end
  else
    false
  end
end
eql?(other) click to toggle source
# File lib/universa/keys.rb, line 188
def eql?(other)
  self == other
end
hash() click to toggle source
# File lib/universa/keys.rb, line 184
def hash
  to_s.hash
end
packed() click to toggle source

returns binary representation. It is not a string representation! @return [String] binary string representation

# File lib/universa/keys.rb, line 161
def packed
  @packed ||= get_packed.force_encoding 'binary'
end
to_s() click to toggle source

String form of the key which could be used to unpack it back @return [String] packed string representation

# File lib/universa/keys.rb, line 148
def to_s
  @string ||= toString()
end