elgamal

package module
v0.0.0-...-d2ff8c8 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2014 License: MIT Imports: 7 Imported by: 0

README

elgamal

Pure elgamal cryptosystem implemented in Go

travis

introduction

Implementation of the El Gamal cryptosystem. See http://en.wikipedia.org/wiki/ElGamal_encryption for an introduction.

The difference between this implementation and the one at golang.org/x/crypto/openpgp/elgamal is the use of absolutly no padding here.

The absance of padding is cool if you want to encrypt numbers and need to make algebra on the cypher texts. The use of padding is needed when you encrypt data and you do not want to allow algebraic operations on the cypher texts.

Another important feature of the library is the ease of serilisation of all the structs in JSON and BSON.

caveat

As any cryptographic library, if you use it, you need to trust it. Unfortunatly, this library as not been verified by a third party. There might be some bugs and vulnerabilities. If you find one, please fill a bug.

documentation

Thanks to godoc.org, the documentation is available at http://godoc.org/github.com/didiercrunch/elgamal

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cypher

type Cypher struct {
	C1, C2, P *big.Int
}

func (*Cypher) FromJSON

func (this *Cypher) FromJSON(json map[string]string) (*Cypher, error)

func (*Cypher) GetBSON

func (this *Cypher) GetBSON() (interface{}, error)

func (*Cypher) MarshalJSON

func (this *Cypher) MarshalJSON() ([]byte, error)

func (*Cypher) Mul

func (this *Cypher) Mul(cypher1, cypher2 *Cypher) *Cypher

func (*Cypher) ToJSON

func (this *Cypher) ToJSON() map[string]string

func (*Cypher) UnmarshalJSON

func (this *Cypher) UnmarshalJSON(bytes []byte) error

type PrivateKey

type PrivateKey struct {
	PublicKey
	X *big.Int
}

PrivateKey represents an ElGamal private key.

func (*PrivateKey) Decrypt

func (priv *PrivateKey) Decrypt(cypher *Cypher) (msg []byte)

func (*PrivateKey) GetBSON

func (this *PrivateKey) GetBSON() (interface{}, error)

type PublicKey

type PublicKey struct {
	G, P, Y *big.Int
}

PublicKey represents an ElGamal public key.

func (*PublicKey) Encrypt

func (pub *PublicKey) Encrypt(msg []byte, random io.Reader) (cypher *Cypher, err error)

func (*PublicKey) GetBSON

func (this *PublicKey) GetBSON() (interface{}, error)

Jump to

Keyboard shortcuts

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