Skip to content

Latest commit

 

History

History

array-shell-sort

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Shell Sort

Before Getting Started

This demo is run by Cypress. The package.json includes Cypress installation, however, if needed, you can install it separately with npm install cypress --save-dev.

Protocol 💻

Each party inputs an array of length N. The protocol sums element-wise, shell-sort the resulting array, and outputs the sorted array. The implementation of this protocol is located in mpc.js

This demo also includes the use of the jiff_websockets extension, superseding the original socket.io functionalities. For the use of the jiff_websockets extension, client.html must include the latest dist/jiff-client-websockets.js file. Therefore, whenever any change is made in the /lib/ext/jiff-client-websockets.js file, you must run npm run build in CML before running this demo.

Running Demo 🏃🏃‍♀️🏃‍♂️

1. Run the server

node demos/support/server.ts   

⚠️Important: You must run a fresh server every time. For example, if a test is paused at any point, it is required to terminate the server and restart it before running the rest of the demo.

2. Run from the Cypress Test Runner 🎥 (with video demos)

  1. Run npm run cypress:open in CML

  2. Choose a browser (Chrome Recommended)

image
  1. Click a demo protocol of your choice
image

3. Interpret the Result 🧐

After a second to a few seconds of executing the test by the above 2 steps, you will see the following results, if successful:

image

Remember that this image is just an example. Your result may look slightly different.

Alternatively... ☞☞

The demo/test can be run from the command line without videos.

1. Run the server in the same way

node demos/support/server.ts

2. Run from the command line ⌨️ (without visual demos)

npx cypress run --config-file demos/cypress.config.ts --spec "demos/array-shell-sort/test.cy.ts"

3. Interpret the result in the CML

image

There is something more... 📦

The demo can be run without Cypress

1. Run the server in the same way

node demos/support/server.ts

2. Experiment on a Browser

Visit http://localhost:8080/demos/array-shell-sort/client.html

3. Connect and Submit

image

Code Structure ⌨️

This Cypress-based demo adopts the web-worker system to emulate multiple threaded execution. In the real-world MPC implementation, clients act in a distributed manner, allowing multiple users to send data from separate browsers. However, the Cypress test framework does not allow multiple tabs/windows, and therefore, it is necessary to make the demo test run as if multiple inputs were submitted from their browsers.

Here, the web-worker system plays a central role. The client.js interfaces with the client.html, containing UI components. client.js sends the required instructions to the web-worker.js. The web worker then calls MPC functions, connects & computes, and returns results to the client.js, which then gets displayed in the UI.

image