Documentation ¶
Index ¶
- Variables
- func Add(pubKey *PublicKey, cipher, constant []byte) []byte
- func AddCipher(pubKey *PublicKey, cipher1, cipher2 []byte) []byte
- func Decrypt(privKey *PrivateKey, cipherText []byte) ([]byte, error)
- func Encrypt(pubKey *PublicKey, plainText []byte) ([]byte, error)
- func EncryptAndNonce(pubKey *PublicKey, plainText []byte) ([]byte, *big.Int, error)
- func EncryptWithNonce(pubKey *PublicKey, r *big.Int, plainText []byte) (*big.Int, error)
- func Mul(pubKey *PublicKey, cipher []byte, constant []byte) []byte
- type PrivateKey
- type PublicKey
Constants ¶
This section is empty.
Variables ¶
var ErrMessageTooLong = errors.New("paillier: message too long for Paillier public key size")
ErrMessageTooLong is returned when attempting to encrypt a message which is too large for the size of the public key.
Functions ¶
func Add ¶
Add homomorphically adds a passed constant to the encrypted integer (our cipher text). We do this by multiplying the constant with our ciphertext. Upon decryption, the resulting plain text will be the sum of the plaintext integer and the constant.
func AddCipher ¶
AddCipher homomorphically adds together two cipher texts. To do this we multiply the two cipher texts, upon decryption, the resulting plain text will be the sum of the corresponding plain texts.
func Decrypt ¶
func Decrypt(privKey *PrivateKey, cipherText []byte) ([]byte, error)
Decrypt decrypts the passed cipher text.
func Encrypt ¶
Encrypt encrypts a plain text represented as a byte array. The passed plain text MUST NOT be larger than the modulus of the passed public key.
func EncryptAndNonce ¶
EncryptAndNonce encrypts a plain text represented as a byte array, and in addition, returns the nonce used during encryption. The passed plain text MUST NOT be larger than the modulus of the passed public key.
func EncryptWithNonce ¶
EncryptWithNonce encrypts a plain text represented as a byte array using the provided nonce to perform encryption. The passed plain text MUST NOT be larger than the modulus of the passed public key.
Types ¶
type PrivateKey ¶
type PrivateKey struct { PublicKey // contains filtered or unexported fields }
PrivateKey represents a Paillier key.
func GenerateKey ¶
func GenerateKey(random io.Reader, bits int) (*PrivateKey, error)
GenerateKey generates an Paillier keypair of the given bit size using the random source random (for example, crypto/rand.Reader).