Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating declarations #284

Merged
merged 31 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
928ffd2
Upto arrays in protocol
Snafkin547 May 2, 2024
497de7e
arithmetic done
Snafkin547 May 2, 2024
e8d62a8
All in protocols
Snafkin547 May 2, 2024
c3843fc
protocol/boolean done
Snafkin547 May 2, 2024
a0cbcd8
protocol/boolean done
Snafkin547 May 2, 2024
8ef1c99
protocol/preprocessing done
Snafkin547 May 2, 2024
e057c95
protocol/shamir done
Snafkin547 May 2, 2024
52aff46
socket completed
Snafkin547 May 2, 2024
de33e34
util done
Snafkin547 May 2, 2024
91a2ae7
client side code done
Snafkin547 May 2, 2024
ad041dd
client restful & websocket exts declaration update done
Snafkin547 May 2, 2024
67c852c
client bignum exts declaration update done
Snafkin547 May 2, 2024
0cb6ae6
client negnum exts declaration update done
Snafkin547 May 2, 2024
29917ab
client fixedp exts declaration update half-done (till make_jiff)
Snafkin547 May 2, 2024
3b987f5
client fixedp exts declaration done
Snafkin547 May 3, 2024
45bb03e
Server bigNum exts declaration done
Snafkin547 May 3, 2024
d230f58
Server restful exts declaration done
Snafkin547 May 3, 2024
ea4c952
Server websockets exts declaration done
Snafkin547 May 3, 2024
aaa371b
Server websockets exts declaration done
Snafkin547 May 3, 2024
18db2a3
server dir done for update
Snafkin547 May 3, 2024
ba3e077
jiff client & server declaration update done
Snafkin547 May 3, 2024
b68b31a
regression test declaration updated
Snafkin547 May 3, 2024
fb3fad4
api, handlers, preprocessing done reupdate let -> const
Snafkin547 May 3, 2024
44076fa
protocols done reupdate let -> const
Snafkin547 May 3, 2024
66822db
socket and extension done reupdate let -> const
Snafkin547 May 3, 2024
8954f67
Merge branch 'master' into declaration
Snafkin547 May 3, 2024
3f1d106
demos done update let -> const
Snafkin547 May 3, 2024
4e13c66
minor mistaike fixed const => let
Snafkin547 May 3, 2024
b98eeb5
minor mistaike fixed const => let
Snafkin547 May 3, 2024
93887cc
minor mistaike fixed const => let
Snafkin547 May 3, 2024
d8971f8
valentine example const -> let
Snafkin547 May 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions demos/array-binary-search/client.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
let worker = new Worker('./web-worker.js');
const worker = new Worker('./web-worker.js');

function connect(party_id) {
$('#connectButton').prop('disabled', true);
let computation_id = $('#computation_id').val();
const computation_id = $('#computation_id').val();

let options = { party_id: party_id, party_count: 2, Zp: 13 };
const options = { party_id: party_id, party_count: 2, Zp: 13 };

let hostname = window.location.hostname.trim();
let port = window.location.port;
Expand Down
14 changes: 7 additions & 7 deletions demos/array-binary-search/mpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Connect to the server and initialize the jiff instance
*/
exports.connect = function (hostname, computation_id, options) {
let opt = Object.assign({}, options);
const opt = Object.assign({}, options);
// Added options goes here
opt.crypto_provider = true;

Expand All @@ -17,7 +17,7 @@
}

// eslint-disable-next-line no-undef
let jiff_instance = new JIFFClient(hostname, computation_id, opt);
const jiff_instance = new JIFFClient(hostname, computation_id, opt);
// eslint-disable-next-line no-undef
jiff_instance.apply_extension(jiff_websockets, opt);

Expand Down Expand Up @@ -54,14 +54,14 @@
}

// comparison
let mid = Math.floor(array.length / 2);
let cmp = element.slt(array[mid]);
const mid = Math.floor(array.length / 2);
const cmp = element.slt(array[mid]);

// Slice array in half, choose slice depending on cmp
let nArray = [];
const nArray = [];
for (let i = 0; i < mid; i++) {
let c1 = array[i];
let c2 = array[mid + i];
const c1 = array[i];
const c2 = array[mid + i];
nArray[i] = cmp.if_else(c1, c2);
}

