Class: AtprotoAuth::Encryption::KeyProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/atproto_auth/encryption.rb

Overview

Handles key management and derivation

Instance Method Summary collapse

Constructor Details

#initializeKeyProvider

Returns a new instance of KeyProvider.



123
124
125
# File 'lib/atproto_auth/encryption.rb', line 123

def initialize
  @master_key = load_master_key
end

Instance Method Details

#key_for_context(context) ⇒ Object

Raises:



127
128
129
130
131
132
133
134
135
136
# File 'lib/atproto_auth/encryption.rb', line 127

def key_for_context(context)
  raise ConfigurationError, "Context is required" if context.nil?

  HKDF.derive(
    @master_key,
    salt: salt_for_context(context),
    info: "atproto-#{context}",
    length: 32
  )
end