ecies

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(data []byte, priv *PrivateKey) ([]byte, error)

Decrypt decrypts ciphertext by receiver private key

func DecryptString

func DecryptString(ciphertext string, priv *PrivateKey) (string, error)

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

func Encrypt

func Encrypt(data []byte, pub *PublicKey) ([]byte, error)

Encrypt encrypts data using receiver public key

func EncryptString

func EncryptString(plaintext string, pub *PublicKey) (string, error)

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

Types

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 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) 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 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) 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