l2fhe

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package l2fhe represents a homomorphic encryption scheme based on Catalano-Fiore and Paillier Cryptosystem. this scheme supports multiplication of two level-1 (not previously multiplicated while encrypted) encrypted values, and also the properties of classic Paillier.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Betas

type Betas struct {
	Beta1, Beta2 *big.Int
}

Betas groups two Beta values together.

type BetasZK added in v0.0.5

type BetasZK struct {
	Beta1, Beta2 *tcpaillier.DecryptShareZK
}

type DecryptedShareBetas

type DecryptedShareBetas struct {
	Beta1, Beta2 *tcpaillier.DecryptionShare
}

DecryptedShareBetas groups two Beta decryption shares together.

type DecryptedShareL1

type DecryptedShareL1 struct {
	Alpha *big.Int
	Beta  *tcpaillier.DecryptionShare
}

DecryptedShareL1 represents a Level-1 Decrypted share.

type DecryptedShareL1ZK

type DecryptedShareL1ZK struct {
	Beta *tcpaillier.DecryptShareZK
}

DecryptedShareL1ZK represents a Zero Knowledge Proof over an Partially Decrypted Level-1 FHE value.

func (*DecryptedShareL1ZK) Verify

func (zk *DecryptedShareL1ZK) Verify(pk *tcpaillier.PubKey, vals ...interface{}) error

Verify verifies a ZKProof of DecryptedShareL1ZK type. It receives the public key and 2 arguments, representing the value encrypted and the decryption share.

type DecryptedShareL2

type DecryptedShareL2 struct {
	Alpha *tcpaillier.DecryptionShare
	Betas []*DecryptedShareBetas
}

DecryptedShareL2 represents a Level-2 Decrypted share.

type DecryptedShareL2ZK

type DecryptedShareL2ZK struct {
	Alpha *tcpaillier.DecryptShareZK
	Betas []*BetasZK
}

DecryptedShareL2ZK represents a Zero Knowledge Proof over an Partially Decrypted Level-2 FHE value.

func (*DecryptedShareL2ZK) Verify

func (zk *DecryptedShareL2ZK) Verify(pk *tcpaillier.PubKey, vals ...interface{}) error

Verify verifies a ZKProof of DecryptedShareL2ZK type. It receives the public key and 2 arguments, representing the value encrypted and the decryption share.

type EncryptedL1

type EncryptedL1 struct {
	Alpha *big.Int
	Beta  *big.Int
}

EncryptedL1 represents a Level-1 Encrypted value.

func (*EncryptedL1) Clone

func (L1 *EncryptedL1) Clone() *EncryptedL1

Clone clones an EncryptedL1 value.

func (*EncryptedL1) ToL2

func (L1 *EncryptedL1) ToL2(pk *PubKey) (l2 *EncryptedL2, err error)

ToL2 returns a deterministic representation of a L1 value to L2

func (*EncryptedL1) ToPaillier

func (L1 *EncryptedL1) ToPaillier(pk *tcpaillier.PubKey) (c *big.Int, err error)

ToPaillier transforms a Level-1 Encrypted value to a PubKey encrypted value, compatible with tcpaillier library.

type EncryptedL1ZK

type EncryptedL1ZK struct {
	Beta *tcpaillier.EncryptZK
}

EncryptedL1ZK represents a Zero Knowledge Proof over an Encrypted Level-1 FHE value.

func (*EncryptedL1ZK) Verify

func (zk *EncryptedL1ZK) Verify(pk *tcpaillier.PubKey, vals ...interface{}) error

Verify verifies a ZKProof of EncryptedL1ZK type. It receives the public key and 1 argument, representing the value encrypted.

type EncryptedL2

type EncryptedL2 struct {
	Alpha *big.Int
	Betas []*Betas
}

EncryptedL2 represents a Level-2 Encrypted value.

func (*EncryptedL2) Clone

func (L2 *EncryptedL2) Clone() *EncryptedL2

Clone clones an EncryptedL2 value.

type EncryptedL2ZK

type EncryptedL2ZK struct {
	Alpha *tcpaillier.EncryptZK
	Betas []*tcpaillier.EncryptZK
}

EncryptedL2ZK represents a Zero Knowledge Proof over an Encrypted Level-2 FHE value.

func (*EncryptedL2ZK) Verify

func (zk *EncryptedL2ZK) Verify(pk *tcpaillier.PubKey, vals ...interface{}) error

Verify verifies a ZKProof of EncryptedL2ZK type. It receives the public key and 1 argument, representing the value encrypted.

type PubKey

