Documentation ¶
Index ¶
- func KeyGen(secParam int, pointCompression bool) (*PublicKey, *SecretKey)
- func NewCryptoRandom(max []byte) []byte
- type Ciphertext
- type CiphertextByte
- type PublicKey
- func (pk *PublicKey) Add(cA, cB *Ciphertext, rand bool) *Ciphertext
- func (pk *PublicKey) Bytes2Ciphertext(ciphertextBytes *CiphertextByte, pointCompression bool) *Ciphertext
- func (pk *PublicKey) CheckOnCurve(ciphertext *Ciphertext) bool
- func (pk *PublicKey) Ciphertext2Bytes(ciphertext *Ciphertext, pointCompression bool) *CiphertextByte
- func (pk *PublicKey) Encrypt(m *big.Int) *Ciphertext
- func (pk *PublicKey) EncryptInv(m *big.Int) *Ciphertext
- func (pk *PublicKey) InitCurve()
- func (pk *PublicKey) ScalarMult(cA *Ciphertext, scalar *big.Int, rand bool) *Ciphertext
- func (pk *PublicKey) ScalarMultRandomizer(cA *Ciphertext, rand bool) *Ciphertext
- type SecretKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCryptoRandom ¶
This function returns a random number smaller than max
Types ¶
type CiphertextByte ¶
type PublicKey ¶
type PublicKey struct { Curve *elliptic.Curve SecParam int Hx *big.Int Hy *big.Int PointCompression bool }
func (*PublicKey) Add ¶
func (pk *PublicKey) Add(cA, cB *Ciphertext, rand bool) *Ciphertext
This function, given a public key, homomorphically add two ciphertexts together and returns a ciphertext of their sum. The function will re-randomize the resulting ciphertext (can be seen as homomorphic addition with an encryption of zero) if the input boolean variable "rand" is set to true.
func (*PublicKey) Bytes2Ciphertext ¶
func (pk *PublicKey) Bytes2Ciphertext(ciphertextBytes *CiphertextByte, pointCompression bool) *Ciphertext
This function decodes ciphertext bytes back to a ciphertext struct
func (*PublicKey) CheckOnCurve ¶
func (pk *PublicKey) CheckOnCurve(ciphertext *Ciphertext) bool
This function checks if a given ciphertext is a well-formed ciphertext
func (*PublicKey) Ciphertext2Bytes ¶
func (pk *PublicKey) Ciphertext2Bytes(ciphertext *Ciphertext, pointCompression bool) *CiphertextByte
This function encodes a ciphertext struct to bytes
func (*PublicKey) Encrypt ¶
func (pk *PublicKey) Encrypt(m *big.Int) *Ciphertext
This function, given a public key, encrypts a plaintext message and return a ciphertext
func (*PublicKey) EncryptInv ¶
func (pk *PublicKey) EncryptInv(m *big.Int) *Ciphertext
This function returns a ciphertext of the inverse of the input plaintext
func (*PublicKey) InitCurve ¶
func (pk *PublicKey) InitCurve()
This function initializes a curve under the public key
func (*PublicKey) ScalarMult ¶
func (pk *PublicKey) ScalarMult(cA *Ciphertext, scalar *big.Int, rand bool) *Ciphertext
This function, given a public key, achieves scalar multiplication on the input ciphertext with a given scalar. The function will re-randomize the // resulting ciphertext (can be seen as homomorphic addition with an encryption of zero) // if the input boolean variable "rand" is set to true.
func (*PublicKey) ScalarMultRandomizer ¶
func (pk *PublicKey) ScalarMultRandomizer(cA *Ciphertext, rand bool) *Ciphertext
This function, given a public key, achieves scalar multiplication on the input ciphertext with a randomly chosen scalar from Zn. The function will re-randomize the resulting ciphertext (can be seen as homomorphic addition with an encryption of zero) if the input boolean variable "rand" is set to true.
type SecretKey ¶
func (*SecretKey) DecryptAndCheck ¶
func (sk *SecretKey) DecryptAndCheck(c *Ciphertext, test []byte) bool
This function, given a secret key, checks if the input ciphertext is an encryption of the input plaintext
func (*SecretKey) DecryptAndCheck0 ¶
func (sk *SecretKey) DecryptAndCheck0(c *Ciphertext) bool
This function, given a secret key, checks if the input ciphertext is an encryption of zero