class Prototok::Ciphers::V1::EncryptedSign

Public Class Methods

key(private_key=nil) click to toggle source
# File lib/prototok/ciphers/V1/encrypted_sign.rb, line 24
def self.key private_key=nil
  if private_key.nil?
    cipher_class::PrivateKey.generate.to_bytes
  else
    cipher_class::PrivateKey.new(private_key).public_key.to_bytes
  end
end
new(private_key, remote_public_key) click to toggle source
# File lib/prototok/ciphers/V1/encrypted_sign.rb, line 9
def initialize(private_key, remote_public_key)
  @private_key = private_key
  @remote_public_key = remote_public_key
  @cipher = cipher_class.new(@remote_public_key, @private_key)
end

Public Instance Methods

decode(decoded_nonce, decoded_blob) click to toggle source
# File lib/prototok/ciphers/V1/encrypted_sign.rb, line 20
def decode(decoded_nonce, decoded_blob)
  @cipher.decrypt(decoded_nonce, decoded_blob)
end
encode(blob) click to toggle source
# File lib/prototok/ciphers/V1/encrypted_sign.rb, line 15
def encode(blob)
  nonce = RbNaCl::Random.random_bytes(cipher_class.nonce_bytes)
  [nonce, @cipher.encrypt(nonce, blob)]
end