ecc

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KeyLength is the length of the ECC key.
	KeyLength = curve25519.ScalarSize
	// CipherTextMinLength is the minimum length of the ciphertext.
	CipherTextMinLength = curve25519.ScalarSize + chacha20poly1305.CipherTextMinLength
)

Variables

View Source
var ErrInvalidKeyLength = errors.New("invalid key length [please use " + strconv.Itoa(curve25519.ScalarSize) + " bytes]")

ErrInvalidKeyLength is returned when the key length is invalid.

Functions

This section is empty.

Types

type PrivateKey

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

PrivateKey represents a private key.

func GetPrivateKeyForBytes added in v0.3.0

func GetPrivateKeyForBytes(key []byte) (*PrivateKey, error)

GetPrivateKeyForBytes returns a private key for given bytes. Please use exactly 32 bytes.

func NewPrivateKey

func NewPrivateKey() (*PrivateKey, error)

NewPrivateKey generates a new random private key.

func (*PrivateKey) Bytes

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

Bytes returns the bytes of the private key.

func (*PrivateKey) Decrypt

func (privateKey *PrivateKey) Decrypt(ciphertext []byte, compression bool) (data []byte, err error)

Decrypt decrypts ciphertext with the private key.

func (*PrivateKey) PublicKey

func (privateKey *PrivateKey) PublicKey() (*PublicKey, error)

PublicKey returns the public key corresponding to the private key. The public key is derived from the private key.

type PublicKey

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

PublicKey represents a public key.

func GetPublicKeyForBytes added in v0.3.0

func GetPublicKeyForBytes(key []byte) (*PublicKey, error)

GetPublicKeyForBytes returns a public key for given bytes. Please use exactly 32 bytes.

func (*PublicKey) Bytes

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

Bytes returns the bytes of the public key.

func (*PublicKey) Encrypt

func (publicKey *PublicKey) Encrypt(data []byte, compression bool) (ciphertext []byte, err error)

Encrypt encrypts data with the public key.

Jump to

Keyboard shortcuts

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