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:


29
30
31
# File 'lib/rbnacl/boxes/curve25519xsalsa20poly1305/public_key.rb', line 29

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


43
44
45
# File 'lib/rbnacl/boxes/curve25519xsalsa20poly1305/public_key.rb', line 43

def self.primitive
  :curve25519xsalsa20poly1305
end

Instance Method Details

#primitiveSymbol

The crypto primitive this PublicKey is to be used for.

Returns:

  • (Symbol)

    The primitive


50
51
52
# File 'lib/rbnacl/boxes/curve25519xsalsa20poly1305/public_key.rb', line 50

def primitive
  self.class.primitive
end

#to_bytesString

The raw bytes of the key

Returns:

  • (String)

    the raw bytes.


36
37
38
# File 'lib/rbnacl/boxes/curve25519xsalsa20poly1305/public_key.rb', line 36

def to_bytes
  @public_key
end