encryption

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSPaillier

type CSPaillier struct {
	SecParams *CSPaillierSecParams

	PubKey *CSPaillierPubKey
	SecKey *CSPaillierSecKey
	// contains filtered or unexported fields
}

CSPaillier represents Camenisch-Shoup variant of Paillier to make it (Paillier) CCA2 secure. http://eprint.iacr.org/2002/161.pdf

func NewCSPaillier

func NewCSPaillier(secParams *CSPaillierSecParams) *CSPaillier

func NewCSPaillierFromPubKey

func NewCSPaillierFromPubKey(pubKey *CSPaillierPubKey) *CSPaillier

func NewCSPaillierFromSecKey

func NewCSPaillierFromSecKey(secKey *CSPaillierSecKey) (*CSPaillier, error)

func (*CSPaillier) Abs

func (csp *CSPaillier) Abs(a *big.Int) (*big.Int, error)

func (*CSPaillier) Decrypt

func (csp *CSPaillier) Decrypt(u, e, v, label *big.Int) (*big.Int, error)

func (*CSPaillier) Encrypt

func (csp *CSPaillier) Encrypt(m, label *big.Int) (*big.Int, *big.Int, *big.Int, error)

Returns (u, e, v).

func (*CSPaillier) GetChallenge

func (csp *CSPaillier) GetChallenge() *big.Int

func (*CSPaillier) GetOpeningMsg

func (csp *CSPaillier) GetOpeningMsg(m *big.Int) (*big.Int, *big.Int)

Returns l = g1^m * h1^s where s is a random integer smaller than n/4.

func (*CSPaillier) GetProofData

func (csp *CSPaillier) GetProofData(c *big.Int) (*big.Int, *big.Int, *big.Int)

Prover should use this function to compute data for second (last) sigma protocol message.

func (*CSPaillier) GetProofRandomData

func (csp *CSPaillier) GetProofRandomData(u, e, label *big.Int) (*big.Int, *big.Int,
	*big.Int, *big.Int, *big.Int, error)

Prover (encryptor) should use this function to generate values for the first sigma protocol message.

func (*CSPaillier) SetProofRandomData

func (csp *CSPaillier) SetProofRandomData(u1, e1, v1, delta1, l1, c *big.Int)

Verifier should call this function when it receives proof random data as the second protocol message.

func (*CSPaillier) SetVerifierEncData

func (csp *CSPaillier) SetVerifierEncData(u, e, v, delta, label, l *big.Int)

Verifier should call this function when it receives l = g1^m * h1^s as the first protocol message.

func (*CSPaillier) Verify

func (csp *CSPaillier) Verify(rTilde, sTilde, mTilde *big.Int) bool

type CSPaillierProverEncData

type CSPaillierProverEncData struct {
	R *big.Int
	M *big.Int
}

type CSPaillierProverRandomData

type CSPaillierProverRandomData struct {
	S  *big.Int
	R1 *big.Int
	S1 *big.Int
	M1 *big.Int
}

type CSPaillierPubKey

type CSPaillierPubKey struct {
	N  *big.Int
	G  *big.Int
	Y1 *big.Int
	Y2 *big.Int
	Y3 *big.Int
	// the parameters below are for verifiable encryption
	Gamma                *schnorr.Group // for discrete logarithm
	VerifiableEncGroupN  *big.Int
	VerifiableEncGroupG1 *big.Int
	VerifiableEncGroupH1 *big.Int
	K                    int
	K1                   int
}

CSPaillierPubKey currently does not use auxiliary parameters/primes - no additional n, p, q parameters (as specified in a paper, original n, p, q can be used).

type CSPaillierSecKey

type CSPaillierSecKey struct {
	N  *big.Int
	G  *big.Int
	X1 *big.Int
	X2 *big.Int
	X3 *big.Int
	// the parameters below are for verifiable encryption
	Gamma                *schnorr.Group // for discrete logarithm
	VerifiableEncGroupN  *big.Int
	VerifiableEncGroupG1 *big.Int
	VerifiableEncGroupH1 *big.Int
	K                    int
	K1                   int
}

type CSPaillierSecParams

type CSPaillierSecParams struct {
	L        int // length of p1 and q1 (l in a paper)
	RoLength int // ro is order of cyclic group Gamma (used for discrete logarithm)
	K        int // k in a paper; it must hold 2**K < min{p1, q1, ro}
	K1       int // k' in a paper; it must hold ro * 2**(K + K1 + 3) < n

}

type CSPaillierVerifierEncData

type CSPaillierVerifierEncData struct {
	U     *big.Int
	E     *big.Int
	V     *big.Int
	Label *big.Int
	Delta *big.Int
}

type CSPaillierVerifierRandomData

type CSPaillierVerifierRandomData struct {
	L      *big.Int
	U1     *big.Int
	E1     *big.Int
	V1     *big.Int
	Delta1 *big.Int
	L1     *big.Int
	C      *big.Int
}

type Paillier

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

https://pirk.incubator.apache.org/papers/1999_asiacrypt_paillier_paper.pdf

func NewPaillier

func NewPaillier(primeLength int) *Paillier

func NewPubPaillier

func NewPubPaillier(pubKey *PaillierPubKey) *Paillier

func (*Paillier) Decrypt

func (paillier *Paillier) Decrypt(c *big.Int) (*big.Int, error)

func (*Paillier) Encrypt

func (paillier *Paillier) Encrypt(m *big.Int) (*big.Int, error)

func (*Paillier) GetPubKey

func (paillier *Paillier) GetPubKey() *PaillierPubKey

type PaillierPubKey

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

type VerifiableEncGroup

type VerifiableEncGroup struct {
	*qr.RSASpecial
	G1 *big.Int
	H1 *big.Int
	// contains filtered or unexported fields
}

func NewVerifiableEncGroup

func NewVerifiableEncGroup(primes *qr.RSASpecialPrimes) (*VerifiableEncGroup, error)

Jump to

Keyboard shortcuts

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