Class: RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PublicKey

Inherits:
Object
  • Object
show all
Includes:
KeyComparator, Serializable
Defined in:
lib/rbnacl/boxes/curve25519xsalsa20poly1305/public_key.rb

Overview

RbNaCl::Box public key. Send it (securely!) to your friends.

This class stores the NaCL public key, and provides some convenience functions for working with it.

Constant Summary collapse

BYTES =

The size of the key, in bytes

Boxes::Curve25519XSalsa20Poly1305::PUBLICKEYBYTES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Serializable

#inspect, #to_s, #to_str

Methods included from KeyComparator

#<=>, #==

Constructor Details

#initialize(public_key) ⇒ Object

Initializes a new PublicKey for key operations.

Takes the (optionally encoded) public key bytes. This can be shared with many people and used to establish key pairs with their private key, for the exchanging of messages using a RbNaCl::Box

Parameters:

  • public_key (String)

    The public key

Raises:



27
28
29
# File 'lib/rbnacl/boxes/curve25519xsalsa20poly1305/public_key.rb', line 27

def initialize(public_key)
  @public_key = Util.check_string(public_key, BYTES, "Public key")
end

Class Method Details

.primitiveSymbol

The crypto primitive the PublicKey class is to be used for

Returns:

  • (Symbol)

    The primitive



41
42
43
# File 'lib/rbnacl/boxes/curve25519xsalsa20poly1305/public_key.rb', line 41

def self.primitive
  :curve25519xsalsa20poly1305
end

Instance Method Details

#primitiveSymbol

The crypto primitive this PublicKey is to be used for.

Returns:

  • (Symbol)

    The primitive



48
49
50
# File 'lib/rbnacl/boxes/curve25519xsalsa20poly1305/public_key.rb', line 48

def primitive
  self.class.primitive
end

#to_bytesString

The raw bytes of the key

Returns:

  • (String)

    the raw bytes.



34
35
36
# File 'lib/rbnacl/boxes/curve25519xsalsa20poly1305/public_key.rb', line 34

def to_bytes
  @public_key
end