Sha256: 8e7c31e53d9668e83f414280cba46c11e0d0c0a8ba9f3afd783e0be8f936b89c

Contents?: true

Size: 826 Bytes

Versions: 4

Compression:

Stored size: 826 Bytes

Contents

# frozen_string_literal: true

module X25519
  # X25519 public keys and shared secrets
  #
  # Montgomery-u coordinates of points on the elliptic curve used by X25519
  # (a.k.a. Curve25519)
  class MontgomeryU
    # Create an object representing a Montgomery-u coordinate from a bytestring
    #
    # @param bytes [String] 32-byte compressed Montgomery-u coordinate
    def initialize(bytes)
      X25519.validate_key_bytes(bytes)
      @bytes = bytes
    end

    # Return a compressed Montgomery-u coordinate serialized as a bytestring
    #
    # @return [String] bytestring serialization of a Montgomery-u coordinate
    def to_bytes
      @bytes
    end

    # Show hex representation of serialized coordinate in string inspection
    def inspect
      "#<#{self.class}:#{@bytes.unpack('H*').first}>"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
x25519-1.0.2 lib/x25519/montgomery_u.rb
x25519-1.0.1 lib/x25519/montgomery_u.rb
x25519-1.0.0 lib/x25519/montgomery_u.rb
x25519-0.2.0 lib/x25519/montgomery_u.rb