x25519

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: Apache-2.0 Imports: 5 Imported by: 3

README

x25519 Elliptic curve Diffie-Hellman key exchange over Curve25519

Doc at https://godoc.org/github.com/riobard/go-x25519

Documentation

Overview

Package x25519 implements Elliptic Curve Diffie-Hellman (ECDH) function over Curve25519. Details at https://cr.yp.to/ecdh.html and https://tools.ietf.org/html/rfc7748

Index

Constants

View Source
const KEYSZ = 32

KEYSZ is the size of keys in bytes used in this package.

Variables

This section is empty.

Functions

This section is empty.

Types

type Curve

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

Curve is the type of Curve25519 secret keys.

func Get

func Get(sk []byte) *Curve

Get creates a PrivateKey from []byte sk and len(sk) must be 32.

func New

func New(random io.Reader) (k *Curve, err error)

New generates a secret key using entropy from random, or crypto/rand.Reader if random is nil.

func (*Curve) Private

func (k *Curve) Private() *PrivateKey

Private returns the secret key as a byte array pointer.

func (*Curve) Public

func (k *Curve) Public() *PublicKey

Public returns the PublicKey corresponding to the secret key.

func (*Curve) Shared

func (k *Curve) Shared(peer *PublicKey) ([]byte, error)

Shared computes the shared secret between our secret key and peer's public key.

type PrivateKey

type PrivateKey = [KEYSZ]byte

PrivateKey is the type of Curve25519 secret keys.

type PublicKey

type PublicKey = [KEYSZ]byte

PublicKey is the type of Curve25519 public keys.

Jump to

Keyboard shortcuts

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