Skip to content

Commit

Permalink
prettier applied
Browse files Browse the repository at this point in the history
  • Loading branch information
Snafkin547 committed Mar 27, 2024
1 parent 12b5534 commit ba9ce1a
Show file tree
Hide file tree
Showing 166 changed files with 68,534 additions and 48,339 deletions.
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ coverage
demos
.circleci
.github
.travis.yml
.travis.yml
CONTRIBUTING.md
6 changes: 5 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
{}
{
"printWidth": 200,
"singleQuote": true,
"trailingComma": "none"
}
59 changes: 38 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ You can use browserify or similar tools to require JIFF via npm and bundle it wi
## Installation

Add JIFF as a dependency to your project:

```shell
npm install jiff-mpc
```
Expand All @@ -29,6 +30,7 @@ npm install jiff-mpc

After installing JIFF via npm, you can require the server module in your server
code using:

```javascript
const { JIFFServer } = require('jiff-mpc');

Expand All @@ -40,6 +42,7 @@ http.listen(port, cb);
```

Similarly, you can require the client module in your node.js clients using:

```javascript
const { JIFFClient } = require('jiff-mpc');

Expand All @@ -55,15 +58,18 @@ let shares = jiffClient.share(<secret>);

To use our bundle, include the provided pre-built JS file in a script tag. Make sure
that you set up your web-server to serve this JS file.

```html
<!-- exposes JIFFClient to the global scope -->
<script src="/dist/jiff-client.js"></script>
```

Then inside a script tag (and after the page loads), initialize a JIFF object and set up a computation:

```javascript
const jiffClient = new JIFFClient("<server address>", "<computation_id>", <options>);
```

The jiffClient object provides methods for sharing, opening, and performing operations on shares.

Alternatively, you can use the same code for both Node.js and browser-based clients, using tools
Expand Down Expand Up @@ -135,30 +141,34 @@ Each document is an independent tutorial. However, beginners are encouraged to v
## Running Demos and Examples

Run a sample server from one of the demos under `demos` in the following way:

```shell
node demos/<demo-name>/server.js
```

The output from the example server will direct you to open `localhost:8080/demos/<demo-name>/client.html` in a browser (you must open
an instance in a separate window/tab for every distinct party participating in the protocol).
You can then proceed with the protocol using the client interfaces.

Note that you can run Node.js parties that can also participate in the protocol by executing (e.g., a separate terminal for each party):

```shell
node demos/<demo-name>/party.js <input-value>
```

## Documentation

The latest documentation can be viewed on the [project page](https://multiparty.org/jiff/). The documentation can be generated using [JSDoc](http://usejsdoc.org/); you will find these docs in `docs/jsdocs/`:

```shell
./node_modules/.bin/jsdoc -r -c docs/jsdoc.conf.json
npm run-script gen-docs # shortcut
```

### Where to Look in the Docs

The documentation for the client side library is separated into the distinct modules, namespaces, and classes:


├─ modules
│ └─ jiff-client Parent module: represents the exposed JIFFClient global variable
├─ classes
Expand All @@ -174,14 +184,17 @@ The documentation for the client side library is separated into the distinct mod
## Running Tests

All of the JIFF library test cases can be run in the following way:

```shell
npm test
```

Demos are accompanied by test cases. The following command can be used to run the demo servers and test cases:

```shell
npm run-script test-demo -- demos/<demo-name>
```

The command assumes that the server is located at demos/<demo-name>/server.js and the test cases are located at demos/<demo-name>/test.js
See demos/run-test.sh for instructions on running test cases located in different directories or with different names.

Expand All @@ -190,13 +203,14 @@ See the [testing suite framework documentation](tests/suite/README.md) for more
## Bundling

If you made changes to the library and would like to bundle it again into a single browser-friendly file, you can run this command:

```shell
npm run-script build # will override dist/jiff-client.js
```

## Development

The JIFF libraries allow developers to customize or extend their functionality by introducing new *hooks*. Multiple hooks can be combined to form a library *extension*.
The JIFF libraries allow developers to customize or extend their functionality by introducing new _hooks_. Multiple hooks can be combined to form a library _extension_.

### Hooks

Expand All @@ -218,11 +232,13 @@ For examples on how to use an extension, see the following files:
2. `demos/sum-fixed/client.html`: using fixed point arithmetic extension in the browser.

Run the bignumber test suite in the following way:

```shell
npm run-script test-bignumber
```

## How to Contribute

Check out our contribution guidelines and resources @ [contributing](CONTRIBUTING.md).

# For Cryptographers
Expand All @@ -242,33 +258,35 @@ reduces to more traditional models in certain cases. For example, if the computa
equivalent to 3-party computation with honest majority.

## Costs of Operations: [OUTDATED]
Below is a table of the current costs of operations in the *base* JIFF without extensions:


| Operation | Rounds | Total Messages | Preprocessing Rounds | Preprocessing Total Messages | Dependencies |
|-------------------|-------------------|-----------------------------------|----------------------|----------------------------------------------|--------------|
| Share | 1 | senders \* receivers | 0 | 0 | N/A |
| Open | 2 | sender + sender \* receivers | 1 | senders \* senders | N/A |
| +, -, c+, c-, c\* | 0 | 0 | 0 | 0 | N/A |
| \* | 2 | 2\*parties + parties\*(parties-1) | 2 | 2 \* (parties \* parties - 1) | triplet,open |
| <, <=, >, >= | 2\*(bits+3) | O( bits \* parties^2 ) | 3 | bits \* (2\*parties + parties^2) | \*, open |
| c<, c<=, c>, c>= | 2\*(bits+3) | O( bits \* parties^2 ) | 3 | bits \* (2\*parties + parties^2) | \*, open |
| =, c=, !=, c!= | 2\*(bits+4) | O( bits \* parties^2 ) | 3 | 2\*bits \* (2\*parties + parties^2) | c<, c>, \* |
| / | bits^2 + 5\*bits | O( bits^2 \* parties^2 ) | 3 | bits\*(2\*bits \* (2\*parties + parties^2)) | <, c<, \* |
| c/ | 2\*(bits+3) + 5 | O( bits \* parties^2 ) | 3 | 4 \* bits \* (2\*parties + parties^2) | open, \*, c< |
| bits+ | 8\*bits | O( parties^2 \* bits ) | 2 | 8 \* bits \* (parties \* parties - 1) | triplet,open |
| bits- | 8\*bits | O( parties^2 \* bits ) | 2 | 8 \* bits \* (parties \* parties - 1) | triplet,open |
| bits* | 12\*bits | O( parties^4 \* bits^2 ) | 2 | 12 \* bits^2 \* (parties \* parties - 1)^2 | triplet,open |
| bits/ | 25\*bits^2 | O( parties^2 \* bits^2 ) | 2 | 25 \* bits^2 \* (parties \* parties - 1) | triplet,open |

Below is a table of the current costs of operations in the _base_ JIFF without extensions:

| Operation | Rounds | Total Messages | Preprocessing Rounds | Preprocessing Total Messages | Dependencies |
| ----------------- | ---------------- | --------------------------------- | -------------------- | ------------------------------------------- | ------------ |
| Share | 1 | senders \* receivers | 0 | 0 | N/A |
| Open | 2 | sender + sender \* receivers | 1 | senders \* senders | N/A |
| +, -, c+, c-, c\* | 0 | 0 | 0 | 0 | N/A |
| \* | 2 | 2\*parties + parties\*(parties-1) | 2 | 2 \* (parties \* parties - 1) | triplet,open |
| <, <=, >, >= | 2\*(bits+3) | O( bits \* parties^2 ) | 3 | bits \* (2\*parties + parties^2) | \*, open |
| c<, c<=, c>, c>= | 2\*(bits+3) | O( bits \* parties^2 ) | 3 | bits \* (2\*parties + parties^2) | \*, open |
| =, c=, !=, c!= | 2\*(bits+4) | O( bits \* parties^2 ) | 3 | 2\*bits \* (2\*parties + parties^2) | c<, c>, \* |
| / | bits^2 + 5\*bits | O( bits^2 \* parties^2 ) | 3 | bits\*(2\*bits \* (2\*parties + parties^2)) | <, c<, \* |
| c/ | 2\*(bits+3) + 5 | O( bits \* parties^2 ) | 3 | 4 \* bits \* (2\*parties + parties^2) | open, \*, c< |
| bits+ | 8\*bits | O( parties^2 \* bits ) | 2 | 8 \* bits \* (parties \* parties - 1) | triplet,open |
| bits- | 8\*bits | O( parties^2 \* bits ) | 2 | 8 \* bits \* (parties \* parties - 1) | triplet,open |
| bits\* | 12\*bits | O( parties^4 \* bits^2 ) | 2 | 12 \* bits^2 \* (parties \* parties - 1)^2 | triplet,open |
| bits/ | 25\*bits^2 | O( parties^2 \* bits^2 ) | 2 | 25 \* bits^2 \* (parties \* parties - 1) | triplet,open |

Some exact costs not shown in the table:

1. Exact total number of messages for secret inequalities is: 3\*(parties + parties^2 + (bits+1) \* (2\*parties + parties\*(parties-1))) + 2\*parties + parties\*(parties-1)
2. Exact total number of messages for constant inequalities is: 2\*(parties + parties^2 + (bits+1) \* (2\*parties + parties\*(parties-1))) + 2\*parties + parties\*(parties-1)
3. Exact total number of messages for equality checks: 2\*(\*(parties + parties^2 + (bits+1) \* (2\*parties + parties\*(parties-1))) + 2\*parties + parties\*(parties-1)) + 2\*parties + parties\*(parties-1)
4. Exact total number of messages for division is: bits \* ( 5\*(parties + parties^2 + (bits+1) \* (2\*parties + parties\*(parties-1))) + 2\*parties + parties\*(parties-1) + 2\*parties + parties\*(parties-1) )
5. Exact total number of messages for constant division is: 1 + 7\*parties + 4\*parties^2 + 8\*(parties + parties^2 + (bits+1) \* (2\*parties + parties\*(parties-1)))

Dependencies:

1. Multiplication has one message to synchronize beaver triplets and one open in sequence.
2. inequality tests has 3 less than half primes in parallel, each has an open and as many multiplication in sequence as bits.
3. constant inequality test has 2 less than half primes in parallel.
Expand All @@ -277,7 +295,6 @@ Dependencies:
6. constant division has one open sequenced with 4 parallel constant inequality checks and two multiplications.
7. Secret XORs and ORs are equivalent to a single multiplication, constant XORs and ORs are free.


## Information and Collaborators

More information about this project, including collaborators and publications, can be found at [multiparty.org](https://multiparty.org/).
Loading

0 comments on commit ba9ce1a

Please sign in to comment.