ephemeral

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyPair

type KeyPair struct {
	PrivateKey *PrivateKey
	PublicKey  *PublicKey
}

KeyPair represents the generated ephemeral elliptic curve private and public key pair

func GenerateKeyPair

func GenerateKeyPair() (*KeyPair, error)

GenerateKeyPair generates a pair of public and private elliptic curve ephemeral key that can be used as an input for ECDH.

type PrivateKey

type PrivateKey btcec.PrivateKey

PrivateKey is an ephemeral private elliptic curve key.

func UnmarshalPrivateKey

func UnmarshalPrivateKey(bytes []byte) *PrivateKey

UnmarshalPrivateKey turns a slice of bytes into a `PrivateKey`.

func (*PrivateKey) Ecdh

func (pk *PrivateKey) Ecdh(publicKey *PublicKey) *SymmetricEcdhKey

Ecdh performs Elliptic Curve Diffie-Hellman operation between public and private key. The returned value is `SymmetricEcdhKey` that can be used for encryption and decryption.

func (*PrivateKey) Marshal

func (pk *PrivateKey) Marshal() []byte

Marshal turns a `PrivateKey` into a slice of bytes.

type PublicKey

type PublicKey btcec.PublicKey

PublicKey is an ephemeral public elliptic curve key.

func UnmarshalPublicKey

func UnmarshalPublicKey(bytes []byte) (*PublicKey, error)

UnmarshalPublicKey turns a slice of bytes into a `PublicKey`.

func (*PublicKey) IsKeyMatching

func (pk *PublicKey) IsKeyMatching(privateKey *PrivateKey) bool

IsKeyMatching verifies if private key is valid for given public key. It checks if public key equals `g^privateKey`, where `g` is a base point of the curve.

func (*PublicKey) Marshal

func (pk *PublicKey) Marshal() []byte

Marshal turns a `PublicKey` into a slice of bytes.

type SymmetricEcdhKey

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

SymmetricEcdhKey is an ephemeral Elliptic Curve key created with Diffie-Hellman key exchange and implementing `SymmetricKey` interface.

func (*SymmetricEcdhKey) Decrypt

func (sek *SymmetricEcdhKey) Decrypt(ciphertext []byte) (plaintext []byte, err error)

Decrypt ciphertext.

func (*SymmetricEcdhKey) Encrypt

func (sek *SymmetricEcdhKey) Encrypt(plaintext []byte) ([]byte, error)

Encrypt plaintext.

type SymmetricKey

type SymmetricKey interface {
	Encrypt([]byte) ([]byte, error)
	Decrypt([]byte) ([]byte, error)
}

SymmetricKey is an ephemeral key shared between two parties that was established with Diffie-Hellman key exchange over a channel that does not need to be secure.

Jump to

Keyboard shortcuts

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