ecies

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(data []byte, priv *PrivateKey, ecdh ECDH, kdf KDF) ([]byte, error)

Decrypt decrypts ciphertext by receiver private key

func DecryptBase64String added in v0.2.0

func DecryptBase64String(ciphertext string, priv *PrivateKey, ecdh ECDH, kdf KDF) (string, error)

DecryptBase64String decrypts ciphertext in base64 form to plaintext by receiver private key

func DecryptHexString added in v0.2.0

func DecryptHexString(ciphertext string, priv *PrivateKey, ecdh ECDH, kdf KDF) (string, error)

DecryptHexString decrypts ciphertext in hex form to plaintext by receiver private key

func Encrypt

func Encrypt(data []byte, pub *PublicKey, ecdh ECDH, kdf KDF) ([]byte, error)

Encrypt encrypts data using receiver public key

func EncryptStringToBase64 added in v0.2.0

func EncryptStringToBase64(plaintext string, pub *PublicKey, ecdh ECDH, kdf KDF) (string, error)

EncryptStringToBase64 encrypts plaintext to ciphertext in base64 form using receiver public key

func EncryptStringToHex added in v0.2.0

func EncryptStringToHex(plaintext string, pub *PublicKey, ecdh ECDH, kdf KDF) (string, error)

EncryptStringToHex encrypts plaintext to ciphertext in hex form using receiver public key

Types

type ECDH added in v0.2.0

type ECDH func(priv *PrivateKey, pub *PublicKey) (masterSecret []byte)

ECDH calculates a master secret from a private key & a public key. Its output will be passed to a KDF for deriving the encryption key.

type KDF added in v0.2.0

type KDF func(masterSecret []byte) (key []byte, err error)

KDF accepts a master secret & derives a encryption key

type PrivateKey

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

PrivateKey ...

func GenerateKey

func GenerateKey(curve elliptic.Curve) (*PrivateKey, error)

GenerateKey generates a new elliptic curve key pair

func PrivateKeyFromBase64 added in v0.2.0

func PrivateKeyFromBase64(base64Key string, curve elliptic.Curve) (*PrivateKey, error)

PrivateKeyFromBase64 parses a private key from its base64 form

func PrivateKeyFromBytes

func PrivateKeyFromBytes(b []byte, curve elliptic.Curve) *PrivateKey

PrivateKeyFromBytes parses a private key from its raw bytes

func PrivateKeyFromHex

func PrivateKeyFromHex(hexKey string, curve elliptic.Curve) (*PrivateKey, error)

PrivateKeyFromHex parses a private key from its hex form

func (*PrivateKey) Base64 added in v0.2.0

func (priv *PrivateKey) Base64() string

Base64 returns private key bytes in base64 form

func (*PrivateKey) Bytes

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

Bytes returns private key raw bytes

func (*PrivateKey) Hex

func (priv *PrivateKey) Hex() string

Hex returns private key bytes in hex form

type PublicKey

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

PublicKey ...

func PublicKeyFromBase64 added in v0.2.0

func PublicKeyFromBase64(base64Key string, curve elliptic.Curve) (*PublicKey, error)

PublicKeyFromBase64 parses a public key from its base64 form

func PublicKeyFromBytes

func PublicKeyFromBytes(b []byte, curve elliptic.Curve) (*PublicKey, error)

PublicKeyFromBytes parses a public key from its uncompressed raw bytes

func PublicKeyFromHex

func PublicKeyFromHex(hexKey string, curve elliptic.Curve) (*PublicKey, error)

PublicKeyFromHex parses a public key from its hex form

func (*PublicKey) Base64 added in v0.2.0

func (pub *PublicKey) Base64() string

Base64 returns public key bytes in base64 form

func (*PublicKey) Bytes

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

Bytes returns the public key to raw bytes in uncompressed format (Ox04|x|y) https://secg.org/sec1-v2.pdf#subsubsection.2.3.3

func (*PublicKey) Hex

func (pub *PublicKey) Hex() string

Hex returns public key bytes in hex form

Jump to

Keyboard shortcuts

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