Method: Asymmetric.decrypt

Defined in:
lib/aspis/asymmetric.rb

.decrypt(input, public_key, private_key, ask_pass) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/aspis/asymmetric.rb', line 28

def self.decrypt(input, public_key, private_key, ask_pass)
  sender_public_key = File.read(public_key)
  sender_public_key = Base64.decode64(sender_public_key)

  recipient_private_key = File.read(private_key)
  recipient_private_key = Symmetric.decrypt(recipient_private_key, ask_pass)

  box = RbNaCl::SimpleBox.from_keypair(sender_public_key, recipient_private_key)

  input = JSON.parse(input)
  ciphertext = input['ciphertext']
  ciphertext = Base64.decode64(ciphertext)
  box.decrypt(ciphertext)
end