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 ¶
- func GenerateKeyPair(suite abstract.Suite) (*PriKey, *PubKey)
- func Unpack(ciphers []*CipherText) ([]abstract.Point, []abstract.Point)
- type CipherText
- type PriKey
- func (sk *PriKey) Decrypt(ciphertext *CipherText) abstract.Point
- func (sk *PriKey) PartialDecrypt(ciphertext *CipherText) *CipherText
- func (sk *PriKey) PartialProofDecrypt(ciphertext *CipherText, nonce string) (*CipherText, []byte, error)
- func (sk *PriKey) ProofDecrypt(ciphertext *CipherText, nonce string) (abstract.Point, []byte, error)
- type PubKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateKeyPair ¶
GenerateKeyPair generates a new random private/public keypair in the specified group
Types ¶
type CipherText ¶
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 ¶
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 ¶
PubKey is an ElGamal public key
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.