Module: JSON::JWK::JWKizable::EC

Defined in:
lib/json/jwk/jwkizable.rb

Instance Method Summary collapse

Instance Method Details

#to_jwk(ex_params = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/json/jwk/jwkizable.rb', line 23

def to_jwk(ex_params = {})
  params = {
    kty: :EC,
    crv: curve_name,
    x: UrlSafeBase64.encode64(coordinates[:x].to_s(2)),
    y: UrlSafeBase64.encode64(coordinates[:y].to_s(2))
  }.merge ex_params
  params[:d] = UrlSafeBase64.encode64(coordinates[:d].to_s(2)) if private_key?
  JWK.new params
end