elgamal

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(privKey *elgamal.PrivateKey, d []byte) ([]byte, error)

Decrypt decrypts byte slice with elgamal private key.

func ElgamalGenerate

func ElgamalGenerate(priv *elgamal.PrivateKey, rand io.Reader) (err error)

ElgamalGenerate generate an elgamal key pair.

func Encrypt

func Encrypt(pubKey *elgamal.PublicKey, input []byte) ([]byte, error)

Encrypt encrypts byte slice with elgamal public key.

func GenerateKeys

func GenerateKeys() (*elgamal.PrivateKey, *elgamal.PublicKey, error)

GenerateKeys returns elgamal private-public keys pair.

Types

type Decrypter

type Decrypter interface {
	// Decrypt decrypt a block of data.
	// return decrypted block or nil and error if error happens.
	Decrypt(data []byte) ([]byte, error)
}

Decrypter decrypts data.

type ElgPrivateKey

type ElgPrivateKey [256]byte

ElgPrivateKey is elgamal private key.

func (ElgPrivateKey) Len

func (elg ElgPrivateKey) Len() int

Len returns elgamal private key length.

func (ElgPrivateKey) NewDecrypter

func (elg ElgPrivateKey) NewDecrypter() (Decrypter, error)

NewDecrypter is decryptor constructor.

type ElgPublicKey

type ElgPublicKey [256]byte

ElgPublicKey is elgamal public key.

func (ElgPublicKey) Len

func (elg ElgPublicKey) Len() int

Len returns elgamal public key length.

func (ElgPublicKey) NewEncrypter

func (elg ElgPublicKey) NewEncrypter() (Encrypter, error)

NewEncrypter is encryptor constructor.

type ElgamalEncryption

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

ElgamalEncryption is elgamal encryption struct.

func (*ElgamalEncryption) Encrypt

func (elg *ElgamalEncryption) Encrypt(data []byte) ([]byte, error)

Encrypt encrypts input byte slice.

func (*ElgamalEncryption) EncryptPadding

func (elg *ElgamalEncryption) EncryptPadding(data []byte, zeroPadding bool) ([]byte, error)

EncryptPadding encrypts input byte slice.

type Encrypter

type Encrypter interface {
	// encrypt a block of data.
	// return encrypted block or nil and error if an error happened.
	Encrypt(data []byte) ([]byte, error)
}

Encrypter encrypts data.

type PrivateEncryptionKey

type PrivateEncryptionKey interface {
	// NewDecrypter create a new decryption object for this private key to decrypt data encrypted to our public key.
	// returns decrypter or nil and error if the private key is in a bad format.
	NewDecrypter() (Decrypter, error)
}

PrivateEncryptionKey is interface for producing decrypter.

type PublicEncryptionKey

type PublicEncryptionKey interface {
	// NewEncrypter returns a new encrypter to encrypt data to this public key.
	NewEncrypter() (Encrypter, error)

	// Len returns length of this public key in bytes.
	Len() int
}

PublicEncryptionKey is interface for public encryption key.

Jump to

Keyboard shortcuts

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