type PubKey struct {
	Paillier         *tcpaillier.PubKey
	MaxMessageModule *big.Int
}

PubKey in l2fhe module represents the use of Pallier Threshold Cryptosystem with Catalano-Fiore's Level-1 Homomorphic Encryption. This implementation is based on TCECDSA paper, using some missing definitions from the original paper. This implementation does not consider ZK Proofs for encryption and multiplication values, Because the ECDSA paper uses other ZKProofs.

func NewFixedKey

func NewFixedKey(msgBitSize int, l, k uint8, params *tcpaillier.FixedParams) (pubKey *PubKey, keyShares []*tcpaillier.KeyShare, err error)

NewFixedKey returns a new L2FHE Key, based on PubKey Threshold Cryptosystem, using a fixed set of params for tcpaillier.

func NewKey

func NewKey(msgBitSize int, l, k uint8) (pubKey *PubKey, keyShares []*tcpaillier.KeyShare, err error)

NewKey returns a new L2FHE Key, based on PubKey Threshold Cryptosystem.

func (*PubKey) AddL1

func (l *PubKey) AddL1(cList ...*EncryptedL1) (sum *EncryptedL1, err error)

AddL1 adds a list of Encrypted Level-1 values and returns its encrypted sum.

func (*PubKey) AddL2

func (l *PubKey) AddL2(cList ...*EncryptedL2) (sum *EncryptedL2, err error)

AddL2 adds a list of Encrypted Level-2 values and returns its encrypted sum.

func (*PubKey) CombineSharesL1

func (l *PubKey) CombineSharesL1(shares ...*DecryptedShareL1) (decrypted *big.Int, err error)

CombineSharesL1 joins a list of decryption shares, returning the decrypted value.

func (*PubKey) CombineSharesL2

func (l *PubKey) CombineSharesL2(shares ...*DecryptedShareL2) (decrypted *big.Int, err error)

CombineSharesL2 joins a list of decryption shares, returning the decrypted value.

func (*PubKey) Encrypt

func (l *PubKey) Encrypt(m *big.Int) (e *EncryptedL1, r *big.Int, err error)

Encrypt encrypts a value using TCPaillier and Catalano-Fiore, generating a Level-1 value. It returns also the random value used to encrypt.

func (*PubKey) EncryptFixed

func (l *PubKey) EncryptFixed(m, r *big.Int) (e *EncryptedL1, err error)

EncryptFixed encrypts a value using TCPaillier and Catalano-Fiore, generating a Level-1 value, using a defined randomness.

func (*PubKey) EncryptFixedB

func (l *PubKey) EncryptFixedB(m, r, b *big.Int) (e *EncryptedL1, err error)

EncryptFixedB encrypts a value using TCPaillier and Catalano-Fiore, generating a Level-1 value, using a defined randomness and a b value.

func (*PubKey) Mul

func (l *PubKey) Mul(c1, c2 *EncryptedL1) (mul *EncryptedL2, err error)

Mul multiplies two Encrypted Level-1 values and returns an encrypted Level-2 value. The mul encryption is deterministic.

func (*PubKey) MulConstL1

func (l *PubKey) MulConstL1(c *EncryptedL1, cons *big.Int) (mul *EncryptedL1, err error)

MulConstL1 multiplies an Encrypted Level-1 value by a constant. The encryption is deterministic. TODO: check if we can use the normal zkproofs to create a zkproof for this case. Meanwhile, we have no ZKProofs.

func (*PubKey) MulConstL2

func (l *PubKey) MulConstL2(c *EncryptedL2, cons *big.Int) (mul *EncryptedL2, err error)

MulConstL2 multiplies an Encrypted Level-2 value by a constant. The encryption is deterministic. TODO: check if we can use the normal zkproofs to create a zkproof for this case. Meanwhile, we have no ZKProofs.

func (*PubKey) PartialDecryptL1

func (l *PubKey) PartialDecryptL1(key *tcpaillier.KeyShare, c *EncryptedL1) (share *DecryptedShareL1, zk *DecryptedShareL1ZK, err error)

PartialDecryptL1 decrypts partially an encrypted Level-1 value using a given key share. It returns the decrypted share and a ZKProof over the encrypted value.

func (*PubKey) PartialDecryptL2

func (l *PubKey) PartialDecryptL2(key *tcpaillier.KeyShare, c *EncryptedL2) (share *DecryptedShareL2, zk *DecryptedShareL2ZK, err error)

PartialDecryptL2 decrypts partially an encrypted Level-2 value using a given key share. It returns the decrypted share and a ZKProof over the encrypted value.

Jump to

Keyboard shortcuts

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