x25519

package module
v0.0.0-...-10cc4d8 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

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 KeySize = 32

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

Variables

This section is empty.

Functions

This section is empty.

Types

type PublicKey

type PublicKey []byte

PublicKey is the type of Curve25519 public keys.

type SecretKey

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

SecretKey is the type of Curve25519 secret keys.

func GenerateKey

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

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

func GenerateKeyUniform

func GenerateKeyUniform(random io.Reader) (*SecretKey, error)

GenerateKeyUniform generates a secret key whose corresponding public key has a uniform representative using entropy from random, or crypto/rand.Reader if random is nil.

func NewSecretKey

func NewSecretKey(sk []byte) *SecretKey

NewSecretKey creates a SecretKey from byte slice sk and len(sk) must be 32.

func (*SecretKey) Bytes

func (k *SecretKey) Bytes() []byte

Bytes returns the secret key as a byte slice.

func (*SecretKey) Public

func (k *SecretKey) Public() PublicKey

Public returns the PublicKey corresponding to the secret key.

func (*SecretKey) PublicUniform

func (k *SecretKey) PublicUniform() UniformRepresentative

PublicUniform returns the uniform representative of the public key corresponding to the secret key, or nil if the public key does not have a uniform representative.

func (*SecretKey) Shared

func (k *SecretKey) Shared(peer PublicKey) []byte

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

func (*SecretKey) SharedUniform

func (k *SecretKey) SharedUniform(peer UniformRepresentative) []byte

SharedUniform computes the shared secret between our secret key and peer public key's uniform representative.

type UniformRepresentative

type UniformRepresentative []byte

UniformRepresentative is the type of Curve25519 public key uniform representatives. See https://www.imperialviolet.org/2013/12/25/elligator.html

func (UniformRepresentative) Public

func (u UniformRepresentative) Public() PublicKey

Public returns the curve25519 public key corresponding to the uniform presentative.

Jump to

Keyboard shortcuts

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