Class: JWT::JWA::Eddsa
- Inherits:
-
Object
- Object
- JWT::JWA::Eddsa
- Includes:
- SigningAlgorithm
- Defined in:
- lib/jwt/jwa/eddsa.rb
Instance Attribute Summary
Attributes included from SigningAlgorithm
Instance Method Summary collapse
-
#initialize(alg) ⇒ Eddsa
constructor
A new instance of Eddsa.
- #sign(data:, signing_key:) ⇒ Object
- #verify(data:, signature:, verification_key:) ⇒ Object
Methods included from SigningAlgorithm
#header, included, #raise_sign_error!, #raise_verify_error!, #valid_alg?
Constructor Details
#initialize(alg) ⇒ Eddsa
Returns a new instance of Eddsa.
8 9 10 |
# File 'lib/jwt/jwa/eddsa.rb', line 8 def initialize(alg) @alg = alg end |
Instance Method Details
#sign(data:, signing_key:) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/jwt/jwa/eddsa.rb', line 12 def sign(data:, signing_key:) unless signing_key.is_a?(RbNaCl::Signatures::Ed25519::SigningKey) raise_encode_error!("Key given is a #{signing_key.class} but has to be an RbNaCl::Signatures::Ed25519::SigningKey") end signing_key.sign(data) end |
#verify(data:, signature:, verification_key:) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/jwt/jwa/eddsa.rb', line 20 def verify(data:, signature:, verification_key:) unless verification_key.is_a?(RbNaCl::Signatures::Ed25519::VerifyKey) raise_decode_error!("key given is a #{verification_key.class} but has to be a RbNaCl::Signatures::Ed25519::VerifyKey") end verification_key.verify(signature, data) rescue RbNaCl::CryptoError false end |