Make sure to use the
sockets.io.js script file that matches exactly the version used in the server.
If the client code is to be served by the server, use:
If the client code is served independently, fetch the matching version of socket.io.js from a CDN, or use the file found in
Additionally, The libsodium-wrappers web-assembly library is used for fast crypto (encryption). You must include the appropriate sodium wrapper js file, if the client code is to be server by the server, use:
The libsodium-wrappers requirement can be removed as long as alternate implementation for encryption/decryption and signing is provided to JIFF through the appropriate hooks. Check out the hooks section below for additional info.
Run npm from inside the project directory to install automatically the dependencies listed in
Make sure to include the library after socket.io and libsodium:
Then inside a script tag (and after the page loads), initialize a JIFF object and set up a computation:
var instance = jiff.make_jiff("http://localhost:8080", "<computation_id>", parties)
The instance object provides methods for sharing, opening, and performing operations on shares.
Running Demos and Examples
Run a sample server from one of the demos under
demos in the following way:
node index.js demos/<demo-name>/server
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):
node demos/<demo-name>/party.js <input-value>
./node_modules/.bin/jsdoc -c docs/jsdoc.conf.json npm run-script gen-docs # shortcut
All the JIFF library test cases can be run in the following way:
Demos are accompanied by test cases. The following command can be used to run the demos servers and test cases:
npm run-script test-demo -- demo/<demo-name>
The command assumes that the server is located at demos//server.js and the test cases are located at demos//test.js See demos/run-test.sh for instructions for running test cases located in different directories or with different names.
See the testing suite framework documentation for more details on running and creating tests for the JIFF library.
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 client and server libraries support hooks. Hooks can be provided in the options parameter during instantiation or afterwards. Hooks allow the introduction of custom functionality to be executed at critical times during the computation, or the introduction of different implementations of specified primitives and operations (e.g. using a different sharing scheme).
The client-side hooks documentation provides more details. If hooks are used to provide important reusable functionality, then it is recommended to bundle these hooks within a JIFF extension.
JIFF supports implementing extensions on top of the base implementations that can provide additional extended functionality. Some extensions can be found under
lib/ext. Two important modules are implemented and provided in this repository: bignumbers and fixed point arithmetic.
See the extensions documentation and the documentation inside
src/ext/jiff-client-bignumber.js for instructions on how to create additional extensions.
Both client and server libraries support extensions. Some extensions require customizing both the server and client libraries to behave properly (such as the bignumbers extension). Other extensions may require only server- or client-side modifications (e.g., the fixed point arithmetic module is only client-side). A server that wants to participate in the computation would require only the client-side extension to use the additional functionality (unless, of course, that extension depends on additional server-side modifications, as well, as in bignumbers).
For examples on how to use an extension, see out the following files:
demos/sum-fixed/server.js: using the server with the Node bignumber.js module.
demos/sum-fixed/client.html: using fixed point arithmetic extension in the browser.
Run the bignumber test suite in the following way:
npm run-script test-bignumber
Costs of Operations:
Below is a table of the current costs of operations in the base jiff with no extensions:
|Operation||Rounds||Total Messages||Preprocessing Rounds||Preprocessing Total Messages||Dependenices|
|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<|
Some exact costs not shown in the table:
- 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)
- 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)
- 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)
- 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) )
- 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)))
- Multiplication has one message to synchronize beaver triplets and one open in sequence.
- inequality tests has 3 less than half primes in parallel, each has an open and as many multiplication in sequence as bits.
- constant inequality test has 2 less than half primes in parallel.
- equality and constant equality tests have 2 inequalities in parallel, sequenced with a multiplication.
- division has as many sequential iterations as bits, each iteration contains a constant inequality, secret inequality, and multiplication.
- constant division has one open sequenced with 4 parallel constant inequality checks and two multiplications.
- 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.