Module: Linzer::JWS
- Defined in:
- lib/linzer/jws.rb
Overview
Note:
This module requires the jwt and ed25519 gems.
JSON Web Signature (JWS) compatible key support.
This module provides integration with the jwt gem for working with JWK (JSON Web Key) format keys. It enables interoperability with systems using JWS/JWT standards.
Currently supports:
-
EdDSA (Ed25519)
Defined Under Namespace
Classes: Key
Class Method Summary collapse
-
.generate_key(algorithm:) ⇒ JWS::Key
Generates a new JWS-compatible key pair.
-
.jwk_import(key, params = {}) ⇒ JWS::Key
Imports a key from JWK (JSON Web Key) format.
Class Method Details
.generate_key(algorithm:) ⇒ JWS::Key
Generates a new JWS-compatible key pair.
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/linzer/jws.rb', line 60 def generate_key(algorithm:) case String(algorithm) when "EdDSA" ed25519_keypair = ::Ed25519::SigningKey.generate material = JWT::JWK.new(ed25519_keypair) Linzer::JWS::Key.new(material) else err_msg = "Algorithm '#{algorithm}' is unsupported or not implemented yet." raise Linzer::Error, err_msg end end |
.jwk_import(key, params = {}) ⇒ JWS::Key
Imports a key from JWK (JSON Web Key) format.
45 46 47 48 |
# File 'lib/linzer/jws.rb', line 45 def jwk_import(key, params = {}) material = JWT::JWK.import(key) Linzer::JWS::Key.new(material, params) end |