Class: BlindIndex::KeyGenerator
- Inherits:
-
Object
- Object
- BlindIndex::KeyGenerator
- Defined in:
- lib/blind_index/key_generator.rb
Instance Method Summary collapse
-
#index_key(table:, bidx_attribute:) ⇒ Object
pattern ported from CipherSweet ciphersweet.paragonie.com/internals/key-hierarchy.
-
#initialize(master_key) ⇒ KeyGenerator
constructor
A new instance of KeyGenerator.
Constructor Details
#initialize(master_key) ⇒ KeyGenerator
Returns a new instance of KeyGenerator.
3 4 5 |
# File 'lib/blind_index/key_generator.rb', line 3 def initialize(master_key) @master_key = master_key end |
Instance Method Details
#index_key(table:, bidx_attribute:) ⇒ Object
pattern ported from CipherSweet ciphersweet.paragonie.com/internals/key-hierarchy
9 10 11 12 13 14 15 16 |
# File 'lib/blind_index/key_generator.rb', line 9 def index_key(table:, bidx_attribute:) raise ArgumentError, "Missing table for key generation" if table.to_s.empty? raise ArgumentError, "Missing field for key generation" if bidx_attribute.to_s.empty? c = "\x7E"*32 root_key = hkdf(BlindIndex.decode_key(@master_key, name: "Master key"), salt: table.to_s, info: "#{c}#{bidx_attribute}", length: 32, hash: "sha384") hash_hmac("sha256", pack([table, bidx_attribute, bidx_attribute]), root_key) end |