Documentation
¶
Index ¶
- Variables
- func Gen(n, probability int) (*big.Int, *big.Int, *big.Int, error)
- func GeneratePQZp(bitsize, probability int) (p, q, g *big.Int, err error)
- type PrivateKey
- type PublicKey
- func (pub *PublicKey) Encrypt(message []byte) ([]byte, []byte, error)
- func (pub *PublicKey) HommorphicEncMultiple(ciphertext [][2][]byte) ([]byte, []byte, error)
- func (pub *PublicKey) HomomorphicEncTwo(c1, c2, c1dash, c2dash []byte) ([]byte, []byte, error)
- func (pub *PublicKey) SigVerify(r, s, message []byte) (bool, error)
Constants ¶
This section is empty.
Variables ¶
var ErrCipherLarge = errors.New("elgamal: cipher is larger than public key size")
var ErrMessageLarge = errors.New("elgamal: message is larger than public key size")
Functions ¶
func Gen ¶
Note : this section of code is taken from (https://github.com/ldinc/pqg). Author of this code is "Drogunov Igor". Gen emit <p,q,g>. p = 2q + 1, p,q - safe primes g - cyclic group generator Zp performs n Miller-Rabin tests with 1 - 1/(4^n) probability false rate. Gain n - bit width for integer & probability rang for MR. It returns p, q, g and write error message.
Types ¶
type PrivateKey ¶
PrivateKey represents Elgamal private key.
func GenerateKey ¶
func GenerateKey(bitsize, probability int) (*PrivateKey, error)
GenerateKey generates elgamal private key according to given bit size and probability. Moreover, the given probability value is used in choosing prime number P for performing n Miller-Rabin tests with 1 - 1/(4^n) probability false rate.
type PublicKey ¶
PublicKey represents a Elgamal public key.
func (*PublicKey) Encrypt ¶
Encrypt encrypts a plain text represented as a byte array. It returns an error if plain text value is larger than modulus P of Public key.
func (*PublicKey) HommorphicEncMultiple ¶
HommorphicEncMultiple performs homomorphic operation over multiple passed chiphers. Elgamal has multiplicative homomorphic property, so resultant cipher contains the product of multiple numbers.
func (*PublicKey) HomomorphicEncTwo ¶
HomomorphicEncTwo performs homomorphic operation over two passed chiphers. Elgamal has multiplicative homomorphic property, so resultant cipher contains the product of two numbers.