elgamal

package
v0.0.0-...-f966322 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyGen

func KeyGen(secParam int, pointCompression bool) (*PublicKey, *SecretKey)

This function generates a EC-ElGamal key pair

Types

type Ciphertext

type Ciphertext struct {
	C1x *big.Int
	C1y *big.Int
	C2x *big.Int
	C2y *big.Int
}

type CiphertextByte

type CiphertextByte struct {
	C1 []byte
	C2 []byte
}

type PublicKey

type PublicKey struct {
	Curve            *elliptic.Curve
	SecParam         int
	Hx               *big.Int
	Hy               *big.Int
	PointCompression bool
}

func (*PublicKey) Add

func (pk *PublicKey) Add(cA, cB *Ciphertext, rand bool) *Ciphertext

This function, given a public key, homomorphically add two ciphertexts together and returns a ciphertext of their sum. The function will re-randomize the resulting ciphertext (can be seen as homomorphic addition with an encryption of zero) if the input boolean variable "rand" is set to true.

func (*PublicKey) Bytes2Ciphertext

func (pk *PublicKey) Bytes2Ciphertext(ciphertextBytes *CiphertextByte, pointCompression bool) *Ciphertext

This function decodes ciphertext bytes back to a ciphertext struct

func (*PublicKey) CheckOnCurve

func (pk *PublicKey) CheckOnCurve(ciphertext *Ciphertext) bool

This function checks if a given ciphertext is a well-formed ciphertext

func (*PublicKey) Ciphertext2Bytes

func (pk *PublicKey) Ciphertext2Bytes(ciphertext *Ciphertext, pointCompression bool) *CiphertextByte

This function encodes a ciphertext struct to bytes

func (*PublicKey) Encrypt

func (pk *PublicKey) Encrypt(m *big.Int) *Ciphertext

This function, given a public key, encrypts a plaintext message and return a ciphertext

func (*PublicKey) EncryptInv

func (pk *PublicKey) EncryptInv(m *big.Int) *Ciphertext

This function returns a ciphertext of the inverse of the input plaintext

func (*PublicKey) InitCurve

func (pk *PublicKey) InitCurve()

This function initializes a curve under the public key

func (*PublicKey) ScalarMultRandomizer

func (pk *PublicKey) ScalarMultRandomizer(cA *Ciphertext, rand bool) *Ciphertext

This function, given a public key, achieves scalar multiplication on the input ciphertext with a randomly chosen scalar from Zn. The function will re-randomize the resulting ciphertext (can be seen as homomorphic addition with an encryption of zero) if the input boolean variable "rand" is set to true.

type SecretKey

type SecretKey struct {
	Curve *elliptic.Curve
	Hx    *big.Int
	Hy    *big.Int
	Priv  []byte
}

func (*SecretKey) DecryptAndCheck

func (sk *SecretKey) DecryptAndCheck(c *Ciphertext, test []byte) bool

This function, given a secret key, checks if the input ciphertext is an encryption of the input plaintext

func (*SecretKey) DecryptAndCheck0

func (sk *SecretKey) DecryptAndCheck0(c *Ciphertext) bool

This function, given a secret key, checks if the input ciphertext is an encryption of zero

Jump to

Keyboard shortcuts

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