Class: Nonnative::Ed25519Key
- Inherits:
-
Object
- Object
- Nonnative::Ed25519Key
- Defined in:
- lib/nonnative/ed25519_key.rb
Overview
Loads an Ed25519 private key from a PEM file for signing tokens.
Verifiers such as go-service use Ed25519 keys encoded as PKCS#8 PEM. This reads the PEM once and exposes the 32-byte seed required by JwtToken.
Instance Attribute Summary collapse
-
#pem ⇒ String
readonly
The PEM contents (PKCS#8 Ed25519 private key).
Instance Method Summary collapse
-
#initialize(path) ⇒ Ed25519Key
constructor
A new instance of Ed25519Key.
-
#seed ⇒ String
Extracts the raw 32-byte Ed25519 seed from the PEM.
Constructor Details
#initialize(path) ⇒ Ed25519Key
Returns a new instance of Ed25519Key.
15 16 17 |
# File 'lib/nonnative/ed25519_key.rb', line 15 def initialize(path) @pem = File.read(path) end |
Instance Attribute Details
#pem ⇒ String (readonly)
Returns the PEM contents (PKCS#8 Ed25519 private key).
20 21 22 |
# File 'lib/nonnative/ed25519_key.rb', line 20 def pem @pem end |
Instance Method Details
#seed ⇒ String
Extracts the raw 32-byte Ed25519 seed from the PEM.
25 26 27 |
# File 'lib/nonnative/ed25519_key.rb', line 25 def seed OpenSSL::PKey.read(@pem).raw_private_key end |