Documentation ¶
Index ¶
- type Encrypter
- type PrecomputeBuffer
- type PrecomputeBufferMock
- type PrivateKey
- type PublicKey
- func (k *PublicKey) Add(a, b *big.Int) *big.Int
- func (k *PublicKey) AddTo(a, b *big.Int) *big.Int
- func (k *PublicKey) Encrypt(m *big.Int) *big.Int
- func (k *PublicKey) Mul(a, b *big.Int) *big.Int
- func (k *PublicKey) PartiallyEncrypt(m *big.Int) *big.Int
- func (k *PublicKey) Randomize(a *big.Int) *big.Int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Encrypter ¶
type Encrypter interface { // Randomize (re-)randomizes an encrypted value Randomize(ciphertext *big.Int) *big.Int // Encrypt encrypts a message (big.Int) Encrypt(plaintext *big.Int) *big.Int // PartiallyEncrypt does the first part of the encryption, so that the // (computationally expensive) randomization can be done at a later time. PartiallyEncrypt(plaintext *big.Int) *big.Int // Add adds two encrypted values and returns the encrypted sum. Add(ciphertextA, ciphertextB *big.Int) *big.Int // AddTo adds b to the Encrypted value a (and also returns it). AddTo(ciphertextA, ciphertextB *big.Int) *big.Int // Mul multiplies the plaintext value b with the encrypted value a and returns the result. Mul(ciphertextA, plaintextB *big.Int) *big.Int }
Encrypter is an interface for additively homomorphic encryption schemes.
type PrecomputeBuffer ¶
type PrecomputeBuffer struct { PublicKey // public key for which we generate random exponents // contains filtered or unexported fields }
PrecomputeBuffer embeds PublicKey and thus implements the Encrypter interface,
func NewPrecomputeBuffer ¶
func NewPrecomputeBuffer(pk PublicKey, bufferSize int, numProc int, waitForCompletion bool) (*PrecomputeBuffer, error)
NewPrecomputeBuffer creates a new PrecomputeBuffer for the specified public key and immediately starts filling this buffer using numProc processors (goroutines).
func (*PrecomputeBuffer) Close ¶
func (pcbuf *PrecomputeBuffer) Close()
Close stops the goroutines associated with the PrecomputeBuffer
func (*PrecomputeBuffer) Encrypt ¶
func (pcbuf *PrecomputeBuffer) Encrypt(m *big.Int) *big.Int
Encrypt encrypts a message (big.Int) and uses pre-computed random exponents to speed-up the computation.
func (*PrecomputeBuffer) Get ¶
func (pcbuf *PrecomputeBuffer) Get() *big.Int
Get returns a new random exponent
type PrecomputeBufferMock ¶
type PrecomputeBufferMock struct { PublicKey // public key for which we generate random exponents // contains filtered or unexported fields }
func NewPrecomputeBufferMock ¶
func NewPrecomputeBufferMock(pk PublicKey) (*PrecomputeBufferMock, error)
NewPrecomputeBufferMock creates a new PrecomputeBufferMock for the specified public key and reuses the same random value to mock a filled ProcomputeBuffer
func (*PrecomputeBufferMock) Close ¶
func (pcbuf *PrecomputeBufferMock) Close()
Close stops the goroutines associated with the PrecomputeBuffer
func (*PrecomputeBufferMock) Encrypt ¶
func (pcbuf *PrecomputeBufferMock) Encrypt(m *big.Int) *big.Int
Encrypt encrypts a message (big.Int) and uses pre-computed random exponents to speed-up the computation.
func (*PrecomputeBufferMock) Get ¶
func (pcbuf *PrecomputeBufferMock) Get() *big.Int
Get returns a new random exponent
type PrivateKey ¶
type PrivateKey struct { PublicKey Lambda *big.Int X *big.Int // Cached value for faster decryption }
PrivateKey is a Paillier private key
func GenerateKey ¶
func GenerateKey(bits int) (priv *PrivateKey, err error)
GenerateKey generates a random Paillier private key
type PublicKey ¶
type PublicKey struct { N *big.Int N2 *big.Int // cached value of N^2 Nplus1 *big.Int // cached value of N + 1 // contains filtered or unexported fields }
PublicKey is a Paillier public key and implements the Encrypter interface
func (*PublicKey) Mul ¶
Mul multiplies the plaintext value b with the encrypted value a and returns the result.
func (*PublicKey) PartiallyEncrypt ¶
PartiallyEncrypt does the first part of the encryption, so that the (computationally expensive) randomization can be done at a later time.