num

package
v0.0.0-...-c6538f3 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Int

type Int struct {
	Cipher    *big.Int
	PublicKey *key.PublicKey
}

Int represents and encrypted integer using the Paillier cryptosystem. The public key used to encrypt the integer is also included. A notable feature of the Paillier cryptosystem is its homomorphic properties along with its non-deterministic encryption.

func NewInt

func NewInt(publicKey *key.PublicKey, x *big.Int) *Int

NewInt returns the encryption of x using the given public key.

func (*Int) AddCiphertext

func (z *Int) AddCiphertext(x, y *Int) *Int

AddCiphertext sets z to the encrypted sum x+y and returns z. If x.PublicKey != y.PublicKey, a pubic-keys-not-equal run-time panic occurs.

func (*Int) AddPlaintext

func (z *Int) AddPlaintext(x *Int, y *big.Int) *Int

AddPlaintext sets z to the encrypted sum x+y and returns z.

func (*Int) Decrypt

func (z *Int) Decrypt(privateKey *key.PrivateKey) *big.Int

Decrypt returns the decrypted value of z using the given private key. If z.PublicKey != privateKey.PublicKey, a pubic-keys-not-equal run-time panic occurs.

func (*Int) DivPlaintext

func (z *Int) DivPlaintext(x *Int, y *big.Int) *Int

DivPlaintext sets z to the encrypted quotient x/y and returns z. If y == 0, a division-by-zero run-time panic occurs. DivPlaintext will return an invalid result in cases where y does not divide x.

func (*Int) MulPlaintext

func (z *Int) MulPlaintext(x *Int, y *big.Int) *Int

MulPlaintext sets z to the encrypted product x*y and returns z.

func (*Int) SubCiphertext

func (z *Int) SubCiphertext(x, y *Int) *Int

SubCiphertext sets z to the encrypted difference x-y and returns z. If x.PublicKey != y.PublicKey, a pubic-keys-not-equal run-time panic occurs.

Jump to

Keyboard shortcuts

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