new JIFFClient(hostnamenon-null, computation_idnon-null, optionsopt, nullable)
- Description:
Creates a new jiff client instance.
- Source:
Example
var JIFFClient = require('jiffClient'); // only for node.js
<script src="jiff-client.js"></script> // for the browser
// build a jiff instance which will connect to a server running on the local machine
var instance = new JIFFClient('http://localhost:8080', 'computation-1', {party_count: 2});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
hostname |
string | server hostname/ip and port. |
||
computation_id |
string | the id of the computation of this instance. |
||
options |
object |
<optional> <nullable> |
{}
|
javascript object with additional options. all parameters are optional, However, private and public key must either be both provided or neither of them provided. { "party_id": number, "party_count": number, "secret_key": Uint8Array to be used with libsodium-wrappers (check Library Specs), "public_key": Uint8Array to be used with libsodium-wrappers (check Library Specs), "public_keys": { 1: "Uint8Array PublicKey", 2: "Uint8Array PublicKey", ... }, "Zp": default mod to use (prime number), "autoConnect": true/false, "hooks": { 'check out hooks documentation' }, "listeners" : A map from custom tags to listeners (of type function(sender_id, message_string)) that handle custom messages with that tag. "onConnect": function(jiff_instance), "onError": function(label, error): called when errors occured in client code or during handling requests from this client at the server side label is a string indicating where the error occured, and error is a string or an exception object. "safemod": boolean (whether or not to check if provided Zp is prime, may be slow for big primes, defaults to false), "crypto_provider": a boolean that flags whether to get beaver triplets and other preprocessing entities from the server (defaults to false), "socketOptions": an object, passed directly to socket.io constructor, "sodium": boolean, if false messages between clients will not be encrypted (useful for debugging), "maxInitializationRetries": how many consecutive times to retry to initialize with the server if initialization fails, defaults to 2, "preprocessingBatchSize": how many base level preprocessing tasks to execute in parallel. } |
Classes
Members
(non-null) __initialized :boolean
- Description:
Private. Do not use directly externally; use isInitialized() instead.
- Source:
- See:
Private. Do not use directly externally; use isInitialized() instead.
Type:
- boolean
(non-null) __ready :boolean
- Description:
Private. Do not use directly externally; use isReady() instead.
- Source:
- See:
Private. Do not use directly externally; use isReady() instead.
Type:
- boolean
(non-null) barriers :object
- Description:
Stores all promises created within some barrier.
- Source:
Stores all promises created within some barrier.
Type:
- object
(non-null) computation_id :string
- Description:
Stores the computation id.
- Source:
Stores the computation id.
Type:
- string
(non-null) counters :object
- Description:
Store sharing and shares counter which keeps track of the count of sharing operations (share and open) and the total number of shares respectively (used to get a unique id for each share operation and share object).
- Source:
Store sharing and shares counter which keeps track of the count of sharing operations (share and open) and the total number of shares respectively (used to get a unique id for each share operation and share object).
Type:
- object
(non-null) crypto_provider :boolean
- Description:
Flags whether to use the server as a fallback for objects that were not pre-processed properly
- Source:
Flags whether to use the server as a fallback for objects that were not pre-processed properly
Type:
- boolean
(non-null) currentPreprocessingTasks :linkedlist
- Description:
Stores currently executing preprocessing tasks.
- Source:
Stores currently executing preprocessing tasks.
Type:
- linkedlist
(non-null) custom_messages_mailbox :object
- Description:
Stores custom messages that are received before their listeners are set. Messages are stored in order. { 'tag' => [ { "sender_id": <sender_id>, "message":
}, ... ] } Once a listener has been set, the corresponding messages are sent to it in order.
- Source:
Stores custom messages that are received before their listeners are set. Messages are stored in order.
{ 'tag' => [ { "sender_id": <sender_id>, "message":
Once a listener has been set, the corresponding messages are sent to it in order.
Type:
- object
(non-null) default_preprocessing_protocols :object
- Description:
Store the default preprocessing protocols for each type of preprocessing value
- Source:
Store the default preprocessing protocols for each type of preprocessing value
Type:
- object
(non-null) deferreds :object
- Description:
A map from some message operation id to a deferred resolved when that message is received.
- Source:
A map from some message operation id to a deferred resolved when that message is received.
Type:
- object
extensions :Array.<string>
- Description:
An array containing the names (jiff-client-[name].js) of the extensions that are applied to this instance.
- Source:
An array containing the names (jiff-client-[name].js) of the extensions that are applied to this instance.
Type:
- Array.<string>
(non-null) handlers :handlers
- Description:
Contains handlers for communication events
- Source:
Contains handlers for communication events
Type:
(non-null) helpers :helpers
- Description:
Helper functions [DO NOT MODIFY UNLESS YOU KNOW WHAT YOU ARE DOING].
- Source:
Helper functions [DO NOT MODIFY UNLESS YOU KNOW WHAT YOU ARE DOING].
Type:
(non-null) hooks :hooks
- Description:
The hooks for this instance. Checkout the hooks documentation
- Source:
The hooks for this instance. Checkout the hooks documentation
Type:
(non-null) hostname :string
- Description:
The server hostname, ends with a slash, includes port and protocol (http/https).
- Source:
The server hostname, ends with a slash, includes port and protocol (http/https).
Type:
- string
id :number
- Description:
The id of this party.
- Source:
The id of this party.
Type:
- number
(non-null) initialization_counter :number
- Description:
Counts how many times JIFF attempted to initialize with the server without success consecutively.
- Source:
Counts how many times JIFF attempted to initialize with the server without success consecutively.
Type:
- number
(non-null) keymap :object
- Description:
A map from party id to public key. Where key is the party id (number), and value is the public key, which by default follows libsodium's specs (Uint8Array).
- Source:
- See:
A map from party id to public key. Where key is the party id (number), and value is the public key, which by default follows libsodium's specs (Uint8Array).
Type:
- object
(non-null) listeners :object
- Description:
A map from tags to listeners (functions that take a sender_id and a string message).
Stores listeners that are attached to this JIFF instance, listeners listen to custom messages sent by other parties.
- Source:
A map from tags to listeners (functions that take a sender_id and a string message).
Stores listeners that are attached to this JIFF instance, listeners listen to custom messages sent by other parties.
Type:
- object
(non-null) logs :Array
- Description:
Used for logging/debugging
- Source:
Used for logging/debugging
Type:
- Array
messagesWaitingKeys :object
- Description:
Stores messages that are received with a signature prior to acquiring the public keys of the sender. { 'party_id': [ { 'label': 'share/open/custom',
} ] }
- Source:
Stores messages that are received with a signature prior to acquiring the public keys of the sender.
{ 'party_id': [ { 'label': 'share/open/custom',
Type:
- object
op_id_seed :string
- Description:
A prefix attached to all op_ids, can be changed using seed_ids to guarantee uniqueness of auto generate ids in a user-side callback or event handler.
- Source:
- See:
A prefix attached to all op_ids, can be changed using seed_ids to guarantee uniqueness of auto generate ids in a user-side callback or event handler.
Type:
- string
(non-null) options :Object
- Description:
Shallow copy of the options passed to the constructor.
- Source:
Shallow copy of the options passed to the constructor.
Type:
- Object
party_count :number
- Description:
Total party count in the computation, parties will take ids between 1 to party_count (inclusive).
- Source:
Total party count in the computation, parties will take ids between 1 to party_count (inclusive).
Type:
- number
(non-null) preprocessing_function_map :object
- Description:
maps all primitive operations to the other operations they are dependent on, until leaves are primitives for which preprocessing protocols are defined, this map is traversed during preprocessing to guide preprocessing of high level operations. Extensions should modify this map to reflect any required changes to preprocessing of modified primitives
- Source:
maps all primitive operations to the other operations they are dependent on, until leaves are primitives for which preprocessing protocols are defined, this map is traversed during preprocessing to guide preprocessing of high level operations. Extensions should modify this map to reflect any required changes to preprocessing of modified primitives
Type:
- object
(non-null) preprocessing_table :object
- Description:
Stores pre-computed values (beaver triples, random bits, etc) used to aid/speed up the main processes.
- Source:
Stores pre-computed values (beaver triples, random bits, etc) used to aid/speed up the main processes.
Type:
- object
(non-null) preprocessingBatchSize :Number
- Description:
Sets batch size for base level preprocessing tasks
- Source:
Sets batch size for base level preprocessing tasks
Type:
- Number
(nullable) preprocessingCallback :function
- Description:
Callback to execute when preprocessing is done!
- Source:
Callback to execute when preprocessing is done!
Type:
- function
(non-null) protocols :protocols
- Description:
A collection of useful protocols to be used during computation or preprocessing: extensions are encouraged to add useful common protocols here, under a sub namespace corresponding to the extension name.
- Source:
A collection of useful protocols to be used during computation or preprocessing: extensions are encouraged to add useful common protocols here, under a sub namespace corresponding to the extension name.
Type:
(nullable) public_key :Uint8Array
- Description:
The public key of this party, by default this follows libsodium's specs.
- Source:
- See:
The public key of this party, by default this follows libsodium's specs.
Type:
- Uint8Array
(nullable) secret_key :Uint8Array
- Description:
The secret key of this party, by default this follows libsodium's specs.
- Source:
- See:
The secret key of this party, by default this follows libsodium's specs.
Type:
- Uint8Array
(non-null) share_helpers :object
- Description:
Internal helpers for operations inside/on a share. Modify existing helpers or add more in your extensions to avoid having to re-write and duplicate the code for primitives.
- Source:
Internal helpers for operations inside/on a share. Modify existing helpers or add more in your extensions to avoid having to re-write and duplicate the code for primitives.
Type:
- object
(non-null) shares :object
- Description:
A map from open operation id to the corresponding shares received for that open operation
- Source:
A map from open operation id to the corresponding shares received for that open operation
Type:
- object
(nullable) sodium_ :sodium
- Description:
sodium wrappers either imported via require (if in nodejs) or from the bundle (in the browser). This will be false if options.sodium is false.
- Source:
- See:
sodium wrappers either imported via require (if in nodejs) or from the bundle (in the browser). This will be false if options.sodium is false.
Type:
- sodium
(non-null) utils :utils
- Description:
Utility functions
- Source:
Utility functions
Type:
(non-null) wait_callbacks :Array
- Description:
Stores the parties and callbacks for every .wait_for() registered by the user.
- Source:
Stores the parties and callbacks for every .wait_for() registered by the user.
Type:
- Array
(non-null) Zp :number
- Description:
The default Zp for this instance.
- Source:
The default Zp for this instance.
Type:
- number
Methods
add_to_barriers(promise)
- Description:
Adds given promise to all active barriers.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
promise |
promise | the promise to add. |
apply_extension(ext, optionsopt)
- Description:
Applies the given extension. If the extension is safe (as per can_apply_extension), it will be applied successfully. If the extension is not safe to be applied, an exception will be thrown with an appropriate error message.
- Source:
- See:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
ext |
object | the namespace of the extension acquired when the extension is imported, should contain a make_jiff function. |
||
options |
object |
<optional> |
{}
|
optional options to be passed to the extension. |
can_apply_extension(name) → {boolean}
- Description:
Checks if a given extension can be safely applied to the instance
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string | the extension name (found in the filename at jiff-client[name].js) |
Returns:
true if the extension can be safely applied, otherwise returns an error message.
- Type
- boolean
connect()
- Description:
Connect to the server and starts listening.
- Source:
disconnect(safeopt, freeopt, callbackopt)
- Description:
Disconnects from the computation. Allows the client program to exit.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
safe |
boolean |
<optional> |
false
|
if true, jiff will disconnect safely (i.e. after ensuring all outgoing pending messages were delivered). |
free |
boolean |
<optional> |
false
|
if set to true, it means this party's disconnection is final, and all resources associated with this party must be freed. If all parties in a computation are freed, then all resources associated with the computation are freed, and any subsequent reconnection to the computation is as if a the connection is for a fresh new computation. |
callback |
function |
<optional> |
executed after the instance safely disconnects, if safe is set to false, this parameter is ignored. |
emit(tag, receiversopt, message, encryptopt)
- Description:
Sends a custom message to a subset of parties
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
tag |
string | the tag to attach to the message |
||
receivers |
Array |
<optional> |
all_parties
|
contains the party ids to receive the message, defaults to all parties |
message |
string | the message to send |
||
encrypt |
boolean |
<optional> |
true
|
if true, messages will be encrypted |
end_barrier(barrier_idopt) → {promise}
- Description:
Executes the callback only after all promises / secret shares in the barrier were resolved.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
barrier_id |
number |
<optional> |
jiff.barriers.length - 1
|
identifies the barrier, should be returned by start_barrier. by default, barrier_id will refer to the last barrier. |
Returns:
a promise that resolves after the secret shares are resolved.
- Type
- promise
executePreprocessing(callbacknon-null)
- Description:
Ask JIFF to start executing preprocessing for tasks previously added by preprocessing.
Calls the provided callback when the preprocessing tasks are all done.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | the callback to execute when preprocessing is finished. preprocessing |
extension_applied(name, optionsopt)
- Description:
Called when an extension is applied successfully. Override to change behavior of your extension based on future extensions.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
string | the name of the applied extension. |
||
options |
object |
<optional> |
{}
|
the options passed by the user to the newly applied extension. |
free()
- Description:
Emits event to free up all the resources allocated for this party on the server. It is best not to call this function directly, as it can break things if resources still need to be used. Instead, use jiff.disconnect(safe, free, callback) to free after safely disconnecting.
- Source:
- See:
from_crypto_provider(label, receivers_listopt, thresholdopt, Zpopt, op_idopt, paramsopt) → {promise}
- Description:
Requests secret(s) from the server (crypto provider) of type matching the given label.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
label |
string | the type of secret(s) being requested from crypto_provider (e.g. triplet, quotient, numbers, etc) |
||
receivers_list |
Array |
<optional> |
all_parties
|
array of party ids that want to receive the secret(s), by default, this includes all parties. |
threshold |
number |
<optional> |
receivers_list.length
|
the min number of parties needed to reconstruct the secret(s). |
Zp |
number |
<optional> |
jiff_instance.Zp
|
the mod, defaults to the Zp of the instance. |
op_id |
string |
<optional> |
auto_Gen()
|
an id which is used to identify the secret requested, so that every party gets a share from the same secret for every matching instruction. An automatic id is generated by increasing a local counter per label, default ids suffice when all parties execute all instructions in the same order. |
params |
object |
<optional> |
{}
|
any additional parameters specific to the label, these are defined by the label handler at the server side. some of these parameters may be optional, while others may be required. |
Returns:
a promise to the secret(s) provided by the server/crypto provider, the promise returns an object with the given format:
{ values:
- Type
- promise
gen_op_id(op, holders) → {string}
- Description:
Generate a unique operation id for a new operation object. The returned op_id will be unique with respect to other operations, and identifies the same operation across all parties, as long as all parties are executing instructions in the same order.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
op |
string | the type/name of operation performed. |
holders |
Array | an array containing the ids of all the parties carrying out the operation. |
Returns:
the op_id for the operation.
- Type
- string
gen_op_id2(op, receivers, senders) → {string}
- Description:
Generate a unique operation id for a new operation object given two distinct executing parties lists. For example, when sharing, this is given two potentially different lists of senders and receivers. The returned op_id will be unique with respect to other operations, and identifies the same operation across all parties, as long as all parties are executing instructions in the same order.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
op |
string | the type/name of operation performed. |
receivers |
Array | an array containing the ids of all the parties carrying out the receiving portion of the operation. |
senders |
Array | an array containing the ids of all the parties carrying out the sending portion of the operation. |
Returns:
the op_id for the operation.
- Type
- string
gen_op_id2_preprocessing(op, receivers, senders) → {string}
- Description:
Generate a unique operation id for a new operation object given two distinct executing parties lists (for preprocessing). For example, when sharing, this is given two potentially different lists of senders and receivers. The returned op_id will be unique with respect to other operations, and identifies the same operation across all parties, as long as all parties are executing instructions in the same order.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
op |
string | the type/name of operation performed. |
receivers |
Array | an array containing the ids of all the parties carrying out the receiving portion of the operation. |
senders |
Array | an array containing the ids of all the parties carrying out the sending portion of the operation. |
Returns:
the op_id for the operation.
- Type
- string
gen_op_id_preprocessing(op, holders) → {string}
- Description:
Generate a unique operation id for a new operation object (for preprocessing) The returned op_id will be unique with respect to other operations, and identifies the same operation across all parties, as long as all parties are executing instructions in the same order.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
op |
string | the type/name of operation performed. |
holders |
Array | an array containing the ids of all the parties carrying out the operation. |
Returns:
the op_id for the operation.
- Type
- string
get_preprocessing(op_id) → {object}
- Description:
Get a preprocessed share/value by associated op_id. If value does not exist Fallback to some user specified way for creating it
- Source:
Parameters:
Name | Type | Description |
---|---|---|
op_id |
string | the op_id associated with the preprocessed value/share |
Returns:
the preprocessed share(s)
- Type
- object
has_extension(name) → {boolean}
- Description:
Checks if the given extension is applied.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string | the extension name (found in the extension filename as jiff-client-[name].js). |
Returns:
true if the extension was applied, false otherwise.
- Type
- boolean
has_preprocessing(op) → {boolean}
- Description:
Checks if the given operation uses preprocessed values
- Source:
Parameters:
Name | Type | Description |
---|---|---|
op |
string | name of the operation to check |
Returns:
true if the op uses preprocessing, false otherwise
- Type
- boolean
internal_open()
- Description:
Same as open, but used by internal JIFF primitives/protocols, do not override this!
- Source:
- See:
internal_share()
- Description:
Same as share, but used by internal JIFF primitives/protocols, do not override this!
- Source:
- See:
isInitialized() → (non-null) {boolean}
- Description:
Returns whether this instance initialized successfully with the server. Note that this can be true even when isReady() returns false, in case where some other parties have not initialized yet!
- Source:
Returns:
- Type
- boolean
isReady() → (non-null) {boolean}
- Description:
Returns whether this instance is capable of starting the computation. In other words, the public keys for all parties and servers are known, and this party successfully initialized with the server.
- Source:
Returns:
- Type
- boolean
listen(tag, handler)
- Description:
Registers the given function as a listener for messages with the given tag. Removes any previously set listener for this tag.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
tag |
string | the tag to listen for. |
handler |
function | the function that handles the received message: takes the sender id and the message as parameters. |
open(share, partiesopt, op_idopt) → (nullable) {promise}
- Description:
Open a secret share to reconstruct secret.
- Source:
Example
var shares = jiff_instance.share(input);
//multiply the inputs of party 1 and 2 together
var result = shares[1].mult(shares[2]);
// reveal the result of the multiplication to all parties
return jiff_instance.open(result);
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
share |
SecretShare | this party's share of the secret to reconstruct. |
||
parties |
Array |
<optional> |
all_parties
|
an array with party ids (1 to n) of receiving parties. |
op_id |
string | number |
<optional> |
auto_gen()
|
the operation id to be used to tag outgoing messages. |
Returns:
a (JQuery) promise to the open value of the secret, null if the party is not specified in the parties array as a receiver.
- Type
- promise
open_array(shares, partiesopt, op_idsopt) → {promise}
- Description:
Opens an array of secret shares.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
shares |
Array.<SecretShare> | an array containing this party's shares of the secrets to reconstruct. |
||
parties |
Array.<(number|string|Array)> |
<optional> |
all_parties
|
an array with party ids of receiving parties. This must be one of 3 cases: 1. null: open all shares to all parties. 2. array of numbers: open all shares to all the parties specified in the array. 3. array of array of numbers: open share with index i to the parties specified in the nested array at parties[i]. if parties[i] was null, then shares[i] will be opened to all parties. |
op_ids |
string | number | object |
<optional> |
auto_gen()
|
an optional mapping that specifies the ID/Tag associated with each open message sent. Since open_array involves sending many messages per party, this parameter only specifies the BASE OPERATION ID. Each message sent will have this base id attached to it concatenated to a counter. If this is an object, then it should map an id of a receiving parties to the base op_id that should be used to tag the messages sent to that party. Parties left unmapped by this object will get an automatically generated id. If this is a number/string, then it will be used as the base id tagging all messages sent by this open to all parties. You can safely ignore this unless you have multiple opens each containing other opens. In that case, the order by which these opens are executed is not fully deterministic and depends on the order of arriving messages. In this case, use this parameter with every nested_open, to ensure ids are unique and define a total ordering on the execution of the opens (check implementation of slt for an example). |
Throws:
error if some shares does not belong to the passed jiff instance.
Returns:
a (JQuery) promise to ALL the open values of the secret, the promise will yield a 2D array of values, each corresponding to the given share in the shares parameter at the same index. In the case where different values are opened to different parties, the order of the values will be preserved, but not the indices, there will be no blanks in the resulting arrays, the first share that is opened to this party will appear at index [0], even if it was not initially at [0].
- Type
- promise
open_ND_array(shares, partiesopt, op_idsopt) → {promise}
- Description:
Opens an n-dimensional array of secret shares.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
shares |
SecretShare | Array.<SecretShare> | Array.<Array.<SecretShare>> | an n-dimensional array containing this party's shares of the secrets to reconstruct. |
||
parties |
Array.<Array> |
<optional> |
all_parties
|
an array with party ids (1 to n) of receiving parties. |
op_ids |
string | number | object |
<optional> |
auto_gen()
|
an optional ID/Tag associated with these open operations |
Throws:
error if some shares does not belong to the passed jiff instance.
Returns:
a (JQuery) promise to ALL the open values of the secret, the promise will yield an n-dimensional array of values, each corresponding to the given share in the shares parameter at the same index. In the case where different values are opened to different parties, the order of the values will be preserved, but not the indices, there will be no blanks in the resulting arrays, the first share that is opened to this party will appear at indices [0][0], even if it was not initially at [0][0].
- Type
- promise
preprocessing(dependent_op, countopt, protocolsopt, thresholdopt, receivers_listopt, compute_listopt, Zpopt, id_listopt, paramsopt) → {promise}
- Description:
Generate values used for JIFF operations in advance of the computation.
Calling this function does not begin preprocessing, it just creates a preprocessing task. After you created your desired tasks, you can ask JIFF to execute them via executePreprocessing.
- Source:
- See:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
dependent_op |
string | name of the operation that will later use the pre_processed values |
||
count |
Number |
<optional> |
1
|
number of times the protocol should be performed, number of values that will be generated |
protocols |
Object |
<optional> |
defaults
|
a mapping from base preprocessing elements ('beaver', 'bits', 'sampling') to functions that can pre-process them the function must implement the same interface as the JIFF provided protocols (e.g. jiffClient.protocols.generate_beaver_bgw), missing mappings indicate that JIFF must use the default protocols |
threshold |
Number |
<optional> |
receivers_list.length
|
the threshold of the preprocessed shares |
receivers_list |
Array |
<optional> |
all_parties
|
the parties that will receive the preprocsssed shares |
compute_list |
Array |
<optional> |
all_parties
|
the parties that will compute the preprocsssed shares |
Zp |
Number |
<optional> |
jiffClient.Zp
|
the Zp of the preprocessed shares |
id_list |
Array |
<optional> |
auto_gen()
|
array of ids to be used sequentially to identify the pre_processed values |
params |
Object |
<optional> |
{}
|
any additional protocol-specific parameters |
Returns:
a promise that is resolved when preprocessing is completed, null if this is called by a party that is neither a compute nor receiver party
- Type
- promise
preprocessingDaemon()
- Description:
Preprocessing Daemon that executes all currently scheduled preprocessing tasks (entries in jiffClient.currentPreprocessingTasks array) in order.
- Source:
receive_open(senders, receiversopt, thresholdopt, Zpopt, op_idopt) → (non-null) {promise}
- Description:
Receive shares from the specified parties and reconstruct their secret. Use this function in a party that will receive some answer/value but does not have a share of it.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
senders |
Array | an array with party ids (1 to n) specifying the parties sending the shares, this must be provided! |
||
receivers |
Array |
<optional> |
all_parties
|
an array with party ids (1 to n) specifying the parties receiving the result |
threshold |
number |
<optional> |
senders.length
|
the min number of parties needed to reconstruct the secret, defaults to all the senders |
Zp |
number |
<optional> |
jiff_instance.Zp
|
the mod (if null then the default Zp for the instance is used) |
op_id |
string | number |
<optional> |
auto_Gen()
|
same as jiff-instance.open |
Returns:
a (JQuery) promise to the open value of the secret.
- Type
- promise
receive_open(senders, thresholdopt, Zpopt, op_idopt) → (non-null) {promise}
- Description:
Receive arrays of shares from the specified parties and reconstruct their secrets. Use this function in a party that will receive some answer/value but does not have a share of it.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
senders |
Array | an array with party ids (1 to n) specifying the parties sending the shares, this must be provided! |
||
threshold |
number |
<optional> |
senders.length
|
the min number of parties needed to reconstruct the secret, defaults to all the senders |
Zp |
number |
<optional> |
jiff_instance.Zp
|
the mod (if null then the default Zp for the instance is used) |
op_id |
string | number |
<optional> |
auto_Gen()
|
same as jiff-instance.open |
Returns:
a (JQuery) promise to the open value of the secret.
- Type
- promise
remove_listener(tag)
- Description:
Removes the custom message listener attached to the given tag
- Source:
Parameters:
Name | Type | Description |
---|---|---|
tag |
string | the tag of the listener to remove |
reshare(shareopt, thresholdopt, receivers_listopt, senders_listopt, Zpopt, op_idopt) → {SecretShare}
- Description:
re-share an existing share (value) under a new threshold or to a new set of parties or both. Do not use this to refresh a share (use refresh instead)
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
share |
SecretShare |
<optional> |
null
|
the share you would like to reshare (null if you are a receiver but not a sender) |
threshold |
number |
<optional> |
receivers_list.length
|
the new threshold, defaults to the length of receivers_list param |
receivers_list |
Array |
<optional> |
all_parties
|
array of party ids to receive from, by default, this includes all parties |
senders_list |
Array |
<optional> |
all_parties
|
array of party ids that posses the share and will reshare it with the receivers, by default, this includes all parties |
Zp |
number |
<optional> |
jiff.Zp
|
the Zp of the existing share |
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this multiplication (and internally, the corresponding beaver triplet). This id must be unique, and must be passed by all parties to the same instruction. this ensures that every party gets a share from the same triplet for every matching instruction. An automatic id is generated by increasing a local counter, default ids suffice when all parties execute the instructions in the same order |
Returns:
this party's share of the result under the new threshold, or null if this party is not a receiver
- Type
- SecretShare
seed_ids(base_op_id)
- Description:
Shorthand for generating unique operation ids. All primitives called after this seed will use their usual default ids prefixed by the seed. Helpful when we have nested callbacks/functions (e.g. share_arrays) that may be executed in arbitrary order, using this function as a the first call inside such callbacks with an appropriate deterministic unique base_op_id ensures that regardless of the order of execution, operations in the same callback are matched correctly across all parties. Check out demos/graph-pip/mpc.js for an example on using this.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
base_op_id |
string | number | the base seed to use as a prefix for all future op_ids. |
share(secret, thresholdopt, receivers_listopt, senders_listopt, Zpopt, share_idopt) → {object}
- Description:
Share a secret input
Can be overriden by extensions to customize behavior
- Source:
Example
// share an input value with all parties, and receive all other parties' inputs
var shares = jiffClient.share(input);
// my party id is '1', so the first share is mine (technically my share of my input value)
var my_share = shares[1];
// my share of party 2's input
var p2_share = shares[2];
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
secret |
number | the number to share (this party's input) |
||
threshold |
number |
<optional> |
receivers_list.length
|
the minimum number of parties needed to reconstruct the secret, defaults to all the receivers |
receivers_list |
Array |
<optional> |
all_parties
|
array of party ids to share with, by default, this includes all parties |
senders_list |
Array |
<optional> |
all_parties
|
array of party ids to receive from, by default, this includes all parties |
Zp |
number |
<optional> |
jiff_instance.Zp
|
the mod (if null then the default Zp for the instance is used) |
share_id |
string | number |
<optional> |
auto_gen()
|
the tag used to tag the messages sent by this share operation, this tag is used so that parties distinguish messages belonging to this share operation from other share operations between the same parties (when the order of execution is not deterministic). An automatic id is generated by increasing a local counter, default ids suffice when all parties execute all sharing operations with the same senders and receivers in the same order |
Returns:
a map (of size equal to the number of sending parties) where the key is the party id (between 1 and n), or 's1' if 's1' is specified in the senders_list, and the value is the share object that wraps the value received from that party (the internal value maybe deferred).
- Type
- object
share_2D_array(array, lengths, thresholdopt, receivers_listopt, senders_listopt, Zpopt, share_idopt) → {promise}
- Description:
Share an array of values. Each sender may have an array of different length. This is handled by the lengths parameter. This function will reveal the lengths of the shared array.
If parties would like to keep the lengths of their arrays secret, they should agree on some "max" length apriori (either under MPC or as part of the logistics of the computation), all their arrays should be padded to that length by using appropriate default/identity values.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array |
Array | the array to be shared. |
||
lengths |
null | number | object | the lengths of the arrays to be shared. For this to work successfully, the
same exact value must be used in the calling code for each party. Any missing
lengths for a row will be automatically publicly revealed by this function.
Must have the following format:
1. null: lengths are unknown, each sender will publicly reveal the lengths of its own array.
2. { rows: |
||
threshold |
number |
<optional> |
receivers_list.length
|
the min number of parties needed to reconstruct the secret, defaults to all the receivers. |
receivers_list |
Array |
<optional> |
all_parties
|
array of party ids to share with, by default, this includes all parties. |
senders_list |
Array |
<optional> |
all_parties
|
array of party ids to receive from, by default, this includes all parties. |
Zp |
number |
<optional> |
jiff_instance.Zp
|
the mod (if null then the default Zp for the instance is used). |
share_id |
string | number |
<optional> |
auto_gen()
|
the base tag used to tag the messages sent by this share operation, every element of the array will get a unique id based on the concatenation of base_share_id and the index of the element. This tag is used so that parties distinguish messages belonging to this share operation from other share operations between the same parties (when the order of execution is not deterministic). An automatic id is generated by increasing a local counter, default ids suffice when all parties execute all sharing operations with the same senders and receivers in the same order. |
Returns:
if the calling party is a receiver then a promise to the shared arrays is returned, the promise will provide an object formatted as follows: { <party_id>: [ [ <1st_row_shares> ], [<2nd_row_share> ], ..., [ <(lengths[party_id])th_row_shares> ] ] } where the party_ids are those of the senders. if the calling party is not a receiver, then null is returned.
- Type
- promise
share_array(array, lengthsopt, thresholdopt, receivers_listopt, senders_listopt, Zpopt, share_idopt) → (nullable) {promise}
- Description:
Share an array of values. Each sender may have an array of different length. This is handled by the lengths parameter. This function will reveal the lengths of the shared array.
If parties would like to keep the lengths of their arrays secret, they should agree on some public "max" length apriori (either under MPC or as part of the logistics of the computation), all their arrays should be padded to that length by using appropriate default/identity values
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array |
Array | the array to be shared. |
||
lengths |
null | number | object |
<optional> |
the lengths of the arrays to be shared, has the following options: |
|
threshold |
number |
<optional> |
receivers_list.length
|
the min number of parties needed to reconstruct the secret, defaults to all the receivers. |
receivers_list |
Array |
<optional> |
all_parties
|
array of party ids to share with, by default, this includes all parties. |
senders_list |
Array |
<optional> |
all_parties
|
array of party ids to receive from, by default, this includes all parties. |
Zp |
number |
<optional> |
jiff_instance.Zp
|
the mod (if null then the default Zp for the instance is used). |
share_id |
string | number |
<optional> |
auto_gen()
|
the base tag used to tag the messages sent by this share operation, every element of the array will get a unique id based on the concatenation of base_share_id and the index of the element. This tag is used so that parties distinguish messages belonging to this share operation from other share operations between the same parties (when the order of execution is not deterministic). An automatic id is generated by increasing a local counter, default ids suffice when all parties execute all sharing operations with the same senders and receivers in the same order. |
Returns:
if the calling party is a receiver then a promise to the shared arrays is returned, the promise will provide an object formatted as follows: { <party_id>: [ <1st_share>, <2nd_share>, ..., <(lengths[party_id])th_share> ] } where the party_ids are those of the senders. if the calling party is not a receiver, then null is returned.
- Type
- promise
share_ND_array() → {object|promise}
- Description:
Share an n-dimensional array of secrets The arrays can be of different lengths and dimensions.
- Source:
Returns:
- Type
- object | promise
share_ND_array_deferred() → {promise}
- Description:
Helper function of share_ND_array This method gets called if share_ND_array does not have enough information to output an array of shares immediately. Instead it returns a promise to an object holding the unknown-size arrays from each sender.
- Source:
Returns:
- Type
- promise
share_ND_array_static() → {object}
- Description:
Helper function of share_ND_array This method gets called if share_ND_array when share_ND_array was given sufficients information (in the form of array skeletons) to infer the size and shape of each of the senders' arrays. This allows it to immediately return an object containing the secret-shared arrays from each sender.
- Source:
Returns:
- Type
- object
start_barrier() → {number}
- Description:
Starts a new barrier, all promises and secret shares created between this call and the corresponding start_barrier call will be part of this barrier. start_barrier may be called before previous barriers are resolved, in which case promises / secret shares created will be part of the new barrier as well as any previous barriers.
- Source:
Returns:
a barrier id that identifies this barrier.
- Type
- number
store_preprocessing(op_id, share)
- Description:
Store a pair of op_id and associated pre-processed value/share The value/share can be accessed later during the computation through jiffClient.get_preprocessing(op_id)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
op_id |
string | the op_id associated with the preprocessed value/share |
share |
SecretShare | the share/value to store |