Class: JOSE::JWS::ALG_EDDSA

Inherits:
Struct
  • Object
show all
Defined in:
lib/jose/jws/alg_eddsa.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sign_typeObject

Returns the value of attribute sign_type

Returns:

  • (Object)

    the current value of sign_type


1
2
3
# File 'lib/jose/jws/alg_eddsa.rb', line 1

def sign_type
  @sign_type
end

Class Method Details

.from_map(fields) ⇒ Object

JOSE::JWS callbacks


5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/jose/jws/alg_eddsa.rb', line 5

def self.from_map(fields)
  case fields['alg']
  when 'Ed25519'
    return new(:Ed25519), fields.delete('alg')
  when 'Ed25519ph'
    return new(:Ed25519ph), fields.delete('alg')
  when 'Ed448'
    return new(:Ed448), fields.delete('alg')
  when 'Ed448ph'
    return new(:Ed448ph), fields.delete('alg')
  else
    raise ArgumentError, "invalid 'alg' for JWS: #{fields['alg'].inspect}"
  end
end

Instance Method Details

#generate_key(fields) ⇒ Object

JOSE::JWS::ALG callbacks


27
28
29
# File 'lib/jose/jws/alg_eddsa.rb', line 27

def generate_key(fields)
  return JOSE::JWS::ALG.generate_key([:okp, sign_type], sign_type.to_s)
end

#sign(jwk, message) ⇒ Object


31
32
33
# File 'lib/jose/jws/alg_eddsa.rb', line 31

def sign(jwk, message)
  return jwk.kty.sign(message, sign_type)
end

#to_map(fields) ⇒ Object


20
21
22
23
# File 'lib/jose/jws/alg_eddsa.rb', line 20

def to_map(fields)
  alg = sign_type.to_s
  return fields.put('alg', alg)
end

#verify(jwk, message, signature) ⇒ Object


35
36
37
# File 'lib/jose/jws/alg_eddsa.rb', line 35

def verify(jwk, message, signature)
  return jwk.kty.verify(message, sign_type, signature)
end