shared3p.sc
shared3p.sc
Module with shared3p protection domain functions.
Functions:
abs
Function for finding absolute values.
Detailed Description
D - shared3p protection domain |
Supported types - int8 / int16 / int32 / int / float32 / float64 / fix32 / fix64 |
Parameters
x |
- an array of any dimension |
returns an array of equal shape, size and dimension, where all values are the absolute values of the input array at that position |
None |
all
Function for checking if all values of the input vector are true.
any
Function for checking if any value of the input vector is true.
argument
Function for accessing the named program arguments of shared3p types.
bit extraction
Function for converting xor_uint(X) type value to the bit representation.
Detailed Description
D - shared3p protection domain |
Supported types - xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64 |
The input is arbitrary dimensional array, output is flattened to one boolean vector. Reshape the result to get appropriate dimensionality. |
Parameters
input |
- the input value to convert |
returns filattened vector of extracted bits |
None |
ceiling
Functions for rounding a value upwards.
choose(multiple conditions)
Function for obliviously choosing pointwise from the inputs.
Detailed Description
D - shared3p protection domain |
Supported types - xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64 |
Parameters
cond |
- a boolean vector |
pointwise check if cond at a certain position is true or false. if true the element of first at that position is returned else the element of second at that position is returned |
None |
Function Overloads
D xor_uint8 choose(D bool[[N]] cond, D xor_uint8[[N]] first, D xor_uint8[[N]] second)
D xor_uint16 choose(D bool[[N]] cond, D xor_uint16[[N]] first, D xor_uint16[[N]] second)
D xor_uint32 choose(D bool[[N]] cond, D xor_uint32[[N]] first, D xor_uint32[[N]] second)
D xor_uint64 choose(D bool[[N]] cond, D xor_uint64[[N]] first, D xor_uint64[[N]] second)
choose(single condition)
Function for obliviously choosing one of the inputs.
Detailed Description
D - shared3p protection domain |
Supported types - xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64 |
Parameters
cond |
- a boolean scalar |
returns one of the input arrays that was obliviously chosen with the condition. if true, array first is returned else second is returned |
None |
Function Overloads
D xor_uint8 choose(D bool cond, D xor_uint8[[N]] first, D xor_uint8[[N]] second)
D xor_uint16 choose(D bool cond, D xor_uint16[[N]] first, D xor_uint16[[N]] second)
D xor_uint32 choose(D bool cond, D xor_uint32[[N]] first, D xor_uint32[[N]] second)
D xor_uint64 choose(D bool cond, D xor_uint64[[N]] first, D xor_uint64[[N]] second)
erf
Function for finding the value of error function.
exp
Function for finding exp(x)
floor
Functions for rounding a value downwards.
inv
Function for inversing a value.
invPrefixSum
Fast inverse prefix sum.
Detailed Description
D - shared3p protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int |
Parameters
vec |
- a vector of supported type |
Reverses prefixSum: subtracts the preceding element from each element of vec. |
None |
Function Overloads
D uint8 invPrefixSum(D uint8[[1]] vec)
D uint16 invPrefixSum(D uint16[[1]] vec)
D uint32 invPrefixSum(D uint32[[1]] vec)
D uint64 invPrefixSum(D uint64[[1]] vec)
D int8 invPrefixSum(D int8[[1]] vec)
D int16 invPrefixSum(D int16[[1]] vec)
D int32 invPrefixSum(D int32[[1]] vec)
D int64 invPrefixSum(D int64[[1]] vec)
isNegligible
Function for finding if the error is small enough to neglect.
ln
Function for finding the natural logarithm of a value.
log
Function for finding the logarithm of a value.
log10
Function for finding the base 10 logarithm of a value.
logGamma
Compute the logarithm of the Gamma function.
pow
Function for computing values of the power function.
prefixSum
Fast prefix sum.
Detailed Description
D - shared3p protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int |
Parameters
vec |
- a vector of supported type |
Turns the input vector [x1, x2, …, xn] to [x1, x1 + x2, … , x1 + … + xn] |
None |
Function Overloads
D uint8 prefixSum(D uint8[[1]] vec)
D uint16 prefixSum(D uint16[[1]] vec)
D uint32 prefixSum(D uint32[[1]] vec)
D uint64 prefixSum(D uint64[[1]] vec)
D int8 prefixSum(D int8[[1]] vec)
D int16 prefixSum(D int16[[1]] vec)
D int32 prefixSum(D int32[[1]] vec)
D int64 prefixSum(D int64[[1]] vec)
publish
Function for publishing the named values of shared3p types.
reshare
Function for converting uint(X) type values to xor_uint(X) and the other way around.
Detailed Description
D - shared3p protection domain |
Supported types - xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64 |
Parameters
input |
- the input value to convert |
returns a converted value from uint(X) → xor_uint(X) or xor_uint(X) → uint(X) |
None |
Function Overloads
D xor_uint8 reshare(D uint8 input)
D xor_uint8 reshare(D int8 input)
D uint8 reshare(D xor_uint8 input)
D xor_uint8 reshare(D uint8[[1]] input)
D xor_uint8 reshare(D int8[[1]] input)
D uint8 reshare(D xor_uint8[[1]] input)
D xor_uint8 reshare(D uint8[[2]] input)
D xor_uint8 reshare(D int8[[2]] input)
D uint8 reshare(D xor_uint8[[2]] input)
D xor_uint16 reshare(D uint16 input)
D xor_uint16 reshare(D int16 input)
D uint16 reshare(D xor_uint16 input)
D xor_uint16 reshare(D uint16[[1]] input)
D xor_uint16 reshare(D int16[[1]] input)
D uint16 reshare(D xor_uint16[[1]] input)
D xor_uint16 reshare(D uint16[[2]] input)
D xor_uint16 reshare(D int16[[2]] input)
D uint16 reshare(D xor_uint16[[2]] input)
D xor_uint32 reshare(D uint32 input)
D xor_uint32 reshare(D int32 input)
D uint32 reshare(D xor_uint32 input)
D xor_uint32 reshare(D uint32[[1]] input)
D xor_uint32 reshare(D int32[[1]] input)
D uint32 reshare(D xor_uint32[[1]] input)
D xor_uint32 reshare(D uint32[[2]] input)
D xor_uint32 reshare(D int32[[2]] input)
D uint32 reshare(D xor_uint32[[2]] input)
D xor_uint64 reshare(D uint64 input)
D xor_uint64 reshare(D int64 input)
D uint64 reshare(D xor_uint64 input)
D xor_uint64 reshare(D uint64[[1]] input)
D xor_uint64 reshare(D int64[[1]] input)
D uint64 reshare(D xor_uint64[[1]] input)
D xor_uint64 reshare(D uint64[[2]] input)
D xor_uint64 reshare(D int64[[2]] input)
D uint64 reshare(D xor_uint64[[2]] input)
sign
Function for determining the sign of values.
Detailed Description
D - shared3p protection domain |
Supported types - int8 / int16 / int32 / int |
Parameters
x |
- an array of any dimension |
returns an array of equal shape, size and dimension, where -1 signifies that, in the input array at that position was a negative number and 1 that it was a positive number |
None |
sin
Function for finding the sine of a value.
sqrt
Function for finding the square root of a value.
truePrefixLength
Function for finding how many elements from the start of a vector are true.
max
Functions for finding the maximum value.
Functions:
D - shared3p protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64 |
max
Function for finding the maximum element of the input vector.
Detailed Description
D - shared3p protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64 |
Parameters
x |
- input |
maximum element of the input vector |
input vector is not empty |
None |
Function Overloads
D T max(D T x)
D uint8 max(D uint8[[1]] x)
D uint16 max(D uint16[[1]] x)
D uint32 max(D uint32[[1]] x)
D uint max(D uint[[1]] x)
D int8 max(D int8[[1]] x)
D int16 max(D int16[[1]] x)
D int32 max(D int32[[1]] x)
D int max(D int[[1]] x)
D float32 max(D float32[[1]] x)
D float64 max(D float64[[1]] x)
D xor_uint8 max(D xor_uint8[[1]] x)
D xor_uint16 max(D xor_uint16[[1]] x)
D xor_uint32 max(D xor_uint32[[1]] x)
D xor_uint64 max(D xor_uint64[[1]] x)
max(2 vectors)
Function for finding the pointwise maximum of 2 arrays.
Detailed Description
D - shared3p protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 / xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64 |
an array with the pointwise maximum of each element in the two input vectors |
both input vectors are of equal length |
None |
Function Overloads
D uint8 max(D uint8 x, D uint8 y)
D uint16 max(D uint16 x, D uint16 y)
D uint32 max(D uint32 x, D uint32 y)
D uint max(D uint x, D uint y)
D int8 max(D int8 x, D int8 y)
D int16 max(D int16 x, D int16 y)
D int32 max(D int32 x, D int32 y)
D int max(D int x, D int y)
D float32 max(D float32 x, D float32 y)
D float64 max(D float64 x, D float64 y)
D uint8 max(D uint8[[1]] x, D uint8[[1]] y)
D uint16 max(D uint16[[1]] x, D uint16[[1]] y)
D uint32 max(D uint32[[1]] x, D uint32[[1]] y)
D uint max(D uint[[1]] x, D uint[[1]] y)
D int8 max(D int8[[1]] x, D int8[[1]] y)
D int16 max(D int16[[1]] x, D int16[[1]] y)
D int32 max(D int32[[1]] x, D int32[[1]] y)
D int max(D int[[1]] x, D int[[1]] y)
D float32 max(D float32[[1]] x, D float32[[1]] y)
D float64 max(D float64[[1]] x, D float64[[1]] y)
D uint8 max(D uint8[[N]] x, D uint8[[N]] y)
D uint16 max(D uint16[[N]] x, D uint16[[N]] y)
D uint32 max(D uint32[[N]] x, D uint32[[N]] y)
D uint max(D uint[[N]] x, D uint[[N]] y)
D int8 max(D int8[[N]] x, D int8[[N]] y)
D int16 max(D int16[[N]] x, D int16[[N]] y)
D int32 max(D int32[[N]] x, D int32[[N]] y)
D int max(D int[[N]] x, D int[[N]] y)
D float32 max(D float32[[N]] x, D float32[[N]] y)
D float64 max(D float64[[N]] x, D float64[[N]] y)
D xor_uint8 max(D xor_uint8 x, D xor_uint8 y)
D xor_uint16 max(D xor_uint16 x, D xor_uint16 y)
D xor_uint32 max(D xor_uint32 x, D xor_uint32 y)
D xor_uint64 max(D xor_uint64 x, D xor_uint64 y)
D xor_uint8 max(D xor_uint8[[1]] x, D xor_uint8[[1]] y)
D xor_uint16 max(D xor_uint16[[1]] x, D xor_uint16[[1]] y)
D xor_uint32 max(D xor_uint32[[1]] x, D xor_uint32[[1]] y)
D xor_uint64 max(D xor_uint64[[1]] x, D xor_uint64[[1]] y)
D xor_uint8 max(D xor_uint8[[N]] x, D xor_uint8[[N]] y)
D xor_uint16 max(D xor_uint16[[N]] x, D xor_uint16[[N]] y)
D xor_uint32 max(D xor_uint32[[N]] x, D xor_uint32[[N]] y)
D xor_uint64 max(D xor_uint64[[N]] x, D xor_uint64[[N]] y)
max(parts)
Function for finding the maximum element in the specified parts of the vector.
Detailed Description
D - shared3p protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int |
Parameters
x |
- input vector |
k |
- an uint type value, which specifies into how many subarrays must the input array be divided |
a vector with all the maximum elements of all the subarrays specified by k |
input vector is not empty |
the size of the input array is dividable by k |
None |
Function Overloads
D uint8 max(D uint8[[1]] x, uint k)
D uint16 max(D uint16[[1]] x, uint k)
D uint32 max(D uint32[[1]] x, uint k)
D uint max(D uint[[1]] x, uint k)
D int8 max(D int8[[1]] x, uint k)
D int16 max(D int16[[1]] x, uint k)
D int32 max(D int32[[1]] x, uint k)
D int max(D int[[1]] x, uint k)
min
Functions for finding the minimum value.
Functions:
D - shared3p protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64 |
min
Function for finding the minimum element of the input vector.
Detailed Description
D - shared3p protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64 |
Parameters
x |
- input |
minimum element of the input vector. |
input vector is not empty |
None |
Function Overloads
D T min(D T x)
D uint8 min(D uint8[[1]] x)
D uint16 min(D uint16[[1]] x)
D uint32 min(D uint32[[1]] x)
D uint min(D uint[[1]] x)
D int8 min(D int8[[1]] x)
D int16 min(D int16[[1]] x)
D int32 min(D int32[[1]] x)
D int min(D int[[1]] x)
D float32 min(D float32[[1]] x)
D float64 min(D float64[[1]] x)
D xor_uint8 min(D xor_uint8[[1]] x)
D xor_uint16 min(D xor_uint16[[1]] x)
D xor_uint32 min(D xor_uint32[[1]] x)
D xor_uint64 min(D xor_uint64[[1]] x)
min(2 vectors)
Function for finding the pointwise minimum of 2 arrays.
Detailed Description
D - shared3p protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 / xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64 |
Parameters
x |
- first argument |
y |
- second argument |
an array with the pointwise minimum of each element in the two input vectors |
both input vectors are of equal length |
None |
Function Overloads
D uint8 min(D uint8 x, D uint8 y)
D uint16 min(D uint16 x, D uint16 y)
D uint32 min(D uint32 x, D uint32 y)
D uint min(D uint x, D uint y)
D int8 min(D int8 x, D int8 y)
D int16 min(D int16 x, D int16 y)
D int32 min(D int32 x, D int32 y)
D int min(D int x, D int y)
D float32 min(D float32 x, D float32 y)
D float64 min(D float64 x, D float64 y)
D uint8 min(D uint8[[1]] x, D uint8[[1]] y)
D uint16 min(D uint16[[1]] x, D uint16[[1]] y)
D uint32 min(D uint32[[1]] x, D uint32[[1]] y)
D uint min(D uint[[1]] x, D uint[[1]] y)
D int8 min(D int8[[1]] x, D int8[[1]] y)
D int16 min(D int16[[1]] x, D int16[[1]] y)
D int32 min(D int32[[1]] x, D int32[[1]] y)
D int min(D int[[1]] x, D int[[1]] y)
D float32 min(D float32[[1]] x, D float32[[1]] y)
D float64 min(D float64[[1]] x, D float64[[1]] y)
D uint8 min(D uint8[[N]] x, D uint8[[N]] y)
D uint16 min(D uint16[[N]] x, D uint16[[N]] y)
D uint32 min(D uint32[[N]] x, D uint32[[N]] y)
D uint min(D uint[[N]] x, D uint[[N]] y)
D int8 min(D int8[[N]] x, D int8[[N]] y)
D int16 min(D int16[[N]] x, D int16[[N]] y)
D int32 min(D int32[[N]] x, D int32[[N]] y)
D int min(D int[[N]] x, D int[[N]] y)
D float32 min(D float32[[N]] x, D float32[[N]] y)
D float64 min(D float64[[N]] x, D float64[[N]] y)
D xor_uint8 min(D xor_uint8 x, D xor_uint8 y)
D xor_uint16 min(D xor_uint16 x, D xor_uint16 y)
D xor_uint32 min(D xor_uint32 x, D xor_uint32 y)
D xor_uint64 min(D xor_uint64 x, D xor_uint64 y)
D xor_uint8 min(D xor_uint8[[1]] x, D xor_uint8[[1]] y)
D xor_uint16 min(D xor_uint16[[1]] x, D xor_uint16[[1]] y)
D xor_uint32 min(D xor_uint32[[1]] x, D xor_uint32[[1]] y)
D xor_uint64 min(D xor_uint64[[1]] x, D xor_uint64[[1]] y)
D xor_uint8 min(D xor_uint8[[N]] x, D xor_uint8[[N]] y)
D xor_uint16 min(D xor_uint16[[N]] x, D xor_uint16[[N]] y)
D xor_uint32 min(D xor_uint32[[N]] x, D xor_uint32[[N]] y)
D xor_uint64 min(D xor_uint64[[N]] x, D xor_uint64[[N]] y)
min(parts)
Function for finding the minimum element in the specified parts of the vector.
Detailed Description
D - shared3p protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int |
Parameters
x |
- input vector |
k |
- an uint type value, which specifies into how many subarrays must the input array be divided |
a vector with all the minimum elements of all the subarrays specified by k |
input vector is not empty |
the size of the input array is dividable by k |
None |
Function Overloads
D uint8 min(D uint8[[1]] x, uint k)
D uint16 min(D uint16[[1]] x, uint k)
D uint32 min(D uint32[[1]] x, uint k)
D uint min(D uint[[1]] x, uint k)
D int8 min(D int8[[1]] x, uint k)
D int16 min(D int16[[1]] x, uint k)
D int32 min(D int32[[1]] x, uint k)
D int min(D int[[1]] x, uint k)
product
Functions for finding products.
Functions:
D - shared3p protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int |
product
Function for finding the product of the input vector.
Detailed Description
D - shared3p protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int |
Parameters
vec |
- a vector of supported type |
The product of the input vector |
None |
Function Overloads
D T product(D T scalar)
D uint8 product(D uint8[[1]] vec)
D uint16 product(D uint16[[1]] vec)
D uint32 product(D uint32[[1]] vec)
D uint product(D uint[[1]] vec)
D int8 product(D int8[[1]] vec)
D int16 product(D int16[[1]] vec)
D int32 product(D int32[[1]] vec)
D int product(D int[[1]] vec)
product(parts)
Function for finding the product of all elements in the input vector in specified parts.
Detailed Description
D - shared3p protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int |
the length of the input array must be a multiple of k |
Parameters
vec |
- The input array of subarrays to find the product of. The subarrays are stacked one after another and are all of the same size. |
k |
- The number of subarrays in the input array. |
The array of subarrayCount number of products, each corresponding to respective subarray in the input array vec. |
None |
Function Overloads
D uint8 product(D uint8[[1]] vec, uint k)
D uint16 product(D uint16[[1]] vec, uint k)
D uint32 product(D uint32[[1]] vec, uint k)
D uint product(D uint[[1]] vec, uint k)
D int8 product(D int8[[1]] vec, uint k)
D int16 product(D int16[[1]] vec, uint k)
D int32 product(D int32[[1]] vec, uint k)
D int product(D int[[1]] vec, uint k)
sum
Functions for finding sums.
Functions:
D - shared3p protection domain |
Supported types - bool / uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 |
sum
Function for finding the sum of all the elements in a vector.
Detailed Description
D - shared3p protection domain |
Supported types - bool / uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 |
We are using a system call for summing vectors as it’s very common operation, and the performance overhead of manually summing is in the range of 100 to 200 times slower. |
Parameters
vec |
- a 1-dimensional array |
the sum of all input vector elements |
None |
Function Overloads
D uint8 sum(D uint8[[1]] vec)
D uint16 sum(D uint16[[1]] vec)
D uint32 sum(D uint32[[1]] vec)
D uint sum(D uint[[1]] vec)
D int8 sum(D int8[[1]] vec)
D int16 sum(D int16[[1]] vec)
D int32 sum(D int32[[1]] vec)
D int sum(D int[[1]] vec)
D float32 sum(D float32[[1]] vec)
D float64 sum(D float64[[1]] vec)
D fix32 sum(D fix32[[1]] vec)
D fix64 sum(D fix64[[1]] vec)
sum(parts)
Function for finding the sum of all elements in the input vector in specified parts.
Detailed Description
D - shared3p protection domain |
Supported types - bool / uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 |
the length of the input array must be a multiple of k |
Parameters
vec |
- The input array of subarrays to sum. The subarrays are stacked one after another and are all of the same size. |
k |
- The number of subarrays in the input array. |
The array of subarrayCount number of sums, each corresponding to respective subarray in the input array vec. |
None |
Function Overloads
D uint sum(D bool[[1]] vec, uint k)
D uint8 sum(D uint8[[1]] vec, uint k)
D uint16 sum(D uint16[[1]] vec, uint k)
D uint32 sum(D uint32[[1]] vec, uint k)
D uint sum(D uint[[1]] vec, uint k)
D int8 sum(D int8[[1]] vec, uint k)
D int16 sum(D int16[[1]] vec, uint k)
D int32 sum(D int32[[1]] vec, uint k)
D int sum(D int[[1]] vec, uint k)
D float32 sum(D float32[[1]] vec, uint k)
D float64 sum(D float64[[1]] vec, uint k)
D fix32 sum(D fix32[[1]] vec, uint k)
D fix64 sum(D fix64[[1]] vec, uint k)