emp-toolkit
garble.h File Reference
#include "block.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <openssl/sha.h>

Go to the source code of this file.

Classes

struct  garble_gate
 
struct  garble_fixed_wire
 
struct  garble_circuit
 

Macros

#define GARBLE_OK   0
 
#define GARBLE_ERR   -1
 

Enumerations

enum  garble_type_e { GARBLE_TYPE_STANDARD, GARBLE_TYPE_HALFGATES, GARBLE_TYPE_PRIVACY_FREE }
 
enum  garble_gate_type_e {
  GARBLE_GATE_ZERO = 0, GARBLE_GATE_ONE = 15, GARBLE_GATE_AND = 8, GARBLE_GATE_OR = 14,
  GARBLE_GATE_XOR = 6, GARBLE_GATE_NOT = 5, GARBLE_GATE_EMPTY = -1
}
 
enum  garble_fixed_wire_e { GARBLE_FIXED_WIRE_ZERO = 0, GARBLE_FIXED_WIRE_ONE = 1 }
 

Functions

size_t garble_table_size (const garble_circuit *gc)
 
int garble_new (garble_circuit *gc, uint64_t n, uint64_t m, garble_type_e type)
 
void garble_delete (garble_circuit *gc)
 
int garble_garble (garble_circuit *gc, const block *input_labels, block *output_labels)
 
void garble_hash (const garble_circuit *gc, unsigned char hash[SHA_DIGEST_LENGTH])
 
int garble_check (garble_circuit *gc, const unsigned char hash[SHA_DIGEST_LENGTH])
 
block garble_create_delta (void)
 
void garble_create_input_labels (block *labels, uint64_t n, block *delta, bool privacyfree)
 
int garble_eval (const garble_circuit *gc, const block *input_labels, block *output_labels, bool *outputs)
 
void garble_extract_labels (block *extracted_labels, const block *labels, const bool *bits, uint64_t n)
 
int garble_map_outputs (const block *output_labels, const block *map, bool *vals, uint64_t m)
 
int garble_circuit_to_file (garble_circuit *gc, char *fname)
 
int garble_circuit_from_file (garble_circuit *gc, char *fname)
 
size_t garble_size (const garble_circuit *gc, bool wires)
 
int garble_save (const garble_circuit *gc, FILE *f, bool wires)
 
int garble_load (garble_circuit *gc, FILE *f, bool wires)
 
int garble_to_buffer (const garble_circuit *gc, char *buf, bool wires)
 
int garble_from_buffer (garble_circuit *gc, const char *buf, bool wires)
 

Macro Definition Documentation

§ GARBLE_ERR

#define GARBLE_ERR   -1

§ GARBLE_OK

#define GARBLE_OK   0

Enumeration Type Documentation

§ garble_fixed_wire_e

Enumerator
GARBLE_FIXED_WIRE_ZERO 
GARBLE_FIXED_WIRE_ONE 

§ garble_gate_type_e

Enumerator
GARBLE_GATE_ZERO 
GARBLE_GATE_ONE 
GARBLE_GATE_AND 
GARBLE_GATE_OR 
GARBLE_GATE_XOR 
GARBLE_GATE_NOT 
GARBLE_GATE_EMPTY 

§ garble_type_e

Enumerator
GARBLE_TYPE_STANDARD 
GARBLE_TYPE_HALFGATES 
GARBLE_TYPE_PRIVACY_FREE 

Function Documentation

§ garble_check()

int garble_check ( garble_circuit gc,
const unsigned char  hash[SHA_DIGEST_LENGTH] 
)

§ garble_circuit_from_file()

int garble_circuit_from_file ( garble_circuit gc,
char *  fname 
)

§ garble_circuit_to_file()

int garble_circuit_to_file ( garble_circuit gc,
char *  fname 
)

§ garble_create_delta()

block garble_create_delta ( void  )

§ garble_create_input_labels()

void garble_create_input_labels ( block labels,
uint64_t  n,
block delta,
bool  privacyfree 
)

§ garble_delete()

void garble_delete ( garble_circuit gc)

§ garble_eval()

int garble_eval ( const garble_circuit gc,
const block input_labels,
block output_labels,
bool *  outputs 
)

§ garble_extract_labels()

void garble_extract_labels ( block extracted_labels,
const block labels,
const bool *  bits,
uint64_t  n 
)

§ garble_from_buffer()

int garble_from_buffer ( garble_circuit gc,
const char *  buf,
bool  wires 
)

§ garble_garble()

int garble_garble ( garble_circuit gc,
const block input_labels,
block output_labels 
)

§ garble_hash()

void garble_hash ( const garble_circuit gc,
unsigned char  hash[SHA_DIGEST_LENGTH] 
)

§ garble_load()

int garble_load ( garble_circuit gc,
FILE *  f,
bool  wires 
)

§ garble_map_outputs()

int garble_map_outputs ( const block output_labels,
const block map,
bool *  vals,
uint64_t  m 
)

§ garble_new()

int garble_new ( garble_circuit gc,
uint64_t  n,
uint64_t  m,
garble_type_e  type 
)

§ garble_save()

int garble_save ( const garble_circuit gc,
FILE *  f,
bool  wires 
)

§ garble_size()

size_t garble_size ( const garble_circuit gc,
bool  wires 
)

§ garble_table_size()

size_t garble_table_size ( const garble_circuit gc)
inline

§ garble_to_buffer()

int garble_to_buffer ( const garble_circuit gc,
char *  buf,
bool  wires 
)