Class: CryptoconditionsRuby::Crypto::Ed25519VerifyingKey
- Inherits:
-
RbNaCl::VerifyKey
- Object
- RbNaCl::VerifyKey
- CryptoconditionsRuby::Crypto::Ed25519VerifyingKey
- Defined in:
- lib/cryptoconditions_ruby/crypto.rb
Instance Attribute Summary collapse
-
#encoder ⇒ Object
writeonly
Sets the attribute encoder.
-
#key ⇒ Object
writeonly
Sets the attribute key.
Instance Method Summary collapse
- #encode(encoding = 'base58') ⇒ Object
-
#initialize(key = nil, encoding = nil) ⇒ Ed25519VerifyingKey
constructor
A new instance of Ed25519VerifyingKey.
- #verify(signature, data, encoding = 'base58') ⇒ Object
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
145 146 147 |
# File 'lib/cryptoconditions_ruby/crypto.rb', line 145 def encoder=(value) @encoder = value end |
#key=(value) ⇒ Object
Sets the attribute key
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 |