fullysec

package
v0.0.0-...-8a2c02c Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Fully secure schemes for functional encryption of inner products.

All implementations in this package are based on the reference paper by Agrawal, Libert and Stehlé (see https://eprint.iacr.org/2015/608.pdf), and offer adaptive security under chosen-plaintext attacks (IND-CPA security).

The reference scheme is public key, which means that no master secret key is required for the encryption.

For instantiation from the decisional Diffie-Hellman assumption (DDH), see struct Damgard (and its multi-input variant DamgardMulti, which is a secret key scheme, because a part of the secret key is required for the encryption).

For instantiation from learning with errors (LWE), see struct LWE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DMCFEClient

type DMCFEClient struct {
	Idx int
	// contains filtered or unexported fields
}

DMCFEClient is to be instantiated by the encryptor. Idx presents index of the encryptor entity.

func NewDMCFEClient

func NewDMCFEClient(idx int, t data.Matrix) (*DMCFEClient, error)

NewDMCFEClient is to be called by the party that wants to encrypt number x_i. The decryptor will be able to compute inner product of x and y where x = (x_1,...,x_l) and y is publicly known vector y = (y_1,...,y_l). Value idx presents index of the party and matrix t is part of the client secret key. Matrix t needs to be generated interactively with other clients but nobody except the client should know its value (by secure multi-party computation).

func (*DMCFEClient) Encrypt

func (c *DMCFEClient) Encrypt(x *big.Int, label string) (*bn256.G1, error)

Encrypt encrypts number x under some label.

func (*DMCFEClient) GenerateKeyShare

func (c *DMCFEClient) GenerateKeyShare(y data.Vector) (data.VectorG2, error)

GenerateKeyShare generates client's key share. Decryptor needs shares from all clients.

type DMCFEDecryptor

type DMCFEDecryptor struct {
	// contains filtered or unexported fields
}

func NewDMCFEDecryptor

func NewDMCFEDecryptor(y data.Vector, label string, ciphers []*bn256.G1, keyShares []data.VectorG2,
	bound *big.Int) *DMCFEDecryptor

NewDMCFEDecryptor is to be called by a party that wants to decrypt a message - to compute inner product of x and y. It needs ciphertexts from all clients and key shares from all clients. The label is a string under which vector x has been encrypted (each client encrypted x_i under this label). The value bound specifies the bound of vector coordinates.

func (*DMCFEDecryptor) Decrypt

func (d *DMCFEDecryptor) Decrypt() (*big.Int, error)

type Damgard

type Damgard struct {
	Params *damgardParams
}

Damgard represents a scheme instantiated from the DDH assumption based on DDH variant of: Agrawal, Shweta, Libert, and Stehle: "Fully secure functional encryption for inner products, from standard assumptions".

func NewDamgard

func NewDamgard(l, modulusLength int, bound *big.Int) (*Damgard, error)

NewDamgard configures a new instance of the scheme. It accepts the length of input vectors l, the bit length of the modulus (we are operating in the Z_p group), and a bound by which coordinates of input vectors are bounded.

It returns an error in case the scheme could not be properly configured, or if precondition l * bound² is >= order of the cyclic group.

func NewDamgardFromParams

func NewDamgardFromParams(params *damgardParams) *Damgard

NewDamgardFromParams takes configuration parameters of an existing Damgard scheme instance, and reconstructs the scheme with same configuration parameters. It returns a new Damgard instance.

func (*Damgard) Decrypt

func (d *Damgard) Decrypt(cipher data.Vector, key *DamgardDerivedKey, y data.Vector) (*big.Int, error)

Decrypt accepts the encrypted vector, functional encryption key, and a plaintext vector y. It returns the inner product of x and y. If decryption failed, error is returned.

func (*Damgard) DeriveKey

func (d *Damgard) DeriveKey(masterSecKey *DamgardSecKey, y data.Vector) (*DamgardDerivedKey, error)

DeriveKey takes master secret key and input vector y, and returns the functional encryption key. In case the key could not be derived, it returns an error.

func (*Damgard) Encrypt

func (d *Damgard) Encrypt(x, masterPubKey data.Vector) (data.Vector, error)

Encrypt encrypts input vector x with the provided master public key. It returns a ciphertext vector. If encryption failed, error is returned.

func (*Damgard) GenerateMasterKeys

func (d *Damgard) GenerateMasterKeys() (*DamgardSecKey, data.Vector, error)

GenerateMasterKeys generates a master secret key and master public key for the scheme. It returns an error in case master keys could not be generated.

type DamgardDerivedKey

type DamgardDerivedKey struct {
	// contains filtered or unexported fields
}

DamgardDerivedKey is a functional encryption key for Damgard scheme.

type DamgardMulti

type DamgardMulti struct {
	*Damgard
	// contains filtered or unexported fields
}

DamgardMulti represents a multi input variant of the underlying Damgard scheme based on Abdalla, Catalano, Fiore, Gay, and Ursu: "Multi-Input Functional Encryption for Inner Products: Function-Hiding Realizations and Constructions without Pairings".

func NewDamgardMulti

func NewDamgardMulti(slots, l, modulusLength int, bound *big.Int) (*DamgardMulti, error)

NewDamgardMulti configures a new instance of the scheme. It accepts the number of slots (encryptors), the length of input vectors l, the bit length of the modulus (we are operating in the Z_p group), and a bound by which coordinates of input vectors are bounded.

It returns an error in case the underlying Damgard scheme instances could not be properly instantiated.

func NewDamgardMultiFromParams

func NewDamgardMultiFromParams(slots int, params *damgardParams) *DamgardMulti

NewDamgardMultiFromParams takes the number of slots and configuration parameters of an existing Damgard scheme instance, and reconstructs the scheme with same configuration parameters.

It returns a new DamgardMulti instance.

func (*DamgardMulti) Decrypt

func (dm *DamgardMulti) Decrypt(cipher data.Matrix, key *DamgardMultiDerivedKey, y data.Matrix) (*big.Int, error)

Decrypt accepts the matrix cipher comprised of encrypted vectors, functional encryption key, and a matrix y comprised of plaintext vectors. It returns the sum of inner products. If decryption failed, error is returned.

func (*DamgardMulti) DeriveKey

DeriveKey takes master secret key and a matrix y comprised of input vectors, and returns the functional encryption key. In case the key could not be derived, it returns an error.

func (*DamgardMulti) GenerateMasterKeys

func (dm *DamgardMulti) GenerateMasterKeys() (data.Matrix, *DamgardMultiSecKey, error)

GenerateMasterKeys generates a matrix comprised of master public keys and a struct encapsulating master public keys for the scheme.

It returns an error in case master keys could not be generated.

type DamgardMultiDerivedKey

type DamgardMultiDerivedKey struct {
	Z *big.Int // Σ <u_i, y_i> where u_i is OTP key for i-th encryptor
	// contains filtered or unexported fields
}

DamgardMultiDerivedKey is a functional encryption key for DamgardMulti scheme.

type DamgardMultiEnc

type DamgardMultiEnc struct {
	*Damgard
}

DamgardMultiEnc represents a single encryptor for the DamgardMulti scheme.

func NewDamgardMultiEnc

func NewDamgardMultiEnc(params *damgardParams) *DamgardMultiEnc

NewDamgardMultiEnc takes configuration parameters of an underlying Damgard scheme instance, and instantiates a new DamgardMultiEnc.

func (*DamgardMultiEnc) Encrypt

func (e *DamgardMultiEnc) Encrypt(x data.Vector, pubKey, otp data.Vector) (data.Vector, error)

Encrypt generates a ciphertext from the input vector x with the provided public key and one-time pad otp (which is a part of the secret key). It returns the ciphertext vector. If encryption failed, error is returned.

type DamgardMultiSecKey

type DamgardMultiSecKey struct {
	Otp data.Matrix
	// contains filtered or unexported fields
}

DamgardMultiSecKey is a secret key for Damgard multi input scheme.

type DamgardSecKey

type DamgardSecKey struct {
	// contains filtered or unexported fields
}

DamgardSecKey is a secret key for Damgard scheme.

type LWE

type LWE struct {
	// contains filtered or unexported fields
}

LWE represents a scheme instantiated from the LWE problem. Based on the LWE variant of: Agrawal, Shweta, Libert, and Stehle: "Fully secure functional encryption for inner products, from standard assumptions".

func NewLWE

func NewLWE(l, n int, boundX, boundY *big.Int) (*LWE, error)

NewLWE configures a new instance of the scheme. It accepts the length of input vectors l, the main security parameter n, the message space size boundX, and the inner product vector space size boundY.

It returns an error in case public parameters of the scheme could not be generated.

func (*LWE) Decrypt

func (s *LWE) Decrypt(cipher, zY, y data.Vector) (*big.Int, error)

Decrypt accepts an encrypted vector cipher, functional encryption key zX, and plaintext vector x, and calculates the inner product of x and y. If decryption failed (for instance with input data that violates the configured bound or malformed ciphertext or keys), error is returned.

func (*LWE) DeriveKey

func (s *LWE) DeriveKey(y data.Vector, Z data.Matrix) (data.Vector, error)

DeriveKey accepts input vector y and master secret key Z, and derives a functional encryption key. In case of malformed secret key or input vector that violates the configured bound, it returns an error.

func (*LWE) Encrypt

func (s *LWE) Encrypt(x data.Vector, U data.Matrix) (data.Vector, error)

Encrypt encrypts vector y using public key U. It returns the resulting ciphertext vector. In case of malformed public key or input vector that violates the configured bound, it returns an error.

func (*LWE) GeneratePublicKey

func (s *LWE) GeneratePublicKey(Z data.Matrix) (data.Matrix, error)

GeneratePublicKey accepts a master secret key Z and generates a corresponding master public key. Public key is a matrix of l*m elements. In case of a malformed secret key the function returns an error.

func (*LWE) GenerateSecretKey

func (s *LWE) GenerateSecretKey() (data.Matrix, error)

GenerateSecretKey generates a secret key for the scheme. The secret key is a matrix with dimensions l*m.

In case secret key could not be generated, it returns an error.

type Paillier

type Paillier struct {
	Params *paillerParams
}

Paillier represents a scheme based on the Paillier variant by Agrawal, Shweta, Libert, and Stehle": "Fully secure functional encryption for inner products, from standard assumptions".

func NewPaillier

func NewPaillier(l, lambda, bitLen int, boundX, boundY *big.Int) (*Paillier, error)

NewPaillier configures a new instance of the scheme. It accepts the length of input vectors l, security parameter lambda, the bit length of prime numbers (giving security to the scheme, it should be such that factoring two primes with such a bit length takes at least 2^lambda operations), and boundX and boundY by which coordinates of input vectors and inner product vectors are bounded.

It returns an error in the case the scheme could not be properly configured, or if the precondition boundX, boundY < (n / l)^(1/2) is not satisfied.

func NewPaillierFromParams

func NewPaillierFromParams(params *paillerParams) *Paillier

NewPaillierFromParams takes configuration parameters of an existing Paillier scheme instance, and reconstructs the scheme with same configuration parameters. It returns a new Paillier instance.

func (*Paillier) Decrypt

func (s *Paillier) Decrypt(cipher data.Vector, key *big.Int, y data.Vector) (*big.Int, error)

Decrypt accepts the encrypted vector, functional encryption key, and a vector y. It returns the inner product of x and y.

func (*Paillier) DeriveKey

func (s *Paillier) DeriveKey(masterSecKey data.Vector, y data.Vector) (*big.Int, error)

DeriveKey accepts master secret key masterSecKey and input vector y, and derives a functional encryption key for the inner product with y. In case of malformed secret key or input vector that violates the configured bound, it returns an error.

func (*Paillier) Encrypt

func (s *Paillier) Encrypt(x, masterPubKey data.Vector) (data.Vector, error)

Encrypt encrypts input vector x with the provided master public key. It returns a ciphertext vector. If encryption failed, error is returned.

func (*Paillier) GenerateMasterKeys

func (s *Paillier) GenerateMasterKeys() (data.Vector, data.Vector, error)

GenerateMasterKeys generates a master secret key and a master public key for the scheme. It returns an error in case master keys could not be generated.

Jump to

Keyboard shortcuts

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