shared3p_string.sc
shared3p_string.sc
Module with string functions.
Functions:
CRC
Compute CRC hash of the input byte array with given initial hash.
CRC(0 initial hash)
Compute CRC hash of the input byte array with 0 initial hash.
cw128GenKey
Generates key for 128-bit Carter-Wegman hash.
cw128Hash
Hashes values in the input vector into 128-bit hashes using the Carter-Wegman algorithm.
cw128Hash(key)
Hashes values in the input vector into 128-bit hashes using the Carter-Wegman algorithm.
Detailed Description
D - shared3p protection domain |
Parameters
data |
- data vector |
key |
- key used for hashing. See cw128GenKey cw128GenKey. |
rowLen |
- length of one data element in bytes |
None |
shared3p_bl_string
Module with functions for bounded length strings.
Functions:
bl_str(struct)
bl_strCat
Function for concatenating two strings.
bl_strContains
function for checking if a string contains the given pattern
bl_strDeclassify
Function for converting an array of type xor_uint8 to a string.
bl_strEmpty
Check if a bounded-length string vector contains empty strings.
Detailed Description
D - shared3p protection domain |
Parameters
s |
- input string vector |
returns a boolean vector indicating if the string in the corresponding position in s was empty |
None |
Function Overloads
D bool bl_strEmpty(BlStringVector< D > s)
bl_strEqPrefixes
Function for checking whether a pattern is a substring of the input string.
Detailed Description
D - shared3p protection domain |
Supported types - xor_uint8 |
the pattern is not longer than the input string |
Parameters
str |
- input string vector of supported type |
pat |
- the pattern to look for |
returns a boolean vector indicating if the pattern is a substring of the input string at that position |
None |
bl_strEquals
Compare two string with each other.
bl_strFind
Searches for a string in a string vector.
Detailed Description
D - shared3p protection domain |
Parameters
needle |
- query string |
haystack |
- string vector |
returns the index of the first occurence of needle in haystack if found and -1 otherwise |
None |
Function Overloads
D int64 bl_strFind(D xor_uint8[[1]] needle, BlStringVector< D > haystack)
bl_strHamming
Function for finding the number of bytes that the two input strings differ in.
bl_strIndexOf
function for finding the index of a given pattern
Detailed Description
D - shared3p protection domain |
Supported types - xor_uint8 |
Parameters
str |
- input string vector of supported type |
pat |
- the pattern to look for |
returns the position where given pattern is contained in the string |
if the string is not found returns value that is or equal to size (str) |
None |
bl_strIsEmpty
Check if the input string is empty.
Detailed Description
D - shared3p protection domain |
Supported types - xor_uint8 |
this is done by checking if all of the bytes in the string are zeroed |
See bl_strEmpty for parallel version. |
Parameters
s |
- a vector of supported type |
returns true if the given known length input string is empty |
None |
bl_strIsLessThan
function for comparing two strings alphabetically
Detailed Description
D - shared3p protection domain |
Supported types - xor_uint8 |
See bl_strLessThan for parallel version. |
Parameters
s, t |
- input string vectors of supported type |
returns true if s < t |
None |
bl_strLength
Function for finding the length of the given input string.
bl_strLengthenBound
Increase the bound of a bounded-length string vector.
Detailed Description
D - shared3p protection domain |
Parameters
s |
- input string vector |
biggerBound |
- new bound |
returns s with the bound increased to biggerBound |
None |
Function Overloads
bl_strLengthenBound(BlStringVector< D > s, uint biggerBound)
bl_strLessThan(parallel)
Compares two bounded-length string vectors point-wise.
Detailed Description
D - shared3p protection domain |
Parameters
x, y |
- input bounded-length string vectors |
returns a boolean vector indicating if the element of x is less than the element of y in the corresponding position |
None |
Function Overloads
D bool bl_strLessThan(BlStringVector< D > x, BlStringVector< D > y)
bl_strLevenshtein
function for finding the edit distance of the two input strings
Detailed Description
D - shared3p protection domain |
Supported types - xor_uint8 |
Parameters
s, t |
- input string vectors of supported type |
returns the edit distance of the two input strings |
the algorithm is almost identical to the known length one. The only difference is that the result is found somewhere in the middle of the 2D grid, and not in the bottom right corner. To find it we: a) compute a mask that’s one in that position and zero otherwise, b) multiply the mask with the grid, and c) return the sum of the result. |
None |
bl_strShuffle
Shuffle a bounded-length string vector.
Detailed Description
D - shared3p protection domain |
Parameters
s |
- input string vector |
returns shuffled s |
None |
Function Overloads
bl_strShuffle(BlStringVector< D > s)
bl_strShuffle(key)
Shuffle a bounded-length string vector.
Detailed Description
D - shared3p protection domain |
Parameters
s |
- input string vector |
sLen |
- bound |
key |
- shuffle key |
returns shuffled s |
None |
Function Overloads
bl_strShuffle(BlStringVector< D > s, D uint8[[1]] key)
bl_strTrim
Function for trimming a string.
bl_strVectorLength
Calculate the length of a bounded-length string vector.
Detailed Description
D - shared3p protection domain |
Parameters
s |
- input string vector |
returns the length of s |
None |
Function Overloads
uint bl_strVectorLength(BlStringVector< D > s)
countZeroes
Count zeroes in the input vector.
findSortingPermutation
Function for finding a stable sorting permutation.
tdbReadBlStringColumn
Read a bounded-length string vector from a table_database table.
tdbVmapAddBlStringType
Add bounded-length string type to a type vector in a table_database vector map.
tdbVmapAddBlStringValue
Add a bounded-length string vector to a table_database vector map.
Detailed Description
D - shared3p protection domain |
Parameters
params |
- vector map |
key |
- key of vector in vector map |
vec |
- bounded length string vector |
None |
Function Overloads
void tdbVmapAddBlStringValue(uint params, string key, BlStringVector< D > vec)
tdbVmapGetBlString
Get bounded-length string vector from a table_database vector map.
zeroExtend
Extend an input string with zeroes.
Detailed Description
D - shared3p protection domain |
Supported types - xor_uint8 |
Parameters
s |
- an input string |
n |
- minimum size that we want the resulting string to be |
returns a vector that was created by zeroextending s |
size (output vector) >= n |
s is a prefix of the output vector |
only zeroes have been added to the output vector |
if size ( s ) >= n then the output vector == s |
None |
shared3p_kl_string
Module with functions for known length strings.
Functions:
kl_str
Function for constructing a known length string from given public string.
kl_strCat
Function for concatenating two strings.
kl_strContains
Function for checking whether a string contains a pattern or not.
kl_strDeclassify
Function for declassifying a given XOR shared byte string.
kl_strEqPrefixes
Function for checking whether a pattern is a substring of the input string.
Detailed Description
D - shared3p protection domain |
Supported types - xor_uint8 |
the pattern is not longer than the input string |
Parameters
str |
- the input string vector of supported type |
pat |
- the substring to look for |
returns a boolean vector indicating if the pattern is a substring of the input string in that position |
None |
kl_strEquals
Function for checking whether two strings are equal.
kl_strHamming
Function for finding the number of bytes two inputs differ in.
kl_strIndexOf
Function for finding the index of a given pattern in the input string.
kl_strIsLessThan
Function for comparing two strings alphabetically.
kl_strLength
Function for getting the length of a string.
kl_strLevenshtein
Function for finding the edit distance of two input strings.
Detailed Description
D - shared3p protection domain |
Supported types - xor_uint8 |
this is the classic dynamic programming implementation of Levenshtein distance that’s simply tuned to minimize the number of the "min" syscalls. Naive approach would invoke "min" O(n*m) times for strings of length n and m. The following implementation invokes the syscall O(n+m) times by computing the table diagonal at a time. |
Parameters
s, t |
- input string vectors of supported type |
returns the edit distance of the two input strings |
None |