Examples

We have provided a few example files to get you started with ORQ programs. The sources are available here.

0: Template

Example 0: An empty file.

Use this as a template for creating new ORQ programs.

Functions

int main(int argc, char **argv)

1: Secret Sharing

Example 1: Secret Sharing.

To run this example, use the run_experiment script as detailed in the README.

../scripts/run_experiment.sh ... ex1_secret_sharing

This example also shows the bare minimum required to run an ORQ program. It works with any protocol.

Functions

int main(int argc, char **argv)

2: Operators

Example 2: Secret-Shared Operations.

To run this example, use the run_experiment script as detailed in the README.

../scripts/run_experiment.sh ... ex2_operators

This example demonstrates ORQ’s vectorized primitives for secret-shared computation.

Functions

int main(int argc, char **argv)

3: Relational

Example 3: Relational Operators.

To run this example, use the run_experiment script as detailed in the README.

../scripts/run_experiment.sh ... ex3_relational

This example demonstrates ORQ’s relational analytics engine.

We assume two secret shared tables (which themselves could be concatenations of multiple data owners’ input):

  1. A users table, which contains sensitive user IDs (such as SSNs), ages, and states;

  2. A payments table, which contains sensitive user IDs and payment amounts

We can imagine that table 1 was contributed in secret-shared form by, e.g., multiple separate government agencies, while table 2 was contributed by, e.g. credit card companies. Of course, none of the data parties would want to give their data, in the clear, to any of the other parties.

The query we want to answer: what is the average amount of money spent, per person between the ages of 18 and 30, in each state?

We represent states as arbitrary integers 0 through 50.

Functions

int main(int argc, char **argv)

4: Wagegap

Example 4: Wagegap Demo.

Given secret-shared employment data, compute the wagegap for various demographic groups in Academia vs Industry.

We generate a random secret-shared table of employment data. The schema is:

  • Salary: this employee’s annual salary in USD

  • Degree: the highest degree they have earned. (Enum.)

  • YearsExp: Their years of experience

  • Region: The region of the world they work in. (Enum.)

  • Academia: A bit representing whether they work an industry (0) or academia (0)

Then, we run a series of aggregations, using each column as part of a compound key, and compute the wage gap between academia and industry.

For the Years of Experience, we create histogram bins by running comparison circuits and shifting the resulting bits into specific locations to create distinct “labels” for each range.

At the end of each subquery, we take the average using private division (since the counts in each group will also be private). Then, we reset the table by calling configureValid, which allows us to proceed to the next analysis. (Since oblivious computation cannot delete rows, all input rows remain present in the table and unchanged. We just mark them as invalid during query execution.)

Defines

_ROWS

Enums

enum Degree

Values:

enumerator NoCollege
enumerator Undergraduate
enumerator Graduate
enumerator Doctorate
enumerator DegreeOther
enumerator _COUNT_DEGREES
enum Region

Values:

enumerator NorthAmerica
enumerator SouthAmerica
enumerator Europe
enumerator Africa
enumerator Asia
enumerator MiddleEast
enumerator Oceania
enumerator Other
enumerator _COUNT_REGIONS

Functions

int main(int argc, char **argv)

5: Join

Example 5: Joins.

This example shows how all types of joins work.

We’ll define two secret-shared tables:

ATTENDEES: a database of students who went to a conference.

  • StudentID (unique)

  • GaveTalk (boolean)

CLASSES: a database of course schedules

  • CourseID (non-unique; multiple courses)

  • StudentID (non-unique; students can take multiple courses)

Change the sizes of the two tables (and bounds on the IDs) to see how the results change.

Different kinds of joins tell us different information about the overlap between two tables:

             | Went to Conference | Did not go to Conference
-------------|--------------------|-------------------------
    In Class |         A          |            C
Not in Class |         B          |            D

The (plaintext) cardinalities of various joins (Attendees Join Classes) are:

  • Inner join: A

  • Left outer join (Attendees): A + B

  • Right outer join (Classes): A + C

  • Full outer join: A + B + C

Note that students in quantity D are not represented in either of our tables.

Functions

int main(int argc, char **argv)