Documentation ¶
Index ¶
- func GenerateKeyPair(bitlen int) (*PubKey, *PrvKey, error)
- type PrvKey
- type PubKey
- func (pk *PubKey) Add(ct1, ct2 *big.Int) (*big.Int, error)
- func (pk *PubKey) AddPlaintext(ct *big.Int, msg *big.Int) (*big.Int, error)
- func (pk *PubKey) DivPlaintext(ct *big.Int, msg *big.Int) (*big.Int, error)
- func (pk *PubKey) Encrypt(msg *big.Int) (*big.Int, error)
- func (pk *PubKey) MultPlaintext(ct *big.Int, msg *big.Int) (*big.Int, error)
- func (pk *PubKey) Sub(ct1, ct2 *big.Int) *big.Int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type PrvKey ¶
type PrvKey struct {
// contains filtered or unexported fields
}
PrvKey -- used to perform decryption.
type PubKey ¶
PubKey -- used to perform encryption and homomorphic operations.
func (*PubKey) Add ¶
Add -- returns a ciphertext `ct3` that will decipher to the sum of the corresponding plaintext messages (`m1`, `m2`) ciphered to (`ct1`, `ct2`) (i.e if ct1 = Enc(m1) and ct2 = Enc(m2), then Dec(Add(ct1, ct2)) = m1 + m2 mod N)
func (*PubKey) AddPlaintext ¶
AddPlaintext -- returns the ciphertext the will decipher to addition of the plaintexts (i.e if ct = Enc(m1), then Dec(AddPlaintext(ct, m2)) = m1 + m2 mod N)
func (*PubKey) DivPlaintext ¶
DivPlaintext -- returns the ciphertext the will decipher to division of the plaintexts (i.e if ct = Enc(m1), then Dec(DivPlaintext(ct, m2)) = m1 / m2 mod N)
func (*PubKey) MultPlaintext ¶
MultPlaintext -- returns the ciphertext the will decipher to multiplication of the plaintexts (i.e. if ct = Enc(m1), then Dec(MultPlaintext(ct, m2)) = m1 * m2 mod N).
func (*PubKey) Sub ¶
Sub -- executes homomorphic subtraction, which corresponds to the addition with the modular inverse. That is, it computes a ciphertext ct3 that will decipher to the subtration of the corresponding plaintexts. So, if ct1 = Enc(m1) and ct2 = Enc(m2), and m1 > m2, then Dec(Sub(ct1, ct2)) = ct1 - ct2 mod N. Note that the ciphertext produced by this operation will only make sense if m1>m2.