Class: Izokatu::Rbnacl::PublicKey::Decrypter

Inherits:
Decrypter show all
Defined in:
lib/izokatu/rbnacl/public_key/decrypter.rb

Overview

RbNaCl public key decrypter

Constant Summary

Constants inherited from Decrypter

Decrypter::RBNACL_KEY_CLASSES

Instance Attribute Summary collapse

Attributes inherited from Decrypter

#nonce

Attributes inherited from Decrypter

#decrypted_data, #decrypter, #encrypted_data

Instance Method Summary collapse

Methods inherited from Decrypter

#import_encrypted_data!, #perform

Methods included from Callable

#call

Constructor Details

#initialize(public_key:, private_key:, encrypted_data:, nonce:) ⇒ Decrypter

Initializing option for decryption

Parameters:

Since:

  • 0.1.0



23
24
25
26
27
# File 'lib/izokatu/rbnacl/public_key/decrypter.rb', line 23

def initialize(public_key:, private_key:, encrypted_data:, nonce:)
  @public_key = public_key
  @private_key = private_key
  super(encrypted_data: encrypted_data, nonce: nonce)
end

Instance Attribute Details

#private_keyRbNaCl::Boxes::Curve25519XSalsa20Poly1305::PrivateKey (readonly)

Returns private key.

Returns:

  • (RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PrivateKey)

    private key



12
13
14
# File 'lib/izokatu/rbnacl/public_key/decrypter.rb', line 12

def private_key
  @private_key
end

#public_keyRbNaCl::Boxes::Curve25519XSalsa20Poly1305::PublicKey (readonly)

Returns public key.

Returns:

  • (RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PublicKey)

    public key



10
11
12
# File 'lib/izokatu/rbnacl/public_key/decrypter.rb', line 10

def public_key
  @public_key
end

Instance Method Details

#create_decrypter!RbNaCl::Boxes::Curve25519XSalsa20Poly1305

Initializing decrypter instance

Returns:

  • (RbNaCl::Boxes::Curve25519XSalsa20Poly1305)

    decrypter instance

Since:

  • 0.1.0



35
36
37
# File 'lib/izokatu/rbnacl/public_key/decrypter.rb', line 35

def create_decrypter!
  @decrypter = RbNaCl::Box.new(public_key, private_key)
end

#decrypt_data!Hash

Decrypting data

Returns:

  • (Hash)

    decrypted data

Since:

  • 0.1.0



45
46
47
# File 'lib/izokatu/rbnacl/public_key/decrypter.rb', line 45

def decrypt_data!
  { decrypted_data_string: decrypter.decrypt(nonce, encrypted_data) }
end