class ZMQ::Curve

Secure authentication and confidentiality.

Public Class Methods

keypair() click to toggle source

Generate a keypair. Returns a hash with the :public and :private keys.

# File lib/0mq/curve.rb, line 9
def self.keypair
  public_key  = FFI::MemoryPointer.new :char, 41, true
  private_key = FFI::MemoryPointer.new :char, 41, true
  
  rc = LibZMQ::zmq_curve_keypair public_key, private_key
  
  begin
    ZMQ.error_check true if rc==-1
  rescue Errno::EOPNOTSUPP
    raise Errno::EOPNOTSUPP, "Curve requires libzmq to be compiled with libsodium."
  end
  
  { public: public_key.read_string, private: private_key.read_string }
end