ecdh

package module
v0.0.0-...-fc0281a Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: BSD-3-Clause Imports: 4 Imported by: 1

Documentation

Overview

ECDH implementation with curve25519. https://tools.ietf.org/html/rfc7748

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pair

type Pair struct {
	Private PrivateKey
	Public  PublicKey
}

Pair holds private and public key.

func New

func New() (*Pair, error)

New generates a pair of a random private and corresponding public key. Private key consists of randomly generated bytes. (rfc7748 pages 7/8) Both keys size is 32 bytes.

func Use

func Use(private []byte) (*Pair, error)

Use takes a []byte value of a valid PrivateKey and calculates a Pair.

type PrivateKey

type PrivateKey []byte

func (PrivateKey) Bytes

func (pri PrivateKey) Bytes() []byte

func (PrivateKey) PlainSecret

func (pri PrivateKey) PlainSecret(pub PublicKey) ([]byte, error)

PlainSecret provides a shared secret (32 bytes) of the given private and public keys.

func (PrivateKey) Public

func (pri PrivateKey) Public() (PublicKey, error)

Public provides the PublicKey of the given PrivateKey.

func (PrivateKey) Secret

func (pri PrivateKey) Secret(pub PublicKey) (SharedSecret, error)

Secret provides a SHA3 hashed shared secret of the given private and public keys. SharedSecret size is 64 bytes hashed by SHAKE256.

type PublicKey

type PublicKey []byte

func (PublicKey) Bytes

func (pub PublicKey) Bytes() []byte

type SharedSecret

type SharedSecret []byte

func (SharedSecret) Bytes

func (s SharedSecret) Bytes() []byte

Jump to

Keyboard shortcuts

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