Debug

Various debugging utilities.

Defines

FANTASTIC4

Numeric codes for each protocol.

REPLICATED3
BEAVER2
PLAINTEXT1
DUMMY0
PROTOCOL_NUM

The default protocol.

MPI_COMMUNICATOR
NOCOPY_COMMUNICATOR
COMMUNICATOR_NUM

The default communicator.

MPC_USE_MPI_COMMUNICATOR

If SINGLE_EXECUTION is defined, don’t compile with a communicator. (Useful for debugging)

MPC_USE_RANDOM_GENERATOR_TRIPLES
SOCKET_COMMUNICATOR_RING_SIZE
SOCKET_COMMUNICATOR_BUFFER_SIZE
SOCKET_COMMUNICATOR_WAIT_MS
NOCOPY_COMMUNICATOR_RING_SIZE

Current communicaton API only uses 1 ring element, ring_size can be changed later if needed.

NOCOPY_COMMUNICATOR_THREADS
MPC_GENERATE_DATA
MPC_RANDOM_DATA_RANGE
MPC_USE_RANDOM_GENERATOR_DATA
MPC_EVALUATE_CORRECT_OUTPUT
MPC_CHECK_CORRECTNESS
USE_DIVISION_CORRECTION
DEBUG_VECTOR_SAME_AS
USE_SECURE_JOIN
USE_INDEX_MAPPED_VECTOR

If defined, Vectors use index mapping to track access patterns instead of VectorData.

PRINT_PROTOCOL_STATISTICS

Print usage statistics for an MPC protocol.

SERVICE_NAMESPACE

Preprocessor defines to generate proper namespaces.

MPC_PROTOCOL_REPLICATED_THREE
COMPILED_MPC_PROTOCOL_NAMESPACE
single_cout(x)

Print x on party zero, only, with a newline.

all_cout(x)

Print x on all parties, prepending with party ID.

single_cout_nonl(x)

Print x on party zero, only, without a newline.

VAR(x)

Pass a variable’s name and value to std::cout. Use like:

std::cout << VAR(x) << VAR(y) << "\n";

This will output something like

x = 3 y = 10

VECTOR_SPACING
TABLE_SPACING
DEBUG_PRINT(x)
_STRINGIFY(x)
STRINGIFY(x)

Functions

std::istream &operator>>(std::istream &in, __int128 &val)

Custom 128-bit handler for std::cin.

Parameters:
  • in

  • val

Returns:

std::istream&

std::ostream &operator<<(std::ostream &os, __int128 n)

Custom 128-bit handler for std::cout.

Parameters:
  • os

  • n

Returns:

std::ostream&

Variables

bool USE_GILBOA_CRT = true
bool MALICIOUS_PROTOCOL = false
bool CONFIDENTIAL_1PC = false
bool USE_STACKED_MULTIPLY_A = false
bool USE_STACKED_AND_B = true
bool SKIP_MALICIOUS_CHECK_FLAG = false
namespace orq
namespace debug

Functions

static void print_bin_(int num1, int num2, bool add_line, int party_num = 0)

Print numbers in binary.

Parameters:
  • num1

  • num2

  • add_line

  • party_num

template<typename VectorType>
static void print(VectorType &&vec, int partyID = 0)

Print a vector on a single party.

Template Parameters:

VectorType

Parameters:
  • vec

  • partyID – party to output, default P0

template<typename T>
static void print(std::string name, T &&vec)

Print a vector, prepended with a label.

Template Parameters:

T

Parameters:
  • name

  • vec

template<typename TableType>
static void print_table(const TableType &table, int partyID = 0)

Print a plaintext table.

Template Parameters:

TableType – can be any vector<vector> or similar

Parameters:
  • table

  • partyID

template<typename TableType>
static void print_table(const std::pair<TableType, std::vector<std::string>> &table, int partyID = 0)

Improved table output. Call with print_table(T.open_with_schema()). (Once plaintext tables are implemented, they will replace the current hacky version.

Template Parameters:

TableType

Parameters:
  • table

  • partyID

template<typename T>
T get_bit(const T &s, int i)
template<typename T>
void print_binary(const T &s)

Prints to stdout the binary representation of s.

Template Parameters:

T – The data type of the input s

Parameters:

s – The input whose binary representation we want to print.

template<typename VectorType>
void print_binary(const VectorType &v, int partyID)

Prints to stdout the binary representation of the elements in v.

Template Parameters:

VectorType – The vector type.

Parameters:
  • v – The input vector.

  • partyID – The ID of the party that calls this function.

template<typename K, typename V>
void print_map_keys(std::map<K, V> m)

Print the keys in map m separated by spaces.

Template Parameters:
  • K

  • V

Parameters:

m

template<typename T>
std::string container2str(const T &S)

Convert any container to string, enclosing it in curly brackets. Works on vectors, sets, etc.

Template Parameters:

T

Parameters:

S

Returns:

std::string