quadratic

package
v0.0.0-...-a536860 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package quadratic includes functional encryption schemes for quadratic multi-variate polynomials.

Index

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

func NewQuad(n, m int, b *big.Int) (*Quad, error)

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

func (q *Quad) Decrypt(c *QuadCipher, feKey data.VectorG2, F data.Matrix) (*big.Int, error)

Decrypt decrypts the ciphertext c with the derived functional encryption key key in order to obtain function x^T * F * y.

func (*Quad) DeriveKey

func (q *Quad) DeriveKey(secKey *QuadSecKey, F data.Matrix) (data.VectorG2, error)

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

type QuadCipher struct {
	Cx   data.VectorG1
	Cy   data.VectorG2
	CIPE data.VectorG1
}

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

type QuadPubKey struct {
	Ua     data.VectorG1
	VB     data.MatrixG2
	PubIPE *fullysec.PartFHIPEPubKey
}

QuadPubKey represents a public key for the scheme. An instance of this type is returned by the GenerateKeys method.

type QuadSecKey

type QuadSecKey struct {
	U      data.Matrix
	V      data.Matrix
	SecIPE *fullysec.PartFHIPESecKey
}

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

func NewSGP(n int, b *big.Int) *SGP

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

func (q *SGP) Decrypt(c *SGPCipher, key *bn256.G2, F data.Matrix) (*big.Int, error)

Decrypt decrypts the ciphertext c with the derived functional encryption key key in order to obtain function x^T * F * y.

func (*SGP) DeriveKey

func (q *SGP) DeriveKey(msk *SGPSecKey, F data.Matrix) (*bn256.G2, error)

DeriveKey derives the functional encryption key for the scheme. It returns an error if the key could not be derived.

func (*SGP) Encrypt

func (q *SGP) Encrypt(x, y data.Vector, msk *SGPSecKey) (*SGPCipher, error)

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

func (q *SGP) GenerateMasterKey() (*SGPSecKey, error)

GenerateMasterKey generates a master secret key for the SGP scheme. It returns an error if the secret key could not be generated.

type SGPCipher

type SGPCipher struct {
	G1MulGamma *bn256.G1
	AMulG1     []data.VectorG1
	BMulG2     []data.VectorG2
}

SGPCipher represents a ciphertext. An instance of this type is returned as a result of the Encrypt method.

func NewSGPCipher

func NewSGPCipher(g1MulGamma *bn256.G1, aMulG1 []data.VectorG1,
	bMulG2 []data.VectorG2) *SGPCipher

NewSGPCipher constructs an instance of SGPCipher.

type SGPSecKey

type SGPSecKey struct {
	S data.Vector
	T data.Vector
}

SGPSecKey represents a master secret key for the SGP scheme. An instance of this type is returned by the GenerateMasterKey method.

func NewSGPSecKey

func NewSGPSecKey(s, t data.Vector) *SGPSecKey

NewSGPSecKey constructs an instance of SGPSecKey.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL