ABY Framework  1.0
Arithmetic Bool Yao Framework
 All Classes Files Functions Variables Enumerations Enumerator Macros
Classes | Macros | Typedefs | Functions
djn.h File Reference

A library implementing the Damgaard Jurik Nielsen cryptosystem with s=1 (Same properties as Paillier, but more efficient). based on:
libdjn - A library implementing the Paillier cryptosystem. (http://hms.isi.jhu.edu/acsc/libdjn/) More...

#include <gmp.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "powmod.h"
Include dependency graph for djn.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  djn_pubkey_t
 
struct  djn_prvkey_t
 

Macros

#define PAILLIER_BITS_TO_BYTES(n)   ((n) % 8 ? (n) / 8 + 1 : (n) / 8)
 

Typedefs

typedef void(* djn_get_rand_t )(void *buf, int len)
 

Functions

void djn_keygen (unsigned int modulusbits, djn_pubkey_t **pub, djn_prvkey_t **prv)
 
void djn_encrypt (mpz_t res, djn_pubkey_t *pub, mpz_t pt, gmp_randstate_t rnd)
 
void djn_encrypt_crt (mpz_t res, djn_pubkey_t *pub, djn_prvkey_t *prv, mpz_t pt, gmp_randstate_t rnd)
 
void djn_encrypt_fb (mpz_t res, djn_pubkey_t *pub, mpz_t plaintext, gmp_randstate_t rnd)
 
void djn_decrypt (mpz_t res, djn_pubkey_t *pub, djn_prvkey_t *prv, mpz_t ct)
 
char * djn_pubkey_to_hex (djn_pubkey_t *pub)
 
char * djn_prvkey_to_hex (djn_prvkey_t *prv)
 
djn_pubkey_tdjn_pubkey_from_hex (char *str)
 
djn_prvkey_tdjn_prvkey_from_hex (char *str, djn_pubkey_t *pub)
 
void djn_freepubkey (djn_pubkey_t *pub)
 
void djn_freeprvkey (djn_prvkey_t *prv)
 
void djn_pow_mod_n_crt (mpz_t res, const mpz_t b, const mpz_t e, const djn_pubkey_t *pub, const djn_prvkey_t *prv)
 
void djn_pow_mod_n_squared_crt (mpz_t res, const mpz_t b, const mpz_t e, const djn_pubkey_t *pub, const djn_prvkey_t *prv)
 
void djn_complete_pubkey (unsigned int modulusbits, djn_pubkey_t **pub, mpz_t n, mpz_t h)
 

Detailed Description

A library implementing the Damgaard Jurik Nielsen cryptosystem with s=1 (Same properties as Paillier, but more efficient). based on:
libdjn - A library implementing the Paillier cryptosystem. (http://hms.isi.jhu.edu/acsc/libdjn/)

Author
Daniel Demmler

Function Documentation

void djn_complete_pubkey ( unsigned int  modulusbits,
djn_pubkey_t **  pub,
mpz_t  n,
mpz_t  h 
)

create full public key given only n and h (e.g., after a key exchange)

void djn_decrypt ( mpz_t  res,
djn_pubkey_t pub,
djn_prvkey_t prv,
mpz_t  ciphertext 
)

decrypt, using CRT, assumes res to be initialized

void djn_encrypt ( mpz_t  res,
djn_pubkey_t pub,
mpz_t  plaintext,
gmp_randstate_t  rnd 
)

encrypt plaintext to res

void djn_encrypt_crt ( mpz_t  res,
djn_pubkey_t pub,
djn_prvkey_t prv,
mpz_t  plaintext,
gmp_randstate_t  rnd 
)

encrypt plaintext using crt if private key is known

void djn_encrypt_fb ( mpz_t  res,
djn_pubkey_t pub,
mpz_t  plaintext,
gmp_randstate_t  rnd 
)

fixed base encryption. Requires pre-computed fixed base table.

mpz_t version of encrypt_crt