Class: Izokatu::KeysGenerator Abstract

Inherits:
Object
  • Object
show all
Extended by:
Callable
Includes:
Contracts
Defined in:
lib/izokatu/keys_generator.rb

Overview

This class is abstract.

Subclasses are containing implementation of #generate_private_key and #generate_public_key

Abstract class for keys generators

Constant Summary collapse

KEYS_SYMBOLS =

Default key symbols for RbNaCl and OpenSSL keys

%i[private_key public_key].freeze
KEY_CLASSES =

Classes of RbNaCl and OpenSSL keys

[
  RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PrivateKey,
  RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PublicKey,
  OpenSSL::PKey::RSA,
  OpenSSL::PKey::EC
].freeze

Instance Method Summary collapse

Methods included from Callable

call

Instance Method Details

#generate_private_keyObject (private)

Performing generation of private key

Raises:

  • RuntimeError

Since:

  • 0.1.0



40
41
42
# File 'lib/izokatu/keys_generator.rb', line 40

def generate_private_key
  raise 'Not implemented!'
end

#generate_public_key(_private_key) ⇒ Object (private)

Performing generation of public key

Raises:

  • RuntimeError

Since:

  • 0.1.0



49
50
51
# File 'lib/izokatu/keys_generator.rb', line 49

def generate_public_key(_private_key)
  raise 'Not implemented!'
end

#performHash

Performing generation of private and public keys

Returns:

  • (Hash)

    public and private keys

Since:

  • 0.1.0



28
29
30
31
# File 'lib/izokatu/keys_generator.rb', line 28

def perform
  generate_private_key
    .then { |private_key| { private_key: private_key, public_key: generate_public_key(private_key) } }
end