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 it in the shapes the token backends need: the raw PEM for PasetoToken and the 32-byte seed for 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.
16 17 18 |
# File 'lib/nonnative/ed25519_key.rb', line 16 def initialize(path) @pem = File.read(path) end |
Instance Attribute Details
#pem ⇒ String (readonly)
Returns the PEM contents (PKCS#8 Ed25519 private key).
21 22 23 |
# File 'lib/nonnative/ed25519_key.rb', line 21 def pem @pem end |
Instance Method Details
#seed ⇒ String
Extracts the raw 32-byte Ed25519 seed from the PEM.
26 27 28 |
# File 'lib/nonnative/ed25519_key.rb', line 26 def seed OpenSSL::PKey.read(@pem).raw_private_key end |