new SecretShare(value, holders, threshold, Zp)
- Description:
The constructor function used by JIFF to create a new share. This can be overloaded by extensions to create custom shares. Modifying this will modify how shares are generated in the BASE JIFF implementation. A share is a value/promise wrapped with a share object. A share also has methods for performing operations.
- Source:
Examples
// A share whose value is 10: the secret is still unknown, 10 is only one share
var share = new jiffClient.SecretShare(10, [1, 2, 3], 3, jiffClient.Zp);
// A share whose value depends on some promise
var share = new jiffClient.SecretShare(promise, [1, 2, 3, 4], 4, jiffClient.Zp);
Parameters:
Name | Type | Description |
---|---|---|
value |
number | promise | the value of the share, or a promise to it. |
holders |
Array | the parties that hold all the corresponding shares (must be sorted). |
threshold |
number | the min number of parties needed to reconstruct the secret. |
Zp |
number | the mod under which this share was created. |
Members
holders :Array
- Description:
Array of party ids who hold shares of the corresponding secret
- Source:
Array of party ids who hold shares of the corresponding secret
Type:
- Array
jiff :module:jiff-client~JIFFClient
- Description:
The jiff client instance this share belongs to
- Source:
The jiff client instance this share belongs to
Type:
ready :boolean
- Description:
Indicates if the secret share's value is ready or still a promise
- Source:
Indicates if the secret share's value is ready or still a promise
Type:
- boolean
threshold :number
- Description:
The sharing threshold
- Source:
The sharing threshold
Type:
- number
value :number|promise
- Description:
The value of the share (or a promise to it)
- Source:
The value of the share (or a promise to it)
Type:
- number | promise
Zp :number
- Description:
The field prime under which the corresponding secret is shared
- Source:
The field prime under which the corresponding secret is shared
Type:
- number
Methods
add(o) → {SecretShare}
- Description:
Generic Addition. Uses either the constant or secret version of this operator depending on type of paramter.
- Source:
Example
var shares = jiffClient.share(input);
// this will add two secret shared values together
var sum1 = shares[1].add(shares[2]);
// this will add 3 to the secret input from party 1
var sum2 = shares[1].add(3);
// both sum1 and sum2 are SecretShares
Parameters:
Name | Type | Description |
---|---|---|
o |
number | SecretShare | the other operand (can be either number or share). |
Returns:
this party's share of the result.
- Type
- SecretShare
bit_decomposition(op_idopt) → {Array.<SecretShare>}
- Description:
Bit Decomposition: Transform existing share to an array of bit shares.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
an array of secret shares of bits of length [ceil(log_2(this.Zp))], where index 0 represents the least significant bit.
- Type
- Array.<SecretShare>
cadd(cst) → {SecretShare}
- Description:
Addition with a constant.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
cst |
number | the constant to add. |
Returns:
this party's share of the result.
- Type
- SecretShare
cdiv(cst, op_idopt) → {SecretShare}
- Description:
Integer divison with a share and a constant (this / cst).
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
cst |
SecretShare | the constant to divide by. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result.
- Type
- SecretShare
cdivfac(cst) → {SecretShare}
- Description:
Division by a constant factor of the number represented by the share.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
cst |
number | the constant by which to divide the share. |
Returns:
this party's share of the result.
- Type
- SecretShare
ceq(cst, op_idopt) → {SecretShare}
- Description:
Equality test with a constant.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
cst |
number | the constant to compare with. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result, the final result is 0 if this = o, and 1 otherwise.
- Type
- SecretShare
cgt(cst, op_idopt) → {SecretShare}
- Description:
Greater than with a constant.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
cst |
number | the constant to compare with. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly.default ids suffice when all parties execute the instructions in the same order. |
Returns:
this party's share of the result, the final result is 1 if this > cst, and 0 otherwise.
- Type
- SecretShare
cgteqn(cst, op_idopt) → {SecretShare}
- Description:
Greater than or equal with a constant.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
cst |
number | the constant to compare with. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result, the final result is 1 if this >= cst, and 0 otherwise.
- Type
- SecretShare
clt(cst, op_idopt) → {SecretShare}
- Description:
Less than with a constant.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
cst |
number | the constant to compare with. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result, the final result is 1 if this < cst, and 0 otherwise.
- Type
- SecretShare
clteq(cst, op_idopt) → {SecretShare}
- Description:
Less than or equal with a constant.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
cst |
number | the constant to compare with. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result, the final result is 1 if this <= cst, and 0 otherwise.
- Type
- SecretShare
cmult(cst) → {SecretShare}
- Description:
Multiplication by a constant.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
cst |
number | the constant to multiply to this share. |
Returns:
this party's share of the result.
- Type
- SecretShare
cneq(cst, op_idopt) → {SecretShare}
- Description:
Unequality test with a constant.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
cst |
number | the constant to compare with. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result, the final result is 0 if this = o, and 1 otherwise.
- Type
- SecretShare
cor_bit(cst) → {SecretShare}
- Description:
bitwise-OR with a constant (BOTH BITS).
- Source:
Parameters:
Name | Type | Description |
---|---|---|
cst |
number | the constant bit to OR with (0 or 1). |
Returns:
this party's share of the result.
- Type
- SecretShare
cpow(cst, op_idopt) → {SecretShare}
- Description:
Fast (modular) exponentiation with constant exponent via repeated squaring.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
cst |
number | the constant to multiply to this share. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result.
- Type
- SecretShare
csub(cst) → {SecretShare}
- Description:
Subtraction with a constant.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
cst |
number | the constant to subtract from this share. |
Returns:
this party's share of the result.
- Type
- SecretShare
cxor_bit(cst) → {SecretShare}
- Description:
bitwise-XOR with a constant (BOTH BITS).
- Source:
Parameters:
Name | Type | Description |
---|---|---|
cst |
number | the constant bit to XOR with (0 or 1). |
Returns:
this party's share of the result.
- Type
- SecretShare
div(o, l, op_idopt) → {SecretShare}
- Description:
Generic Integer Divison. Uses either the constant or secret version of this operator depending on type of paramter.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
number | SecretShare | the other operand (can be either number or share). |
||
l |
number | the maximum bit length of the two shares. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result.
- Type
- SecretShare
eq(o, op_idopt) → {SecretShare}
- Description:
Generic Equals. Uses either the constant or secret version of this operator depending on type of paramter.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
number | SecretShare | the other operand (can be either number or share). |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result.
- Type
- SecretShare
error(error)
- Description:
Logs an error. Passes the error on to the associated jiff client instance's error
- Source:
Parameters:
Name | Type | Description |
---|---|---|
error |
string | error | the error to log |
gt(o, op_idopt) → {SecretShare}
- Description:
Generic Greater than. Uses either the constant or secret version of this operator depending on type of paramter.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
number | SecretShare | the other operand (can be either number or share). |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result.
- Type
- SecretShare
gteq(o, op_idopt) → {SecretShare}
- Description:
Generic Greater or equal. Uses either the constant or secret version of this operator depending on type of paramter.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
number | SecretShare | the other operand (can be either number or share). |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result.
- Type
- SecretShare
if_else(trueVal, falseVal, op_idopt) → {SecretShare}
- Description:
Simulate an oblivious If-else statement with a single return value. Should be called on a secret share of a bit: 0 representing false, and 1 representing true If this is a share of 1, a new sharing of the element represented by the first parameter is returned, otherwise, a new sharing of the second is returned.
- Source:
Example
// a and b are secret shares
// cmp will be a secret share of either 1 or 0, depending on whether a or b is greater
var cmp = a.gt(b);
// max is set to the greater value, without revealing the value or the result of the inequality
var max = cmp.if_else(a, b);
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
trueVal |
SecretShare | number | the value/share to return if this is a sharing of 1. |
||
falseVal |
SecretShare | number | the value/share to return if this is a sharing of 0. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
a new sharing of the result of the if.
- Type
- SecretShare
isConstant(o) → {boolean}
- Description:
Checks if the given parameter is a constant, used to determine whether constant or secret operations should be executed when the generic version of an operation is called
- Source:
Parameters:
Name | Type | Description |
---|---|---|
o |
number/object | the parameter to determine. |
Returns:
true if o is a valid constant, false otherwise.
- Type
- boolean
logLEAK(tag, partiesopt, op_idopt) → (nullable) {promise}
- Description:
Logs the value represented by this share to the console WARNING: THIS LEAKS INFORMATION AND MUST BE USED ONLY TO DEBUG ON FAKE DATA
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
tag |
string | accompanying tag to display in the console |
||
parties |
Array.<(number|string)> |
<optional> |
[holders[0]
|
the parties which will display the log |
op_id |
string | number | object |
<optional> |
auto_gen()
|
same as open |
Returns:
a promise to the value represented by this share after logging it, null if party is not in parties
- Type
- promise
lt(o, op_idopt) → {SecretShare}
- Description:
Generic Less than. Uses either the constant or secret version of this operator depending on type of paramter.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
number | SecretShare | the other operand (can be either number or share). |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result.
- Type
- SecretShare
lt_halfprime(op_idopt) → {SecretShare}
- Description:
Checks whether the share is less than half the field size.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result.
- Type
- SecretShare
lteq(o, op_idopt) → {SecretShare}
- Description:
Generic Less or equal. Uses either the constant or secret version of this operator depending on type of paramter.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
number | SecretShare | the other operand (can be either number or share). |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result.
- Type
- SecretShare
mult(o, op_idopt) → {SecretShare}
- Description:
Generic Multiplication. Uses either the constant or secret version of this operator depending on type of paramter.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
number | SecretShare | the other operand (can be either number or 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. Only used if secret multiplication is used. |
Returns:
this party's share of the result.
- Type
- SecretShare
neq(o, op_idopt) → {SecretShare}
- Description:
Generic Not Equals. Uses either the constant or secret version of this operator depending on type of paramter.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
number | SecretShare | the other operand (can be either number or share). |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result.
- Type
- SecretShare
not() → {SecretShare}
- Description:
Negation of a bit. This has to be a share of a BIT in order for this to work properly.
- Source:
Returns:
this party's share of the result (negated bit).
- Type
- SecretShare
open(partiesopt, op_idopt) → (nullable) {promise}
- Description:
Shortcut for opening/revealing the value of this share. Alias for open in jiff-instance
- Source:
- See:
-
- jiff-instance#open
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
parties |
Array |
<optional> |
all_parties
|
an array with party ids (1 to n) of receiving parties |
op_id |
string | number | object |
<optional> |
auto_gen()
|
same as open |
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
or_bit(o, op_idopt) → {SecretShare}
- Description:
Generic OR for bits (both this and o have to be bits to work correctly). Uses either the constant or secret version of this operator depending on type of paramter.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
number | SecretShare | the other operand (can be either number or share). |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. Only used if secret or is used.. |
Returns:
this party's share of the result.
- Type
- SecretShare
promise_handler(value)
- Description:
Handler for when this share's promise (if any) is resolved
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
number | the value of the share after it was resolved |
refresh(op_idopt) → {SecretShare}
- Description:
Reshares/refreshes the sharing of this number, used before opening to keep the share secret.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
op_id |
string |
<optional> |
auto_gen()
|
the operation id with which to tag the messages sent by this refresh, by default an automatic operation id is generated by increasing a local counter, default operation ids suffice when all parties execute the instructions in the same order. |
Returns:
a new share of the same number.
- Type
- SecretShare
sadd(o) → {SecretShare}
- Description:
Addition of two secret shares.
- Source:
Example
// share a value with all parties, and sum the values of all shares
var shares = jiff_instance.share(x);
var sum = shares[1];
for (var i = 2; i <= jiff_instance.party_count; i++) {
sum = sum.sadd(shares[i]);
}
Parameters:
Name | Type | Description |
---|---|---|
o |
SecretShare | the share to add to this share. |
Returns:
this party's share of the result.
- Type
- SecretShare
sdiv(o, lopt, op_idopt) → {SecretShare}
- Description:
Integer divison with two shares (this / o)
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
SecretShare | the share to divide by. |
||
l |
number |
<optional> |
ceil(log_2(this.Zp))
|
the maximum bit length of either operands. |
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result.
- Type
- SecretShare
seq(o, op_idopt) → {SecretShare}
- Description:
Equality test with two shares.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
SecretShare | the share to compare with. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result, the final result is 1 if this = o, and 0 otherwise.
- Type
- SecretShare
sgt(o, op_idopt) → {SecretShare}
- Description:
Greater than with another share.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
SecretShare | the other share. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result, the final result is 1 if this > o, and 0 otherwise.
- Type
- SecretShare
sgteq(o, op_idopt) → {SecretShare}
- Description:
Greater than or equal with another share.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
SecretShare | the other share. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result, the final result is 1 if this >= o, and 0 otherwise.
- Type
- SecretShare
slt(o, op_idopt) → {SecretShare}
- Description:
Less than with another share.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
SecretShare | the other share. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result, the final result is 1 if this < o, and 0 otherwise.
- Type
- SecretShare
slteq(o, op_idopt) → {SecretShare}
- Description:
Less than or equal with another share.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
SecretShare | the other share. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result, the final result is 1 if this <= o, and 0 otherwise.
- Type
- SecretShare
smod(o, lopt, op_idopt) → {SecretShare}
- Description:
Remainder with two shares (this % o)
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
SecretShare | the modulus to apply |
||
l |
number |
<optional> |
ceil(log_2(this.Zp))
|
the maximum bit length of either operands. |
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result.
- Type
- SecretShare
smult(o, op_idopt) → {SecretShare}
- Description:
Multiplication of two secret shares through Beaver Triplets.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
SecretShare | the share to multiply with. |
||
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.
- Type
- SecretShare
smult_bgw(o, op_idopt) → {SecretShare}
- Description:
Multiplication of two secret shares through BGW protocol.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
SecretShare | the share to multiply with. |
||
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.
- Type
- SecretShare
sneq(o, op_idopt) → {SecretShare}
- Description:
Unequality test with two shares.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
SecretShare | the share to compare with. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
this party's share of the result, the final result is 0 if this = o, and 1 otherwise.
- Type
- SecretShare
sor_bit(o, op_idopt) → {SecretShare|SecretShare}
- Description:
OR of two secret shares OF BITS.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
SecretShare | the share to OR with. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
-
this party's share of the result, the final result is 1 if this < o, and 0 otherwise.
- Type
- SecretShare
-
this party's share of the result.
- Type
- SecretShare
ssub(o) → {SecretShare}
- Description:
Subtraction of two secret shares.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
o |
SecretShare | the share to subtract from this share. |
Returns:
this party's share of the result.
- Type
- SecretShare
sub(o) → {SecretShare}
- Description:
Generic Subtraction. Uses either the constant or secret version of this operator depending on type of paramter.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
o |
number | SecretShare | the other operand (can be either number or share). |
Returns:
this party's share of the result.
- Type
- SecretShare
sxor_bit(o, op_idopt) → {SecretShare|SecretShare}
- Description:
bitwise-XOR of two secret shares OF BITS.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
SecretShare | the share to XOR with. |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. |
Returns:
-
this party's share of the result, the final result is 1 if this < o, and 0 otherwise.
- Type
- SecretShare
-
this party's share of the result.
- Type
- SecretShare
toString() → {string}
- Description:
Gets a string representation of this share
- Source:
Returns:
the id and value of the share as a string
- Type
- string
valueOf() → {number}
- Description:
Gets the value of this share
- Source:
Returns:
the value (undefined if not ready yet)
- Type
- number
when_both_ready(o, cb) → {value|promise}
- Description:
Executes callback when both this share and o are ready and returns the result (or a promise to the result)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
o |
SecretShare | the other share object. |
cb |
function | the callback to execute. |
Returns:
either the return value of cb() or a promise to it
- Type
- value | promise
wThen(onFulfilled, onRejectedopt) → {promise|value}
- Description:
Wrapper around share.value.then. In case share is ready (its promise is resolved and cleared) The callback is executed immediately. Does not support chaining
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
onFulfilled |
function | callback for success, called with this.value as parameter |
||
onRejected |
function |
<optional> |
this.error
|
callback for errors |
Returns:
either the result of executing onFulfilled or a promise to it
- Type
- promise | value
xor_bit(o, op_idopt) → {SecretShare}
- Description:
Generic XOR for bits (both this and o have to be bits to work correctly). Uses either the constant or secret version of this operator depending on type of paramter.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
o |
number | SecretShare | the other operand (can be either number or share). |
||
op_id |
string |
<optional> |
auto_gen()
|
the operation id which is used to identify this operation. This id must be unique, and must be passed by all parties to the same instruction, to ensure that corresponding instructions across different parties are matched correctly. Only used if secret xor is used.. |
Returns:
this party's share of the result.
- Type
- SecretShare