SSS (sss v0.1.0)

View Source

Documentation for SSS.

Summary

Functions

Takes a string array of shares encoded in Base64 or Hex created via Shamir's Algorithm

Takes a string array of shares encoded in Base64 or Hex created via Shamir's Algorithm

Returns a new array of secret shares (encoding x,y pairs as Base64 or Hex strings) created by Shamir's Secret Sharing Algorithm requiring a minimum number of share to recreate, of length shares, from the input secret raw as a string.

Returns a new array of secret shares (encoding x,y pairs as Base64 or Hex strings) created by Shamir's Secret Sharing Algorithm requiring a minimum number of share to recreate, of length shares, from the input secret raw as a string.

Takes a string array of shares encoded in Base64 created via Shamir's Algorithm. Each string must be of equal length of a multiple of 88 characters as a single 88 character share is a pair of 256-bit numbers (x, y).

Takes a string array of shares encoded in Hex created via Shamir's Algorithm. Each string must be of equal length of a multiple of 128 characters as a single 128 character share is a pair of 256-bit numbers (x, y).

Returns the number base64 in base 10 Int representation. note: this is not coming from a string representation; the base64 input is exactly 256 bits long, and the output is an arbitrary size base 10 integer.

Returns the number Hex in base 10 Int representation. note: this is not coming from a string representation; the Hex input is exactly 256 bits long, and the output is an arbitrary size base 10 integer.

Create a Zero Matrix(mxn) m-row and n-column

Create a l-layer, m-row, n-column zero matrix(lxmxn)

Get an Element in a 2D Matrix(mxn) at index x-row, y-column

Get an Element in a 3D Matrix(lxmxn) at index x-layer, y-row, z-column

Takes in a given string to check if it is a valid secret

Takes in a given string to check if it is a valid secret

Converts an array of Ints to the original string secret, removing any least significant nulls.

Computes the multiplicative inverse of the number on the field @prime.

Returns a random number from the range 1 <= n <= @prime-1 inclusive

Converts a string secret into a 256-bit Int array, array based upon size of the input string. All values are right-padded to length 256, even if the most significant bit is zero.

Returns the Int number base10 in base64 representation. note: this is not a string representation; the base64 output is exactly 256 bits long.

Returns the Int number base10 in Hex representation. note: this is not a string representation; the Hex output is exactly 256 bits long.

Update an Element in a 2D Matrix(mxn) at index x-row, y-column

Update an Element in a 3D Matrix(lxmxn) at index x-layer, y-row, z-column

Validator combine shares input.

Functions

combine(shares, is_base64)

Takes a string array of shares encoded in Base64 or Hex created via Shamir's Algorithm

Note: the polynomial will converge if the specified minimum number of shares
      or more are passed to this function. Passing thus does not affect it
      Passing fewer however, simply means that the returned secret is wrong.

combine!(shares, is_base64)

Takes a string array of shares encoded in Base64 or Hex created via Shamir's Algorithm

Note: the polynomial will converge if the specified minimum number of shares
      or more are passed to this function. Passing thus does not affect it
      Passing fewer however, simply means that the returned secret is wrong.

create(minimum, shares, secret, is_base64)

Returns a new array of secret shares (encoding x,y pairs as Base64 or Hex strings) created by Shamir's Secret Sharing Algorithm requiring a minimum number of share to recreate, of length shares, from the input secret raw as a string.

create!(minimum, shares, secret, is_base64)

Returns a new array of secret shares (encoding x,y pairs as Base64 or Hex strings) created by Shamir's Secret Sharing Algorithm requiring a minimum number of share to recreate, of length shares, from the input secret raw as a string.

decode_share_base64(shares)

Takes a string array of shares encoded in Base64 created via Shamir's Algorithm. Each string must be of equal length of a multiple of 88 characters as a single 88 character share is a pair of 256-bit numbers (x, y).

decode_share_hex(shares)

Takes a string array of shares encoded in Hex created via Shamir's Algorithm. Each string must be of equal length of a multiple of 128 characters as a single 128 character share is a pair of 256-bit numbers (x, y).

from_base64(base64_str)

Returns the number base64 in base 10 Int representation. note: this is not coming from a string representation; the base64 input is exactly 256 bits long, and the output is an arbitrary size base 10 integer.

from_hex(hex)

Returns the number Hex in base 10 Int representation. note: this is not coming from a string representation; the Hex input is exactly 256 bits long, and the output is an arbitrary size base 10 integer.

gen_zero_matrix_2d(m, n)

Create a Zero Matrix(mxn) m-row and n-column

gen_zero_matrix_3d(l, m, n)

Create a l-layer, m-row, n-column zero matrix(lxmxn)

get_matrix_2d(matrix, x, y)

Get an Element in a 2D Matrix(mxn) at index x-row, y-column

get_matrix_3d(matrix_3d, x, y, z)

Get an Element in a 3D Matrix(lxmxn) at index x-layer, y-row, z-column

get_prime()

is_valid_share_base64(candidate)

Takes in a given string to check if it is a valid secret

Requirements: Length multiple of 88 Can decode each 44 character block as Base64

Returns raise if exist

is_valid_share_hex(candidate)

Takes in a given string to check if it is a valid secret

Requirements:

Length multiple of 128
Can decode each 64 character block as Hex

Returns raise if exist

merge_int_to_string(secrets)

Converts an array of Ints to the original string secret, removing any least significant nulls.

modinv(a, m)

Computes the multiplicative inverse of the number on the field @prime.

random_number()

Returns a random number from the range 1 <= n <= @prime-1 inclusive

split_secret_to_int(secret)

Converts a string secret into a 256-bit Int array, array based upon size of the input string. All values are right-padded to length 256, even if the most significant bit is zero.

to_base64(number)

Returns the Int number base10 in base64 representation. note: this is not a string representation; the base64 output is exactly 256 bits long.

to_hex(number)

Returns the Int number base10 in Hex representation. note: this is not a string representation; the Hex output is exactly 256 bits long.

update_matrix_2d(matrix, x, y, value)

Update an Element in a 2D Matrix(mxn) at index x-row, y-column

update_matrix_3d(matrix_3d, x, y, z, value)

Update an Element in a 3D Matrix(lxmxn) at index x-layer, y-row, z-column

validator_combine(shares, is_base64)

Validator combine shares input.

validator_create(minimum, shares, secret)