shared2p.sc
shared2p.sc
Module with shared2p protection domain functions.
Functions:
abs
Function for finding absolute values.
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 shared2p types.
bit extraction
Function for converting xor_uint(X) type value to the bit representation.
Detailed Description
D - shared2p 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 |
choose
Function for obliviously choosing pointwise from the inputs.
Detailed Description
D - shared2p protection domain |
Supported types - xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64 |
Parameters
cond |
- a boolean vector |
first |
- values for true case |
second |
- values for false case |
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 |
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)
publish
Function for publishing the named values of shared2p types.
reshare
Function for converting uint(X) type values to xor_uint(X) and the other way around.
Detailed Description
D - shared2p 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) |
Function Overloads
D xor_uint8 reshare(D uint8 input)
D uint8 reshare(D xor_uint8 input)
D xor_uint8 reshare(D uint8[[1]] input)
D uint8 reshare(D xor_uint8[[1]] input)
D xor_uint8 reshare(D uint8[[2]] input)
D uint8 reshare(D xor_uint8[[2]] input)
D xor_uint16 reshare(D uint16 input)
D uint16 reshare(D xor_uint16 input)
D xor_uint16 reshare(D uint16[[1]] input)
D uint16 reshare(D xor_uint16[[1]] input)
D xor_uint16 reshare(D uint16[[2]] input)
D uint16 reshare(D xor_uint16[[2]] input)
D xor_uint32 reshare(D uint32 input)
D uint32 reshare(D xor_uint32 input)
D xor_uint32 reshare(D uint32[[1]] input)
D uint32 reshare(D xor_uint32[[1]] input)
D xor_uint32 reshare(D uint32[[2]] input)
D uint32 reshare(D xor_uint32[[2]] input)
D xor_uint64 reshare(D uint64 input)
D uint64 reshare(D xor_uint64 input)
D xor_uint64 reshare(D uint64[[1]] input)
D uint64 reshare(D xor_uint64[[1]] input)
D xor_uint64 reshare(D uint64[[2]] input)
D uint64 reshare(D xor_uint64[[2]] input)
sign
Function for determining the sign of values.
Detailed Description
D - shared2p 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 |
truePrefixLength
Function for finding how many elements from the start of a vector are true.
max
Functions for finding the maximum value.
Functions:
D - shared2p 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 - shared2p 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 |
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 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 - shared2p protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / xor_uint8 / xor_uint16 / xor_uint32 / xor_uint64 |
Parameters
x |
- first argument |
y |
- second argument |
an array with the pointwise maximum of each element in the two input vectors |
both input vectors are of equal length |
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 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 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 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 - shared2p 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 |
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 - shared2p protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int |
min
Function for finding the minimum element of the input vector.
Detailed Description
D - shared2p 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 |
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 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 - shared2p protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / 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 |
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 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 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 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 - shared2p 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 |
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 - shared2p protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int |
product
Function for finding the product of the input vector.
product(parts)
Function for finding the product of all elements in the input vector in specified parts.
Detailed Description
D - shared2p 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. |
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 - shared2p protection domain |
Supported types - bool / uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int |
sum
Function for finding the sum of all the elements in a vector.
Detailed Description
D - shared2p protection domain |
Supported types - bool / uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int |
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 |
sum(parts)
Function for finding the sum of all elements in the input vector in specified parts.
Detailed Description
D - shared2p protection domain |
Supported types - bool / 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 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. |
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)