Assignment 4: Cryptography Crash Course
In this assignment, you will be exposed to three cryptographic techniques that are related to the papers we will read in the cryptographic systems course unit.
The purpose of this assignment is to get you a little familiar with what these techniques and protocols look like at the API level, what they could be used for, and some of the practical challenges developers face when trying to use them.
Overall Instructions
Overview of what you will do:
- Implement a secure multiparty computation (MPC) simple voting application using the JIFF MPC framework.
- Implement a private set intersection (PSI) protocol based on DDH and elliptic curve oblivious pseudorandom functions (OPRF).
- Use private information retrieval (PIR) to privately query a database using the Checklist protocol.
We provide a lot of stub code to make your tasks easier. Find and clone the stencil code in this Github repo. Each directory has a README with some low level instructions about the code and how to run it, and some documentation references. Please read the instructions carefuly, as they are designed to make the assignment easier for you.
Submission instructions:
Your submission will consist of a written report that has answers for the specific questions below, and a zip file containing
all the implementation and code that you filled into the stencil.
In your report, please write a few sentences or a short paragraph for every question, highlighting your approach and your findings.
Do not just provide your answer in one word! Please show us your rational/steps.
Submit your report and zip file to cs2390tas@lists.brown.edu
by 11pm (Eastern time) on Friday, November 22, 2024
MPC Voting Application
Secure multiparty computation (MPC) allows multiple parties to perform a computation on their private sensitive inputs. The inputs remain unknown to all other parties, and only the final output of the computation is revealed at the end.
In the real-world, each party has its own device that it uses to participate in the computation, e.g. a laptop or phone. In this assignment, each party will be a separate process that you run in a separate terminal. These processes communicate together over sockets, as if they are separate devices. Additionally, our implementation uses a server to orchestrate communication between these parties, e.g. so that parties do not need to manage the identity and IPs of all other parties, or have to deal with NAT, or other networking challenges.
We will look into shamir secret sharing based MPC. In this variant, each party splits each of its secret inputs into a collection of secret shares, one per party. For example, if there are a total of 3 parties, each input will be split into 3 shares, each sent to a different party. When combined together these shares reconstruct the original input. In JIFF, the MPC framework we will use, this operation is called open(...). JIFF provides APIs to also operate over these shares. For example, it allows adding the shares together to compute a new sharing of the sum of the secret inputs.
Here's a simple example of summing one secret input per party, and opening the result, in JIFF.
Your task is to implement a secret ballot voting MPC application. The scenario is as follows: you and two other friends are trying to choose a restaurant to go to for dinner. You do not want anyone to know what you voted for, only the total votes each option received. At a high level, if a party voted for one restaurant, say "DuneBrothers", it should secret share a value of 1 for that option, and 0 for all other options. The MPC code should then sum the vote values per options, which would correspond to the count of 1s that option received from every participant. More implementation details and steps are available in the stencil.
After implementing and testing your code. Please answer the following questions in your written report.
To print the value of a secret share, you can use this code:
// share contains a secret share. console.log('value of share', await share.value);
Private Set Intersection (PSI)
In this problem you will look at the following scenario. A server has a list of passwords it knows have been leaked or are otherwise vulnerable. This list is private to the server, and might be large. A client has one potential password it's considering using for some sensitive account. The client would like to know if the password is one of the vulnerable ones, without telling the server what the password is, and without the server revealing all leaked passwords to the client.
You will implement a private set intersection that allows the client and server to perform this check privately. A description of this protocol and instructions for how and where to implement its steps are in the stencil repo. Please follow them and then test your code. It should correctly identify the bad passwords in the provided list, but not any other passwords.
Hint: Start by assuming the client has exactly two passwords.
Hint 2: Start with modifying the protocol to reveal whether any of the two clients passwords are bad.
Hint 3: Now, try to make the protocol reveal *which* of the passwords are bad, if any.
Hint 4: Generalize to more than two passwords!
Private Information Retrieval (PIR)
PIR allows a client to query a database held at one or more servers. The query is private and unknown to the server, but the client still receives the output.
The most simple PIR variants assume that (1) the database is public / it's ok to reveal more information about the database than just the exact query answer, (2) the database is contigious vector, with indices between [0,n), and the client queries are secret indices in that vector. Furthermore, the protocol we will be using, Checklist, has a couple of extra setup details: (1) there are two non-colluding servers that both have a copy of the database, (2) the client and servers can perform a preprocessing step before the client issues queries, in which the client receives hints from the servers it can then use to make its querying more efficient. Checklist's offline preprocessing steps requires the server to do O(n) computation, and send O(sqrt(n)) communication to the client, where n is the size of the database. Then, each query requires O(sqrt(n)) computation on the server, and O(log(n)) communication between server and client.
Hint: Would hashing work? How large is the domain if using hashing?
Hint 2: Could you do something better than hashing? the keys are made up from 2 character lower case english letters. Can you use some alphabetical ordering or ascii encoding instead?
This is the end of the assignment! 🥳 Now, package up your answers and code and submit your work.