class Izokatu::Rbnacl::PrivateKey::Decrypter

RbNaCl private key decrypter

Constants

DEFAULT_OPTIONS

Default options for Izokatu::Rbnacl::Decrypter

Attributes

auth_data[R]

@return [String] authenticated data

key[R]

@return [String] key for private key encryption/decryption

Public Class Methods

new(key:, encrypted_data:, nonce:, auth_data:) click to toggle source

Initializing option for decryption

@param encrypted_data (encrypted_data) @param nonce (nonce) @param key (key) @param auth_data (auth_data)

@since 0.1.0

Calls superclass method Izokatu::Rbnacl::Decrypter::new
# File lib/izokatu/rbnacl/private_key/decrypter.rb, line 28
def initialize(key:, encrypted_data:, nonce:, auth_data:)
  @key = key
  super(encrypted_data: encrypted_data, nonce: nonce)
  @auth_data = auth_data || DEFAULT_OPTIONS[:auth_data]
end

Public Instance Methods

create_decrypter!() click to toggle source

Creating decrypter instance

@return [RbNaCl::AEAD::XChaCha20Poly1305IETF] decrypter instance

@since 0.1.0

# File lib/izokatu/rbnacl/private_key/decrypter.rb, line 40
def create_decrypter!
  @decrypter = RbNaCl::AEAD::XChaCha20Poly1305IETF.new(key)
end
decrypt_data!() click to toggle source

Decrypting data

@return [Hash] decrypted data

@since 0.1.0

# File lib/izokatu/rbnacl/private_key/decrypter.rb, line 50
def decrypt_data!
  { decrypted_data_string: decrypter.decrypt(nonce, encrypted_data, auth_data) }
end