Class: JOSE::JWS::ALG_EDDSA
- Inherits:
-
Struct
- Object
- Struct
- JOSE::JWS::ALG_EDDSA
- Defined in:
- lib/jose/jws/alg_eddsa.rb
Instance Attribute Summary collapse
-
#sign_type ⇒ Object
Returns the value of attribute sign_type.
Class Method Summary collapse
-
.from_map(fields) ⇒ Object
JOSE::JWS callbacks.
Instance Method Summary collapse
-
#generate_key(fields) ⇒ Object
JOSE::JWS::ALG callbacks.
- #sign(jwk, message) ⇒ Object
- #to_map(fields) ⇒ Object
- #verify(jwk, message, signature) ⇒ Object
Instance Attribute Details
#sign_type ⇒ Object
Returns the value of attribute 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 19 20 |
# 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') when 'EdDSA' return new(:EdDSA), 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
29 30 31 32 |
# File 'lib/jose/jws/alg_eddsa.rb', line 29 def generate_key(fields) okp_type = sign_type == :EdDSA ? :Ed25519 : sign_type return JOSE::JWS::ALG.generate_key([:okp, okp_type], sign_type.to_s) end |
#sign(jwk, message) ⇒ Object
34 35 36 |
# File 'lib/jose/jws/alg_eddsa.rb', line 34 def sign(jwk, ) return jwk.kty.sign(, sign_type) end |
#to_map(fields) ⇒ Object
22 23 24 25 |
# File 'lib/jose/jws/alg_eddsa.rb', line 22 def to_map(fields) alg = sign_type.to_s return fields.put('alg', alg) end |
#verify(jwk, message, signature) ⇒ Object
38 39 40 |
# File 'lib/jose/jws/alg_eddsa.rb', line 38 def verify(jwk, , signature) return jwk.kty.verify(, sign_type, signature) end |