You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JavaScript implementation of garbled gates and 2PC boolean circuit protocols.
3
4
4
5
## Requirements and Installation
6
+
5
7
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).
6
8
7
9
Run `npm` to install all JIGG dependencies:
@@ -12,60 +14,58 @@ npm install
12
14
## Project Layout
13
15
14
16
├─ 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
16
19
├─ demo/ Demo for client-server deployment scenario
17
20
├─ src/ Library modules implementing protocol steps for participants
18
21
│ ├─ comm/ Communications modules (such as for OT)
19
-
│ ├─ data/ Data structure modules (such as circuits)
22
+
│ ├─ modules/ Data structure modules (such as circuits)
20
23
│ └─ 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
+
23
26
27
+
## Running Demo Circuit Applications
24
28
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:
27
30
```shell
28
-
node server 3000
31
+
node demo/server.js <port number>
29
32
```
30
33
31
34
### 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.
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
49
57
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.
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/).
69
69
```ada
70
70
4 8
71
71
2 2 2
@@ -77,64 +77,22 @@ JIGG can also parse a circuit in the standardized '[Bristol](https://homes.esat.
77
77
```
78
78
79
79
### 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:
85
81
86
-
### Generating Precomputed Garbled Gates
87
-
It is possible to generate a collection of precomputed label assignments and garbled gates for each circuit.
88
82
```shell
89
-
node test/suite/generate.js
83
+
npm run casm -- <path_to_macro><output_path>
90
84
```
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.
92
85
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:
110
88
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>
119
89
```
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
123
91
```
124
92
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:
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.
138
96
139
97
## Capabilities
140
98
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
144
102
145
103
### To Do
146
104
- 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)
149
106
150
107
## Information and Collaborators
151
-
152
108
More information about this project, including collaborators and publications, can be found at [multiparty.org](https://multiparty.org/).
0 commit comments