Class: JWT::EdDSA::JWK::OKP
- Inherits:
-
JWK::KeyBase
- Object
- JWK::KeyBase
- JWT::EdDSA::JWK::OKP
- Defined in:
- lib/jwt/eddsa/jwk/okp.rb
Overview
Constant Summary collapse
- KTY =
"OKP"
- KTYS =
[KTY, JWT::EdDSA::JWK::OKP, Ed25519::SigningKey, Ed25519::VerifyKey].freeze
- OKP_PUBLIC_KEY_ELEMENTS =
%i[kty n x].freeze
- OKP_PRIVATE_KEY_ELEMENTS =
%i[d].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #export(options = {}) ⇒ Object
-
#initialize(key, params = nil, options = {}) ⇒ OKP
constructor
A new instance of OKP.
- #key_digest ⇒ Object
- #members ⇒ Object
- #private? ⇒ Boolean
- #signing_key ⇒ Object
- #verify_key ⇒ Object
Constructor Details
#initialize(key, params = nil, options = {}) ⇒ OKP
Returns a new instance of OKP.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/jwt/eddsa/jwk/okp.rb', line 13 def initialize(key, params = nil, = {}) params ||= {} # For backwards compatibility when kid was a String params = { kid: params } if params.is_a?(String) key_params = extract_key_params(key) params = params.transform_keys(&:to_sym) check_jwk_params!(key_params, params) super(, key_params.merge(params)) end |
Class Method Details
.import(jwk_data) ⇒ Object
113 114 115 |
# File 'lib/jwt/eddsa/jwk/okp.rb', line 113 def import(jwk_data) new(jwk_data) end |
Instance Method Details
#export(options = {}) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/jwt/eddsa/jwk/okp.rb', line 49 def export( = {}) exported = parameters.clone unless private? && [:include_private] == true exported.reject! do |k, _| OKP_PRIVATE_KEY_ELEMENTS.include?(k) end end exported end |
#key_digest ⇒ Object
37 38 39 |
# File 'lib/jwt/eddsa/jwk/okp.rb', line 37 def key_digest ::JWT::JWK::Thumbprint.new(self).to_s end |
#members ⇒ Object
45 46 47 |
# File 'lib/jwt/eddsa/jwk/okp.rb', line 45 def members OKP_PUBLIC_KEY_ELEMENTS.each_with_object({}) { |i, h| h[i] = self[i] } end |
#private? ⇒ Boolean
41 42 43 |
# File 'lib/jwt/eddsa/jwk/okp.rb', line 41 def private? !signing_key.nil? end |
#signing_key ⇒ Object
31 32 33 34 35 |
# File 'lib/jwt/eddsa/jwk/okp.rb', line 31 def signing_key return @signing_key if defined?(@signing_key) @signing_key = signing_key_from_parameters end |
#verify_key ⇒ Object
25 26 27 28 29 |
# File 'lib/jwt/eddsa/jwk/okp.rb', line 25 def verify_key return @verify_key if defined?(@verify_key) @verify_key = verify_key_from_parameters end |