x25519

package
v0.0.0-...-9b94c9a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package x25519 implements Elliptic Curve Diffie-Hellman (ECDH) function over Curve25519

Index

Constants

View Source
const (
	// GroupElementLength is the length of a ECDH group element in bytes.
	GroupElementLength = 32

	// PublicKeySize is the size of a serialized PublicKey in bytes.
	PublicKeySize = GroupElementLength

	// PrivateKeySize is the size of a serialized PrivateKey in bytes.
	PrivateKeySize = GroupElementLength
)

Key sizes

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateKey

type PrivateKey struct {
	PublicKey
	// contains filtered or unexported fields
}

PrivateKey represents an X25519 private key.

func GenerateKey

func GenerateKey(random io.Reader) (*PrivateKey, error)

GenerateKey generates an X25519 keypair using the random source random (for example, crypto/rand.Reader).

func (*PrivateKey) Bytes

func (priv *PrivateKey) Bytes() []byte

Bytes returns the raw private key.

func (*PrivateKey) MarshalPEM

func (priv *PrivateKey) MarshalPEM() []byte

MarshalPEM encodes a X25519 private key to PEM.

func (*PrivateKey) Public

func (priv *PrivateKey) Public() crypto.PublicKey

Public returns the public key corresponding to priv.

func (*PrivateKey) SetBytes

func (priv *PrivateKey) SetBytes(b []byte)

SetBytes interprets b as the bytes of a big-endian private key.

func (*PrivateKey) Shared

func (priv *PrivateKey) Shared(peer *PublicKey) []byte

Shared computes the shared key corresponding to priv and peer's public key.

func (*PrivateKey) UnmarshalPEM

func (priv *PrivateKey) UnmarshalPEM(data []byte) error

UnmarshalPEM decodes an X25519 private key PEM block.

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

PublicKey represents an X25519 public key.

func (*PublicKey) Bytes

func (pub *PublicKey) Bytes() []byte

Bytes returns the raw public key.

func (*PublicKey) SetBytes

func (pub *PublicKey) SetBytes(b []byte)

SetBytes interprets b as the bytes of a big-endian public key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL