elgamal

package
v0.0.0-...-3bfcb49 Latest Latest
Warning

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

Go to latest
Published: May 17, 2016 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package elgamal is an ElGamal implementation based on the DeDiS framework, suitable for usage with any group in which the Decisional Diffie-Hellman problem (DDH) is hard. Only supports encryption of group elements, not of arbitrary byte arrays.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKeyPair

func GenerateKeyPair(suite abstract.Suite) (*PriKey, *PubKey)

GenerateKeyPair generates a new random private/public keypair in the specified group

func Unpack

func Unpack(ciphers []*CipherText) ([]abstract.Point, []abstract.Point)

Unpack an array of ciphertexts to their separate points

Types

type CipherText

type CipherText struct {
	C1 abstract.Point
	C2 abstract.Point
}

CipherText is an ElGamal ciphertext

func Add

func Add(left *CipherText, right *CipherText, pk *PubKey) *CipherText

Add to ciphertexts, resulting in a new ciphertext whose plaintext is the sum of the plaintexts of the two arguments.

func Pack

func Pack(c1 []abstract.Point, c2 []abstract.Point) []*CipherText

Pack two arrays of points to an array of ciphertexts

func (*CipherText) Randomize

func (c *CipherText) Randomize(pk *PubKey) *CipherText

Randomize modifies the ciphertext into a new ciphertext of the same ciphertext (by multiplying it with an ecryption of 1 under the same public key).

type PriKey

type PriKey struct {
	PubKey
	Secret abstract.Secret
}

PriKey is an ElGamal private key

func (*PriKey) Decrypt

func (sk *PriKey) Decrypt(ciphertext *CipherText) abstract.Point

Decrypt the specified ciphertext, resulting in a plaintext point.

func (*PriKey) PartialDecrypt

func (sk *PriKey) PartialDecrypt(ciphertext *CipherText) *CipherText

PartialDecrypt performs the decryption operation on c2 normally, but keep c1

func (*PriKey) PartialProofDecrypt

func (sk *PriKey) PartialProofDecrypt(ciphertext *CipherText, nonce string) (*CipherText, []byte, error)

PartialProofDecrypt does the same as ProofDecrypt, but keeps c1

func (*PriKey) ProofDecrypt

func (sk *PriKey) ProofDecrypt(ciphertext *CipherText, nonce string) (abstract.Point, []byte, error)

ProofDecrypt decrypts the specified ciphertext, and include a proof that we did this correctly (i.e., that the ciphertext was indeed an encryption of the plaintext).

type PubKey

type PubKey struct {
	Suite abstract.Suite
	Base  abstract.Point
	Key   abstract.Point
}

PubKey is an ElGamal public key

func SumKeys

func SumKeys(keys []*PubKey) *PubKey

SumKeys sums the given public keys (more specifically, their h's)

func (*PubKey) Encrypt

func (pk *PubKey) Encrypt(plaintext abstract.Point) *CipherText

Encrypt the specified element with respect to the public key

func (*PubKey) VerifyProof

func (pk *PubKey) VerifyProof(ciphertext *CipherText, plaintext abstract.Point, prf []byte, nonce string) error

VerifyProof verifies a decryption proof against a given public key, cipher text and plaintext

  • that is, check if the proof indeed shows that the ciphertext was an encryption to the public key of the plaintext.

Jump to

Keyboard shortcuts

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