Class: Ed25519::VerifyKey

Inherits:
Object
  • Object
show all
Defined in:
lib/red25519/keys.rb

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ VerifyKey

Returns a new instance of VerifyKey.



46
47
48
49
50
51
52
53
54
# File 'lib/red25519/keys.rb', line 46

def initialize(string)
  case string.length
  when 32
    @key = string
  when 64
    @key = [string].pack("H*")
  else raise ArgumentError, "seed must be 32 or 64 bytes long"
  end
end

Instance Method Details

#inspectObject



60
61
62
# File 'lib/red25519/keys.rb', line 60

def inspect
  "#<Ed25519::VerifyKey:#{to_hex}>"
end

#to_bytesObject Also known as: to_s



64
65
66
# File 'lib/red25519/keys.rb', line 64

def to_bytes
  @key
end

#to_hexObject



69
70
71
# File 'lib/red25519/keys.rb', line 69

def to_hex
  to_bytes.unpack("H*").first
end

#verify(signature, message) ⇒ Object



56
57
58
# File 'lib/red25519/keys.rb', line 56

def verify(signature, message)
  Ed25519::Engine.verify(@key, signature, message)
end