Class: CryptoconditionsRuby::Crypto::Ed25519VerifyingKey

Inherits:
RbNaCl::VerifyKey
  • Object
show all
Defined in:
lib/cryptoconditions_ruby/crypto.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key = nil, encoding = nil) ⇒ Ed25519VerifyingKey

Returns a new instance of Ed25519VerifyingKey.



148
149
150
151
152
153
# File 'lib/cryptoconditions_ruby/crypto.rb', line 148

def initialize(key = nil, encoding = nil)
  @key = key
  encoding = encoding || 'base58'
  @encoder = Crypto.get_encoder(encoding)
  super(@encoder.new.decode(@key))
end

Instance Attribute Details

#encoder=(value) ⇒ Object

Sets the attribute encoder

Parameters:

  • value

    the value to set the attribute encoder to.



145
146
147
# File 'lib/cryptoconditions_ruby/crypto.rb', line 145

def encoder=(value)
  @encoder = value
end

#key=(value) ⇒ Object

Sets the attribute key

Parameters:

  • value

    the value to set the attribute key to.



145
146
147
# File 'lib/cryptoconditions_ruby/crypto.rb', line 145

def key=(value)
  @key = value
end

Instance Method Details

#encode(encoding = 'base58') ⇒ Object



162
163
164
165
# File 'lib/cryptoconditions_ruby/crypto.rb', line 162

def encode(encoding = 'base58')
  encoder = Crypto.get_encoder(encoding).new
  encoder.encode(self.to_s)
end

#verify(signature, data, encoding = 'base58') ⇒ Object



155
156
157
158
159
160
# File 'lib/cryptoconditions_ruby/crypto.rb', line 155

def verify(signature, data, encoding = 'base58')
  encoder = Crypto.get_encoder(encoding)
  super(encoder.new.decode(signature), data)
rescue ::RbNaCl::BadSignatureError
  false
end