Expand Down
14 changes: 7 additions & 7 deletions demos/array-bubble-sort/client.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
let worker = new Worker('./web-worker.js');
const worker = new Worker('./web-worker.js');
function connect(party_id) {
$('#connectButton').prop('disabled', true);
var computation_id = $('#computation_id').val();
var party_count = parseInt($('#count').val());
const computation_id = $('#computation_id').val();
const party_count = parseInt($('#count').val());

if (isNaN(party_count)) {
$('#output').append("<p class='error'>Party count must be a valid number!</p>");
$('#connectButton').prop('disabled', false);
} else {
var options = { party_count: party_count };
const options = { party_count: party_count };

var hostname = window.location.hostname.trim();
var port = window.location.port;
let hostname = window.location.hostname.trim();
let port = window.location.port;
if (port == null || port === '') {
port = '80';
}
Expand Down Expand Up @@ -47,7 +47,7 @@ worker.onmessage = function (e) {
// eslint-disable-next-line no-unused-vars
function submit(party_id) {
$('#submit' + String(party_id)).attr('disabled', true);
let arr = JSON.parse(document.getElementById('inputText' + String(party_id)).value);
const arr = JSON.parse(document.getElementById('inputText' + String(party_id)).value);

for (let i = 0; i < arr.length; i++) {
if (typeof arr[i] !== 'number') {
Expand Down
16 changes: 8 additions & 8 deletions demos/array-bubble-sort/mpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Connect to the server and initialize the jiff instance
*/
exports.connect = function (hostname, computation_id, options) {
let opt = Object.assign({}, options);
const opt = Object.assign({}, options);
// Added options goes here
opt.crypto_provider = true;

Expand All @@ -17,7 +17,7 @@
}

// eslint-disable-next-line no-undef
let jiff_instance = new JIFFClient(hostname, computation_id, opt);
const jiff_instance = new JIFFClient(hostname, computation_id, opt);
// eslint-disable-next-line no-undef
jiff_instance.apply_extension(jiff_websockets, opt);

Expand All @@ -31,9 +31,9 @@
function bubblesort(arr) {
for (let i = 0; i < arr.length; i++) {
for (let j = 0; j < arr.length - i - 1; j++) {
let a = arr[j];
let b = arr[j + 1];
let cmp = a.slt(b);
const a = arr[j];
const b = arr[j + 1];
const cmp = a.slt(b);
arr[j] = cmp.if_else(a, b);
arr[j + 1] = cmp.if_else(b, a);
}
Expand All @@ -43,18 +43,18 @@
}

exports.compute = function (input, jiff_instance) {
let shares = jiff_instance.share_array(input, input.length);
const shares = jiff_instance.share_array(input, input.length);

// Sum all shared input arrays element wise
let array = shares[1];
const array = shares[1];
for (let p = 2; p <= jiff_instance.party_count; p++) {
for (let i = 0; i < array.length; i++) {
array[i] = array[i].sadd(shares[p][i]);
}
}

// Sort new array
let sorted = bubblesort(array);
const sorted = bubblesort(array);

// Open the array
return jiff_instance.open_array(sorted);
Expand Down
14 changes: 7 additions & 7 deletions demos/array-concat/client.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
let worker = new Worker('./web-worker.js');
const worker = new Worker('./web-worker.js');
function connect(party_id) {
$('#connectButton').prop('disabled', true);
var computation_id = $('#computation_id').val();
var party_count = parseInt($('#count').val());
const computation_id = $('#computation_id').val();
const party_count = parseInt($('#count').val());

if (isNaN(party_count)) {
$('#output').append("<p class='error'>Party count must be a valid number!</p>");
$('#connectButton').prop('disabled', false);
} else {
var options = { party_count: party_count };
const options = { party_count: party_count };

var hostname = window.location.hostname.trim();
var port = window.location.port;
let hostname = window.location.hostname.trim();
let port = window.location.port;
if (port == null || port === '') {
port = '80';
}
Expand Down Expand Up @@ -48,7 +48,7 @@ worker.onmessage = function (e) {
function submit(party_id) {
$('#submit' + String(party_id)).attr('disabled', true);

var _string = document.getElementById('inputText' + String(party_id)).value;
const _string = document.getElementById('inputText' + String(party_id)).value;

// eslint-disable-next-line no-undef
worker.postMessage({
Expand Down
2 changes: 1 addition & 1 deletion demos/array-concat/mpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Connect to the server and initialize the jiff instance
*/
exports.connect = function (hostname, computation_id, options) {
let opt = Object.assign({}, options);
const opt = Object.assign({}, options);
// Added options goes here
opt.crypto_provider = true;

Expand Down
16 changes: 8 additions & 8 deletions demos/array-merge-sort/client.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
let worker = new Worker('./web-worker.js');
const worker = new Worker('./web-worker.js');
function connect(party_id) {
$('#connectButton').prop('disabled', true);
var computation_id = $('#computation_id').val();
var party_count = parseInt($('#count').val());
const computation_id = $('#computation_id').val();
const party_count = parseInt($('#count').val());

if (isNaN(party_count)) {
$('#output').append('<p class="error">Party count must be a valid number!</p>');
$('#connectButton').prop('disabled', false);
} else {
var options = { party_count: party_count };
const options = { party_count: party_count };

var hostname = window.location.hostname.trim();
var port = window.location.port;
let hostname = window.location.hostname.trim();
let port = window.location.port;
if (port == null || port === '') {
port = '80';
}
Expand Down Expand Up @@ -48,7 +48,7 @@ worker.onmessage = function (e) {
function submit(party_id) {
$('#submit' + String(party_id)).attr('disabled', true);

let arr = JSON.parse(document.getElementById('inputText' + String(party_id)).value);
const arr = JSON.parse(document.getElementById('inputText' + String(party_id)).value);

// Ensure array has only numbers
for (let i = 0; i < arr.length; i++) {
Expand All @@ -62,7 +62,7 @@ function submit(party_id) {
}

// Ensure array length is a power of 2
var lg = arr.length;
let lg = arr.length;
while (lg > 1) {
if (lg % 2 !== 0) {
$('#output').append('<p class="error">Input array length must be a power of 2!</p>');
Expand Down
18 changes: 9 additions & 9 deletions demos/array-merge-sort/mpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Connect to the server and initialize the jiff instance
*/
exports.connect = function (hostname, computation_id, options) {
let opt = Object.assign({}, options);
const opt = Object.assign({}, options);
// Added options goes here
opt.crypto_provider = true;

Expand All @@ -17,7 +17,7 @@
}

// eslint-disable-next-line no-undef
let jiff_instance = new JIFFClient(hostname, computation_id, opt);
const jiff_instance = new JIFFClient(hostname, computation_id, opt);
// eslint-disable-next-line no-undef
jiff_instance.apply_extension(jiff_websockets, opt);

Expand All @@ -30,7 +30,7 @@

function oddEvenSort(a, lo, n) {
if (n > 1) {
let m = Math.floor(n / 2);
const m = Math.floor(n / 2);
oddEvenSort(a, lo, m);
oddEvenSort(a, lo + m, m);
oddEvenMerge(a, lo, n, 1);
Expand All @@ -39,7 +39,7 @@

// lo: lower bound of indices, n: number of elements, r: step
function oddEvenMerge(a, lo, n, r) {
let m = r * 2;
const m = r * 2;
if (m < n) {
oddEvenMerge(a, lo, n, m);
oddEvenMerge(a, lo + r, n, m);
Expand All @@ -57,19 +57,19 @@
return;
}

let x = a[i];
let y = a[j];
const x = a[i];
const y = a[j];

let cmp = x.lt(y);
const cmp = x.lt(y);
a[i] = cmp.if_else(x, y);
a[j] = cmp.if_else(y, x);
}

exports.compute = function (input, jiff_instance) {
let shares = jiff_instance.share_array(input, input.length);
const shares = jiff_instance.share_array(input, input.length);

// Sum all shared input arrays element wise
let array = shares[1];
const array = shares[1];
for (let p = 2; p <= jiff_instance.party_count; p++) {
for (let i = 0; i < array.length; i++) {
array[i] = array[i].sadd(shares[p][i]);
Expand Down
14 changes: 7 additions & 7 deletions demos/array-mpc-as-a-service/client-mpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
jiff_restAPI = require('../../lib/ext/jiff-client-restful.js');
}

var __jiff_instance, config, all_parties;
let __jiff_instance, config, all_parties;
exports.connect = function (hostname, computation_id, options, _config) {
config = _config;

all_parties = config.compute_parties.concat(config.input_parties);

var opt = Object.assign({}, options);
const opt = Object.assign({}, options);
opt['crypto_provider'] = config.preprocessing === false;
opt['initialization'] = { role: 'input' };
opt['party_count'] = config.party_count;
Expand All @@ -26,15 +26,15 @@
return __jiff_instance;
};
exports.compute = function (input, jiff_instance_) {
var jiff_instance = __jiff_instance;
let jiff_instance = __jiff_instance;
if (jiff_instance_) {
jiff_instance = jiff_instance_;
}

// Set up array sharing
var skeleton = jiff_instance.skeleton_of(input);
var skeletons = {};
var i, p_id;
const skeleton = jiff_instance.skeleton_of(input);
const skeletons = {};
let i, p_id;
for (i = 0; i < config.input_parties.length; i++) {
p_id = config.input_parties[i];
skeletons[p_id] = skeleton; // Assume same skeleton for all parties
Expand All @@ -46,7 +46,7 @@
// If this party is still connected after the compute parties are done, it will
// receive the result.

var promise = jiff_instance.receive_open_array(all_parties, config.compute_parties);
const promise = jiff_instance.receive_open_array(all_parties, config.compute_parties);

promise.then(function (value) {
jiff_instance.disconnect(true, true);
Expand Down
12 changes: 6 additions & 6 deletions demos/array-mpc-as-a-service/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ let worker = new Worker('./web-worker.js');
// eslint-disable-next-line no-unused-vars
function connect(party_id) {
$('#connectButton').prop('disabled', true);
var computation_id = $('#computation_id').val();
const computation_id = $('#computation_id').val();

var options = { party_count: config.party_count };
const options = { party_count: config.party_count };

var hostname = window.location.hostname.trim();
var port = window.location.port;
let hostname = window.location.hostname.trim();
let port = window.location.port;
if (port == null || port === '') {
port = '80';
}
Expand All @@ -35,14 +35,14 @@ function connect(party_id) {

// eslint-disable-next-line no-unused-vars
function submit(party_id) {
var arr = JSON.parse(document.getElementById('inputText' + String(party_id)).value);
const arr = JSON.parse(document.getElementById('inputText' + String(party_id)).value);

if (arr.length !== config.input_length) {
alert('Please input an array of length ' + config.input_length + '.');
return;
}

for (var i = 0; i < arr.length; i++) {
for (let i = 0; i < arr.length; i++) {
if (typeof(arr[i]) !== 'number') {
alert('Please input an array of integers.');
return;
Expand Down
Loading
Loading