Documentation
¶
Overview ¶
Package quadratic includes functional encryption schemes for quadratic multi-variate polynomials.
Index ¶
- type Quad
- func (q *Quad) Decrypt(c *QuadCipher, feKey data.VectorG2, F data.Matrix) (*big.Int, error)
- func (q *Quad) DeriveKey(secKey *QuadSecKey, F data.Matrix) (data.VectorG2, error)
- func (q *Quad) Encrypt(x, y data.Vector, pubKey *QuadPubKey) (*QuadCipher, error)
- func (q *Quad) GenerateKeys() (*QuadPubKey, *QuadSecKey, error)
- type QuadCipher
- type QuadParams
- type QuadPubKey
- type QuadSecKey
- type SGP
- type SGPCipher
- type SGPSecKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Quad ¶
type Quad struct {
Params *QuadParams
}
Quad represents a public key FE scheme for quadratic multi-variate polynomials. More precisely, it allows to encrypt vectors x and y using public key, derive a functional encryption key corresponding to a matrix F, and decrypt value x^T * F * y from encryption of x, y and functional key, without reveling any other information about x or y. The scheme is based on a paper by Romain Gay: "A New Paradigm for Public-Key Functional Encryption for Degree-2 Polynomials". The scheme uses an underling partially function hiding inner product FE scheme.
func NewQuad ¶
NewQuad configures a new instance of the quadratic public key scheme. It accepts the length of input vectors n and m and the upper bound b for coordinates of input vectors x, y, and the function matrix F. Parameter n should be greater or equal to m.
func NewQuadFromParams ¶
func NewQuadFromParams(params *QuadParams) *Quad
NewQuadFromParams takes configuration parameters of an existing Quad instance, and reconstructs the scheme with the same configuration parameters. It returns a new Quad instance.
func (*Quad) Decrypt ¶
Decrypt decrypts the ciphertext c with the derived functional encryption key key in order to obtain function x^T * F * y.
func (*Quad) DeriveKey ¶
DeriveKey derives the functional encryption key for the scheme. It returns an error if the key could not be derived.
func (*Quad) Encrypt ¶
func (q *Quad) Encrypt(x, y data.Vector, pubKey *QuadPubKey) (*QuadCipher, error)
Encrypt encrypts input vectors x and y with the given public key. It returns the appropriate ciphertext. If the ciphertext could not be generated, it returns an error.
func (*Quad) GenerateKeys ¶
func (q *Quad) GenerateKeys() (*QuadPubKey, *QuadSecKey, error)
GenerateKeys generates a public key and master secret key for the scheme. It returns an error if the keys could not be generated.
type QuadCipher ¶
QuadCipher represents ciphertext in the scheme.
type QuadParams ¶
type QuadParams struct { PartFHIPE *fullysec.PartFHIPE // N should be greater or equal to M N int // length of vectors x M int // length of vectors y // The value by which elements of vectors x, y, and the // matrix F are bounded. Bound *big.Int }
QuadParams includes public parameters for the partially function hiding inner product scheme. PartFHIPE: underlying partially function hiding scheme. N (int): The length of x vectors to be encrypted. M (int): The length of y vectors to be encrypted. Bound (*big.Int): The value by which coordinates of vectors x, y and F are bounded.
type QuadPubKey ¶
QuadPubKey represents a public key for the scheme. An instance of this type is returned by the GenerateKeys method.
type QuadSecKey ¶
QuadSecKey represents a master secret key for the scheme. An instance of this type is returned by the GenerateKeys method.
type SGP ¶
type SGP struct { // length of vectors x and y (matrix F is N x N) N int // Modulus for ciphertext and keys Mod *big.Int // The value by which elements of vectors x, y, and the // matrix F are bounded. Bound *big.Int GCalc *dlog.CalcBN256 GInvCalc *dlog.CalcBN256 }
SGP implements efficient FE scheme for quadratic multi-variate polynomials based on Dufour Sans, Gay and Pointcheval: "Reading in the Dark: Classifying Encrypted Digits with Functional Encryption". See paper: https://eprint.iacr.org/2018/206.pdf which is based on bilinear pairings. It offers adaptive security under chosen-plaintext attacks (IND-CPA security). This is a secret key scheme, meaning that we need a master secret key to encrypt the messages. Assuming input vectors x and y, the SGP scheme allows the decryptor to calculate x^T * F * y, where F is matrix that represents the function, and vectors x, y are only known to the encryptor, but not to decryptor.
func NewSGP ¶
NewSGP configures a new instance of the SGP scheme. It accepts the length of input vectors n and the upper bound b for coordinates of input vectors x, y, and the function matrix F.
func (*SGP) Decrypt ¶
Decrypt decrypts the ciphertext c with the derived functional encryption key key in order to obtain function x^T * F * y.
func (*SGP) DeriveKey ¶
DeriveKey derives the functional encryption key for the scheme. It returns an error if the key could not be derived.
func (*SGP) Encrypt ¶
Encrypt encrypts input vectors x and y with the master secret key msk. It returns the appropriate ciphertext. If ciphertext could not be generated, it returns an error.
func (*SGP) GenerateMasterKey ¶
GenerateMasterKey generates a master secret key for the SGP scheme. It returns an error if the secret key could not be generated.
type SGPCipher ¶
SGPCipher represents a ciphertext. An instance of this type is returned as a result of the Encrypt method.
type SGPSecKey ¶
SGPSecKey represents a master secret key for the SGP scheme. An instance of this type is returned by the GenerateMasterKey method.
func NewSGPSecKey ¶
NewSGPSecKey constructs an instance of SGPSecKey.