Skip to content

Commit eacdc11

Browse files
authored
Merge pull request #3 from multiparty/cleanup
Cleanup
2 parents a32b2b7 + 13220d5 commit eacdc11

File tree

143 files changed

+183633
-250934
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+183633
-250934
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/node_modules/

.eslint.json renamed to .eslintrc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,15 @@
2929
"browser": true,
3030
"jquery": true,
3131
"node": true,
32-
"amd": true,
32+
"amd":true,
3333
"es6": true
3434
},
3535

3636
"parserOptions":{
37-
"ecmaVersion": 6,
38-
"ecmaFeatures": {
39-
"experimentalObjectRestSpread": true
40-
}
37+
"ecmaVersion": 6
4138
},
4239
"plugins": [
43-
"requirejs"
40+
"requirejs",
41+
"mocha"
4442
]
4543
}

.eslintrc.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

README.md

Lines changed: 40 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# JIGG
2+
23
JavaScript implementation of garbled gates and 2PC boolean circuit protocols.
34

45
## Requirements and Installation
6+
57
This library is implemented entirely in JavaScript. Running the server requires [Node.js](https://nodejs.org/en/), [npm](https://www.npmjs.com/) (both installed via `yum install nodejs npm` or `brew install npm` on macOS), [Socket.IO](https://socket.io/), and [libsodium](https://www.npmjs.com/package/libsodium).
68

79
Run `npm` to install all JIGG dependencies:
@@ -12,60 +14,58 @@ npm install
1214
## Project Layout
1315

1416
├─ circuits/ Circuit files
15-
│ └─ bristol/ Extended functionality for use cases (e.g. negative numbers)
17+
│ ├─ macros/ Macro files to assemble circuits using [CASM](https://github.com/wyatt-howe/macro-circuit-assembler)
18+
│ └─ bristol/ Bristol format files
1619
├─ demo/ Demo for client-server deployment scenario
1720
├─ src/ Library modules implementing protocol steps for participants
1821
│ ├─ comm/ Communications modules (such as for OT)
19-
│ ├─ data/ Data structure modules (such as circuits)
22+
│ ├─ modules/ Data structure modules (such as circuits)
2023
│ └─ utils/ Other utility modules (such as cryptographic primitives)
21-
└─ test/ Unit tests and end-to-end simulation tests
22-
└─ suite/ End-to-end simulation tests
24+
└─ test/ End-to-end tests
25+
2326

27+
## Running Demo Circuit Applications
2428

25-
## Running Applications
26-
Start the communications server from server.js with the command below and optionally specify a port number such as:
29+
Start the communications server from server.js with the command below:
2730
```shell
28-
node server 3000
31+
node demo/server.js <port number>
2932
```
3033

3134
### As a Browser Party
32-
Parties can go to `http://localhost:port/` in a web browser supporting JavaScript to begin communications. This is strictly a two-party protocol at the moment.
35+
36+
Parties can go to `http://localhost:<port>/` in a web browser supporting JavaScript to begin communications.
3337

3438
### As a Node.js Party
39+
3540
Connect a new party in Node.js by running:
3641
```shell
37-
node demo/party.js <circuit> <role> <b16-input>
42+
node demo/party.js <port> <role> <input> <encoding> <circuitName>
43+
# <role>: Garbler or Evaluator
44+
# <input>: string with no whitespaces
45+
# <encoding>: bits, number, or hex
46+
# <circuitName>: must include file extension
47+
# demo will run bristol circuit found at
48+
# 'circuits/bristol/<circuitName>'
3849
```
50+
3951
For example to join an AES-128 computation as the garbler, run:
4052
```shell
41-
node demo/party.js aes128.txt garbler 00000000000000000000000000000000 # message in base 16
53+
node demo/party.js 3000 Evaluator 00000000000000000000000000000000 hex aes-128-reverse.txt
4254
```
4355

44-
### Demos
45-
We have a 64-bit equal-to-zero test (`circuits/bristol/zero_equal_64.txt`) in `circuits/bristol` and several other circuits from the same [page](https://homes.esat.kuleuven.be/~nsmart/MPC/). Circuits larger than ~6000 gates seem to hang the JS engine (sometimes only temporarily) and so are now forced to run in sequence to prevent this from occurring.
46-
47-
There is now a SHA-256 demo at `sha256.html` and `client.html`.
48-
The boolean circuit for SHA has +100,000 gates, and by limiting the number of gates encrypted in parallel, JIGG is able to compute it in under a minute in the browser. Test vectors are found [here](https://homes.esat.kuleuven.be/~nsmart/MPC/sha-256-test.txt) and in the `test/` folder.
56+
### Server + Garbler/Evaluator
4957

50-
### Circuit Format
51-
JIGG can evaluate a boolean circuit in either of two formats. It supports circuits represented using JSON according to the [SIGG](https://github.com/multiparty/sigg) standard.
52-
```javascript
53-
const circuit = {
54-
"wire_count":8, "gate_count":4,
55-
"value_in_count":2, "value_in_length":[2,2],
56-
"value_out_count":1, "value_out_length":[3],
57-
"wire_in_count":4, "wire_in_index":[1,2,3,4],
58-
"wire_out_count":3, "wire_out_index":[5,7,8],
59-
"gate": [
60-
{"wire_in_index":[1,2], "wire_out_index":[5], "operation":"and"},
61-
{"wire_in_index":[3,4], "wire_out_index":[6], "operation":"xor"},
62-
{"wire_in_index":[6], "wire_out_index":[7], "operation":"not"},
63-
{"wire_in_index":[5,7], "wire_out_index":[8], "operation":"and"}
64-
]
65-
};
58+
The server may also run as a garbler or evaluator. You can acheive this by running the server with
59+
the same arguments as a party:
60+
```shell
61+
node demo/server.js <port> <role> <input> <encoding> <circuitName>
6662
```
6763

68-
JIGG can also parse a circuit in the standardized '[Bristol](https://homes.esat.kuleuven.be/~nsmart/MPC/) [Format](https://homes.esat.kuleuven.be/~nsmart/MPC/old-circuits.html)' which is supported by several compiled MPC libraries such as [SCALE-MAMBA](https://homes.esat.kuleuven.be/~nsmart/SCALE/).
64+
## Demo Circuits
65+
We have a variety of circuits available under `circuits/bristol` mostly from this [page](https://homes.esat.kuleuven.be/~nsmart/MPC/).
66+
67+
### Circuit Format
68+
JIGG can parse a circuit in the standardized '[Bristol](https://homes.esat.kuleuven.be/~nsmart/MPC/) [Format](https://homes.esat.kuleuven.be/~nsmart/MPC/old-circuits.html)' which is supported by several compiled MPC libraries such as [SCALE-MAMBA](https://homes.esat.kuleuven.be/~nsmart/SCALE/).
6969
```ada
7070
4 8
7171
2 2 2
@@ -77,64 +77,22 @@ JIGG can also parse a circuit in the standardized '[Bristol](https://homes.esat.
7777
```
7878

7979
### Circuit Assembler
80-
To create a new circuit, write a macro with existing circuits as its gates and run the [macro-circuit-assembler](https://github.com/wyatt-howe/macro-circuit-assembler/tree/casm) with `npm run casm <path_to_macro> <output_path>`.
81-
82-
<!--For example, `npm run-script casm circuits/macros/and8.casm circuits/and8.txt` assembles the 8-bit AND circuit.-->
83-
84-
## Running Tests
80+
To create a new circuit, write a macro with existing circuits as its gates and run the [macro-circuit-assembler](https://github.com/wyatt-howe/macro-circuit-assembler/tree/casm) with:
8581

86-
### Generating Precomputed Garbled Gates
87-
It is possible to generate a collection of precomputed label assignments and garbled gates for each circuit.
8882
```shell
89-
node test/suite/generate.js
83+
npm run casm -- <path_to_macro> <output_path>
9084
```
91-
These files represent what a dedicated service could precompute and make available on-demand in order to improve the performance of a deployed instance of the protocol. Unit tests make use of these files if they are present.
9285

93-
### Unit Tests
94-
Unit tests of functional components (single-process without sockets) can be run using [mocha](https://mochajs.org/).
95-
```shell
96-
mocha test
97-
```
98-
It is possible to restrict the end-to-end unit tests to only test inputs on a specific circuit (note that the `.txt` circuit file extension is omitted).
99-
```shell
100-
mocha test --circuit logic-and-4-bit
101-
```
102-
The number of distinct inputs on which to run the circuits being tested can be specified.
103-
```shell
104-
mocha test --trials 3
105-
```
106-
The two options can also be combined.
107-
```shell
108-
mocha test --circuit logic-and-8-bit --trials 10
109-
```
86+
For example, this macro assembles an AND circuit over 8 bits using
87+
existing 4 bit AND circuits:
11088

111-
### End-to-end Tests
112-
All of the built-in test vectors can be verified in `npm test` or, equivalently, `node test/suite/simulate.js`. Communications between the server, garbler and evaluator are automated. You do not need to already have a server running; tests are run over port 3001.
113-
```shell
114-
npm test
115-
```
116-
You may also run an individual test on a specific circuit file.
117-
```shell
118-
node test/suite/simulate.js <circuit-file-path>
11989
```
120-
For example, execute the following to test a computation using the 8-bit conjunction circuit.
121-
```shell
122-
node test/suite/simulate.js and8.txt
90+
npm run casm -- circuits/macros/and-8.casm circuits/and-8.txt
12391
```
12492

125-
#### Legacy End-to-end Tests
126-
All of the built-in test vectors can be verified in `npm run test-old` or `node test/suite/all.js`. Communcations between the server, garbler and evaluator are automated. You do not need to already have a server running – tests are run over port 3001.
127-
128-
You may also access the test function directly, by running `test.js`.
129-
```shell
130-
node test/suite/test.js <circuit> <testvector>
131-
```
132-
For example to test an equal-to-zero computation with the zero vector, write:
133-
```shell
134-
node test/suite/test.js compare-eq-zero-64-bit.txt '["00000000","00000000","1"]'
135-
```
93+
## Running Tests
13694

137-
Predefined test cases (circuit name, test vector) for the circuits can be configured in `test/suite/defaults.json` or specified inside another file such as `test/sample-tests.txt`. Test vectors are written as `[input1, input2, output]` as shown above.
95+
All of the built-in test vectors can be verified in `npm test`. The tests will run a server automatically. These are end-to-end tests.
13896

13997
## Capabilities
14098
JIGG is designed for semi-honest parties (in either node or in the browser). We support point-and-permute, free-XOR, free single-input gates, and encryption from a random oracle (fixed-key XChaCha20). The half-AND optimization is compatible but not yet supported. The default label size is 128 bits and relies on JavaScript's Uint8Array class. The [`simple-labels`](https://github.com/wyatt-howe/jigg/tree/simple-labels) branch demonstrates dynamically-sized labels (that are 53 bits in length or less) without using arrays. Some potential improvements are listed in the to-do section.
@@ -144,9 +102,7 @@ JIGG is fully functional as it is now, but there's still more to do (see the lis
144102

145103
### To Do
146104
- Half-AND gate optimization
147-
- Standardize JSON, serialized, and compressed formats for inter-party messages
148-
- Create a single unified test suite
105+
- Standardize JSON/serialized/compressed formats for inter-party messages compatible with [SIGG](https://github.com/multiparty/sigg)
149106

150107
## Information and Collaborators
151-
152108
More information about this project, including collaborators and publications, can be found at [multiparty.org](https://multiparty.org/).

circuits/bristol/aes-128-expanded-old.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27692,4 +27692,4 @@
2769227692
2 1 1487 1540 29179 XOR
2769327693
2 1 1495 1541 29187 XOR
2769427694
2 1 1519 1542 29211 XOR
27695-
2 1 1527 1543 29219 XOR
27695+
2 1 1527 1543 29219 XOR

circuits/bristol/aes-128-non-expanded-old.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33616,4 +33616,4 @@
3361633616
2 1 264 265 33805 XOR
3361733617
2 1 266 267 33807 XOR
3361833618
2 1 268 269 257 XOR
33619-
2 1 256 257 33749 XOR
33619+
2 1 256 257 33749 XOR

0 commit comments

Comments
 (0)