Documentation
¶
Index ¶
- func AHEKeyGen(secbits int, fixedPointScale int64) (*AHESecretKey, *AHEPublicKey)
- func KeyGen(secbits int, fixedPointPrecision FixedPointPrecision, scheme Scheme) (*SecretKey, *PublicKey)
- func SHEKeyGen(secbits int, messageSpace *big.Int, fixedPointScale int64) (*SHESecretKey, *SHEPublicKey)
- type AHECiphertext
- type AHEPublicKey
- func (pk *AHEPublicKey) Add(a *AHECiphertext, b *AHECiphertext) *AHECiphertext
- func (pk *AHEPublicKey) CiphertextSpace() *big.Int
- func (pk *AHEPublicKey) ConstMul(a *AHECiphertext, constant *big.Int) *AHECiphertext
- func (pk *AHEPublicKey) DecodeFixedPoint(a *big.Int, scale *big.Int) *big.Float
- func (pk *AHEPublicKey) EncodeFixedPoint(a *big.Float) *big.Int
- func (pk *AHEPublicKey) Encrypt(a *big.Int) *AHECiphertext
- func (pk *AHEPublicKey) EncryptDeterministic(a *big.Int) *AHECiphertext
- func (pk *AHEPublicKey) EncryptFloat(a *big.Float) *AHECiphertext
- func (pk *AHEPublicKey) EncryptFloatDeterministic(a *big.Float) *AHECiphertext
- func (pk *AHEPublicKey) EncryptOne() *AHECiphertext
- func (pk *AHEPublicKey) EncryptZero() *AHECiphertext
- func (pk *AHEPublicKey) FloatConstMul(a *AHECiphertext, constant *big.Float) *AHECiphertext
- func (pk *AHEPublicKey) MessageSpace() *big.Int
- func (pk *AHEPublicKey) Modulus() *big.Int
- func (pk *AHEPublicKey) NewCiphertextFromBytes(data []byte) (*AHECiphertext, error)
- func (pk *AHEPublicKey) NullCiphertext() *AHECiphertext
- func (pk *AHEPublicKey) Sub(a *AHECiphertext, b *AHECiphertext) *AHECiphertext
- type AHESecretKey
- type Ciphertext
- type FixedPointPrecision
- type PublicKey
- func (pk *PublicKey) Add(a *Ciphertext, b *Ciphertext) *Ciphertext
- func (pk *PublicKey) CiphertextSpace() *big.Int
- func (pk *PublicKey) ConstMul(a *Ciphertext, constant *big.Int) *Ciphertext
- func (pk *PublicKey) DecodeFixedPoint(a *big.Int, scale *big.Int) *big.Float
- func (pk *PublicKey) EncodeFixedPoint(a *big.Float) *big.Int
- func (pk *PublicKey) Encrypt(a *big.Int) *Ciphertext
- func (pk *PublicKey) EncryptDeterministic(a *big.Int) *Ciphertext
- func (pk *PublicKey) EncryptFloat(a *big.Float) *Ciphertext
- func (pk *PublicKey) EncryptFloatDeterministic(a *big.Float) *Ciphertext
- func (pk *PublicKey) EncryptOne() *Ciphertext
- func (pk *PublicKey) EncryptZero() *Ciphertext
- func (pk *PublicKey) FloatConstMul(a *Ciphertext, constant *big.Float) *Ciphertext
- func (pk *PublicKey) MessageSpace() *big.Int
- func (pk *PublicKey) Modulus() *big.Int
- func (pk *PublicKey) Mul(a *Ciphertext, b *Ciphertext) *Ciphertext
- func (pk *PublicKey) NewCiphertextFromBytes(data []byte) (*Ciphertext, error)
- func (pk *PublicKey) NullCiphertext() *Ciphertext
- func (pk *PublicKey) Sub(a *Ciphertext, b *Ciphertext) *Ciphertext
- type SHECiphertext
- type SHEPublicKey
- func (pk *SHEPublicKey) Add(a *SHECiphertext, b *SHECiphertext) *SHECiphertext
- func (pk *SHEPublicKey) CiphertextSpace() *big.Int
- func (pk *SHEPublicKey) ConstMul(a *SHECiphertext, constant *big.Int) *SHECiphertext
- func (pk *SHEPublicKey) Encrypt(a *big.Int) *SHECiphertext
- func (pk *SHEPublicKey) EncryptDeterministic(a *big.Int) *SHECiphertext
- func (pk *SHEPublicKey) EncryptFloat(a *big.Float) *SHECiphertext
- func (pk *SHEPublicKey) EncryptFloatDeterministic(a *big.Float) *SHECiphertext
- func (pk *SHEPublicKey) EncryptOne() *SHECiphertext
- func (pk *SHEPublicKey) EncryptZero() *SHECiphertext
- func (pk *SHEPublicKey) FloatConstMul(a *SHECiphertext, constant *big.Float) *SHECiphertext
- func (pk *SHEPublicKey) MessageSpace() *big.Int
- func (pk *SHEPublicKey) Modulus() *big.Int
- func (pk *SHEPublicKey) Mul(a *SHECiphertext, b *SHECiphertext) *SHECiphertext
- func (pk *SHEPublicKey) NewCiphertextFromBytes(data []byte) (*SHECiphertext, error)
- func (pk *SHEPublicKey) NullCiphertext() *SHECiphertext
- func (pk *SHEPublicKey) Sub(a *SHECiphertext, b *SHECiphertext) *SHECiphertext
- type SHESecretKey
- type Scheme
- type SecretKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AHEKeyGen ¶
func AHEKeyGen(secbits int, fixedPointScale int64) (*AHESecretKey, *AHEPublicKey)
AHEKeyGen generates a (secret, public) key pair secbits is the RSA security parameter
func KeyGen ¶
func KeyGen(secbits int, fixedPointPrecision FixedPointPrecision, scheme Scheme) (*SecretKey, *PublicKey)
KeyGen generates a public and secret key for a homomorphic encryption scheme (either Paillier or SHE)
func SHEKeyGen ¶
func SHEKeyGen(secbits int, messageSpace *big.Int, fixedPointScale int64) (*SHESecretKey, *SHEPublicKey)
SHEKeyGen generates a (secret, public) key pair secbits is the RSA security parameter
Types ¶
type AHECiphertext ¶
type AHECiphertext struct {
Ciphertext *paillier.Ciphertext
FixedPointScale *big.Int // fixed point scaling factor associated with the ciphertext (grows with # multiplications)
}
AHECiphertext consists of an ciphertext C in an additively homomorphic encryption (AHE) sheme, encrypting a value that is scaled by FixedPointScale
func (*AHECiphertext) Bytes ¶
func (ct *AHECiphertext) Bytes() []byte
Bytes returns the byte encoding of the ciphertext struct
type AHEPublicKey ¶
AHEPublicKey of the AHE scheme Modulus is the message space modulus FixedPointScale is the scaling factor for fixed-point representation in the message space
func (*AHEPublicKey) Add ¶
func (pk *AHEPublicKey) Add(a *AHECiphertext, b *AHECiphertext) *AHECiphertext
Add uses the homomorphic properties of the encryption sheme to add two encrypted values together and returns the ciphertext encrypting the sum
func (*AHEPublicKey) CiphertextSpace ¶
func (pk *AHEPublicKey) CiphertextSpace() *big.Int
CiphertextSpace reutns the size of the ciphertexts
func (*AHEPublicKey) ConstMul ¶
func (pk *AHEPublicKey) ConstMul(a *AHECiphertext, constant *big.Int) *AHECiphertext
ConstMul multiplies an encrypted value by a plaintext constant (int) note that the constant is first converted to an element of the message space
func (*AHEPublicKey) DecodeFixedPoint ¶
DecodeFixedPoint converts a fixed-pont encoded value into a floa64
func (*AHEPublicKey) EncodeFixedPoint ¶
func (pk *AHEPublicKey) EncodeFixedPoint(a *big.Float) *big.Int
EncodeFixedPoint converts a floating-point value a to a fixed-point encoded integer value where the scaling factor is represented in the public key
func (*AHEPublicKey) Encrypt ¶
func (pk *AHEPublicKey) Encrypt(a *big.Int) *AHECiphertext
Encrypt encrypts the int value with fixedpoint scaling factor of 1
func (*AHEPublicKey) EncryptDeterministic ¶
func (pk *AHEPublicKey) EncryptDeterministic(a *big.Int) *AHECiphertext
EncryptDeterministic encrypts the int value without randomizing
func (*AHEPublicKey) EncryptFloat ¶
func (pk *AHEPublicKey) EncryptFloat(a *big.Float) *AHECiphertext
EncryptFloat first converts the input into the encryption scheme's message space (using fixed-point encoding) and then returns a fresh encryption of the encoded value
func (*AHEPublicKey) EncryptFloatDeterministic ¶
func (pk *AHEPublicKey) EncryptFloatDeterministic(a *big.Float) *AHECiphertext
EncryptFloatDeterministic encrypts a float without randomness
func (*AHEPublicKey) EncryptOne ¶
func (pk *AHEPublicKey) EncryptOne() *AHECiphertext
EncryptOne returns a ciphertext encrypting one
func (*AHEPublicKey) EncryptZero ¶
func (pk *AHEPublicKey) EncryptZero() *AHECiphertext
EncryptZero returns a ciphertext encrypting zero
func (*AHEPublicKey) FloatConstMul ¶
func (pk *AHEPublicKey) FloatConstMul(a *AHECiphertext, constant *big.Float) *AHECiphertext
FloatConstMul multiplies an encrypted value by a plaintext constant (float) note that the constant is first converted to an element of the message space
func (*AHEPublicKey) MessageSpace ¶
func (pk *AHEPublicKey) MessageSpace() *big.Int
MessageSpace returns the largest value that can be encrypted
func (*AHEPublicKey) Modulus ¶
func (pk *AHEPublicKey) Modulus() *big.Int
Modulus returns the modulus of the message space
func (*AHEPublicKey) NewCiphertextFromBytes ¶
func (pk *AHEPublicKey) NewCiphertextFromBytes(data []byte) (*AHECiphertext, error)
NewCiphertextFromBytes initializes a ciphertext from a byte encoding. Requires the public key to ensure field elements are correct (see PBC library)
func (*AHEPublicKey) NullCiphertext ¶
func (pk *AHEPublicKey) NullCiphertext() *AHECiphertext
NullCiphertext returns an encryption of zero without randomness
func (*AHEPublicKey) Sub ¶
func (pk *AHEPublicKey) Sub(a *AHECiphertext, b *AHECiphertext) *AHECiphertext
Sub uses the homomorphic properties of the encryption sheme to evaluate and return and encryption of the the difference a - b
type AHESecretKey ¶
AHESecretKey of the AHE scheme
func (*AHESecretKey) Decrypt ¶
func (sk *AHESecretKey) Decrypt(pk *AHEPublicKey, ct *AHECiphertext) *big.Int
Decrypt uses the secret key to decrypt a ciphertext
func (*AHESecretKey) DecryptFloat ¶
func (sk *AHESecretKey) DecryptFloat(pk *AHEPublicKey, ct *AHECiphertext) *big.Float
DecryptFloat uses the secret key to decrypt a ciphertext and recover the fixed-point encoded value which is returned as a float64 type
type Ciphertext ¶
type Ciphertext struct {
Paillier *AHECiphertext
Bgn *SHECiphertext
IsShe bool
}
Ciphertext for either Paillier or SHE scheme
func (*Ciphertext) Bytes ¶
func (ct *Ciphertext) Bytes() ([]byte, error)
Bytes returns the byte encoding of the ciphertext struct
func (*Ciphertext) String ¶
func (ct *Ciphertext) String() string
type FixedPointPrecision ¶
type FixedPointPrecision int64
FixedPointPrecision specifies fixed-point encoding scale used to encode floating point values over the integers
const ( // LowPrecision = 1 << 10 scaling factor LowPrecision FixedPointPrecision = 1 << 10 // MediumPrecision = 1 << 20 scaling factor MediumPrecision FixedPointPrecision = 1 << 20 // HighPrecision = 1 << 30 scaling factor HighPrecision FixedPointPrecision = 1 << 30 // VeryHighPrecision = 1 << 40 scaling factor VeryHighPrecision FixedPointPrecision = 1 << 40 )
type PublicKey ¶
type PublicKey struct {
Paillier *AHEPublicKey
Bgn *SHEPublicKey
IsShe bool
}
PublicKey for either Paillier or SHE scheme
func (*PublicKey) Add ¶
func (pk *PublicKey) Add(a *Ciphertext, b *Ciphertext) *Ciphertext
Add uses the homomorphic properties of the encryption sheme to add two encrypted values together and returns the ciphertext encrypting the sum
func (*PublicKey) CiphertextSpace ¶
CiphertextSpace returns the size of a ciphertext
func (*PublicKey) ConstMul ¶
func (pk *PublicKey) ConstMul(a *Ciphertext, constant *big.Int) *Ciphertext
ConstMul multiplies an encrypted value by a plaintext constant (int) note that the constant is first converted to an element of the message space
func (*PublicKey) DecodeFixedPoint ¶
DecodeFixedPoint converts a fixed-pont encoded value into a floa64
func (*PublicKey) EncodeFixedPoint ¶
EncodeFixedPoint converts a floating-point value a to a fixed-point encoded integer value where the scaling factor is represented in the public key
func (*PublicKey) Encrypt ¶
func (pk *PublicKey) Encrypt(a *big.Int) *Ciphertext
Encrypt encrypts the int value with fixedpoint scaling factor of 1
func (*PublicKey) EncryptDeterministic ¶
func (pk *PublicKey) EncryptDeterministic(a *big.Int) *Ciphertext
EncryptDeterministic encrypts the int value without randomness
func (*PublicKey) EncryptFloat ¶
func (pk *PublicKey) EncryptFloat(a *big.Float) *Ciphertext
EncryptFloat first converts the input into the encryption scheme's message space (using fixed-point encoding) and then returns a fresh encryption of the encoded value
func (*PublicKey) EncryptFloatDeterministic ¶
func (pk *PublicKey) EncryptFloatDeterministic(a *big.Float) *Ciphertext
EncryptFloatDeterministic encrypts a flaot without randomness
func (*PublicKey) EncryptOne ¶
func (pk *PublicKey) EncryptOne() *Ciphertext
EncryptOne returns a ciphertext encrypting one
func (*PublicKey) EncryptZero ¶
func (pk *PublicKey) EncryptZero() *Ciphertext
EncryptZero returns a ciphertext encrypting zero
func (*PublicKey) FloatConstMul ¶
func (pk *PublicKey) FloatConstMul(a *Ciphertext, constant *big.Float) *Ciphertext
FloatConstMul multiplies an encrypted value by a plaintext constant (float) note that the constant is first converted to an element of the message space
func (*PublicKey) MessageSpace ¶
MessageSpace returns the largest value that can be encrypted
func (*PublicKey) Modulus ¶
Modulus returns the modulus of the message space (may be larger than message space; e.g. BGN)
func (*PublicKey) Mul ¶
func (pk *PublicKey) Mul(a *Ciphertext, b *Ciphertext) *Ciphertext
Mul multiplies an encrypted value by a another encrypted value b
func (*PublicKey) NewCiphertextFromBytes ¶
func (pk *PublicKey) NewCiphertextFromBytes(data []byte) (*Ciphertext, error)
NewCiphertextFromBytes initializes a ciphertext from a byte encoding. Requires the public key to ensure field elements are correct (see PBC library)
func (*PublicKey) NullCiphertext ¶
func (pk *PublicKey) NullCiphertext() *Ciphertext
NullCiphertext returns a ciphertext encrypting zero without randomness
func (*PublicKey) Sub ¶
func (pk *PublicKey) Sub(a *Ciphertext, b *Ciphertext) *Ciphertext
Sub uses the homomorphic properties of the encryption sheme to evaluate and return and encryption of the the difference a - b
type SHECiphertext ¶
type SHECiphertext struct {
Ciphertext *bgn.Ciphertext
Poly *bgn.PolyCiphertext
IsPoly bool // if the ciphertext is a polynomial
}
SHECiphertext consists of an ciphertext C in a somewhat homomorphic encryption (SHE) sheme, encrypting a value that is scaled by FixedPointScale
func (*SHECiphertext) Bytes ¶
func (ct *SHECiphertext) Bytes() []byte
Bytes returns the byte encoding of the ciphertext struct
type SHEPublicKey ¶
SHEPublicKey of the SHE scheme
func (*SHEPublicKey) Add ¶
func (pk *SHEPublicKey) Add(a *SHECiphertext, b *SHECiphertext) *SHECiphertext
Add uses the homomorphic properties of the encryption sheme to add two encrypted values together and returns the ciphertext encrypting the sum
func (*SHEPublicKey) CiphertextSpace ¶
func (pk *SHEPublicKey) CiphertextSpace() *big.Int
CiphertextSpace reutns the size of the ciphertexts
func (*SHEPublicKey) ConstMul ¶
func (pk *SHEPublicKey) ConstMul(a *SHECiphertext, constant *big.Int) *SHECiphertext
ConstMul multiplies an encrypted value by a plaintext constant (int) note that the constant is first converted to an element of the message space
func (*SHEPublicKey) Encrypt ¶
func (pk *SHEPublicKey) Encrypt(a *big.Int) *SHECiphertext
Encrypt first converts the input into the encryption scheme's message space (using fixed-point encoding) and then returns a fresh encryption of the encoded value
func (*SHEPublicKey) EncryptDeterministic ¶
func (pk *SHEPublicKey) EncryptDeterministic(a *big.Int) *SHECiphertext
EncryptDeterministic encrypts the int value without randomizing
func (*SHEPublicKey) EncryptFloat ¶
func (pk *SHEPublicKey) EncryptFloat(a *big.Float) *SHECiphertext
EncryptFloat encryptes a floating point using a fixed-point representation
func (*SHEPublicKey) EncryptFloatDeterministic ¶
func (pk *SHEPublicKey) EncryptFloatDeterministic(a *big.Float) *SHECiphertext
EncryptFloatDeterministic encrypts a float without randomness
func (*SHEPublicKey) EncryptOne ¶
func (pk *SHEPublicKey) EncryptOne() *SHECiphertext
EncryptOne returns a ciphertext encrypting one
func (*SHEPublicKey) EncryptZero ¶
func (pk *SHEPublicKey) EncryptZero() *SHECiphertext
EncryptZero returns a ciphertext encrypting zero
func (*SHEPublicKey) FloatConstMul ¶
func (pk *SHEPublicKey) FloatConstMul(a *SHECiphertext, constant *big.Float) *SHECiphertext
FloatConstMul multiplies an encrypted value by a plaintext constant (float) note that the constant is first converted to an element of the message space
func (*SHEPublicKey) MessageSpace ¶
func (pk *SHEPublicKey) MessageSpace() *big.Int
MessageSpace returns the largest value that can be encrypted
func (*SHEPublicKey) Modulus ¶
func (pk *SHEPublicKey) Modulus() *big.Int
Modulus returns the modulus of the message space (may be larger than message space; e.g. BGN)
func (*SHEPublicKey) Mul ¶
func (pk *SHEPublicKey) Mul(a *SHECiphertext, b *SHECiphertext) *SHECiphertext
Mul multiplies two encryped values homomorphically and returns the ciphertext encrypting the product
func (*SHEPublicKey) NewCiphertextFromBytes ¶
func (pk *SHEPublicKey) NewCiphertextFromBytes(data []byte) (*SHECiphertext, error)
NewCiphertextFromBytes initializes a ciphertext from a byte encoding. Requires the public key to ensure field elements are correct (see PBC library)
func (*SHEPublicKey) NullCiphertext ¶
func (pk *SHEPublicKey) NullCiphertext() *SHECiphertext
NullCiphertext returns an encryption of zero without randomness
func (*SHEPublicKey) Sub ¶
func (pk *SHEPublicKey) Sub(a *SHECiphertext, b *SHECiphertext) *SHECiphertext
Sub uses the homomorphic properties of the encryption sheme to evaluate and return and encryption of the the difference a - b
type SHESecretKey ¶
SHESecretKey of the AHE scheme
func (*SHESecretKey) Decrypt ¶
func (sk *SHESecretKey) Decrypt(pk *SHEPublicKey, ct *SHECiphertext) *big.Int
Decrypt uses the secret key to decrypt a ciphertext
func (*SHESecretKey) DecryptFloat ¶
func (sk *SHESecretKey) DecryptFloat(pk *SHEPublicKey, ct *SHECiphertext) *big.Float
DecryptFloat uses the secret key to decrypt a ciphertext and recover the fixed-point encoded value which is returned as a float64 type
type SecretKey ¶
type SecretKey struct {
Paillier *AHESecretKey
Bgn *SHESecretKey
IsShe bool
}
SecretKey for either Paillier or SHE scheme
func (*SecretKey) Decrypt ¶
func (sk *SecretKey) Decrypt(pk *PublicKey, ct *Ciphertext) *big.Int
Decrypt uses the secret key to decrypt a ciphertext
func (*SecretKey) DecryptFloat ¶
func (sk *SecretKey) DecryptFloat(pk *PublicKey, ct *Ciphertext) *big.Float
DecryptFloat uses the secret key to decrypt a ciphertext and recover the fixed-point encoded value which is returned as a float64 type