distributed_keygen.shamir_secret_sharing module

Utility for Shamir secret sharing.

class distributed_keygen.shamir_secret_sharing.ShamirSecretSharingScheme(modulus, number_of_parties, polynomial_degree)[source]

Bases: object

Class with Shamir Secret sharing functionality

__eq__(other)[source]

Compare equality between this ShamirSecretSharingScheme and the other object. :type other: object :param other: Object to compare with. :rtype: bool :return: Boolean stating (in)equality

__init__(modulus, number_of_parties, polynomial_degree)[source]

Initialize a t-out-of-n secret sharing scheme where - t = polynomial_degree + 1 - n = number_of_parties

Note that polynomial_degree is the same as the corruption threshold.

Parameters:
  • modulus (int) – prime modulus of the coefficients in the polynomials used to create shares

  • number_of_parties (int) – number of shares that need to be created for each sharing

  • polynomial_degree (int) – degree of the polynomials used to create shares

serialize()[source]

Serialization function

Return type:

Dict[str, Dict[str, int]]

Returns:

json object containing the necessary information to deserialize

share_secret(secret)[source]

Function that creates shares of a value for each party

Parameters:

secret (int) – secret to be shared

Return type:

ShamirShares

Returns:

sharing of the secret

class distributed_keygen.shamir_secret_sharing.ShamirShares(shamir_sss, shares)[source]

Bases: object

Class that keeps track of the shares for a certain value

__add__(other)[source]

Add the shares belonging to the two given ShamirShares values together.

Parameters:

other (ShamirShares) – Shares to be added to these shares.

Raises:

ValueError – In case a different secret sharing scheme was used.

Return type:

ShamirShares

Returns:

New ShamirShares object where the shares have been added together.

__mul__(other)[source]

Multiply the shares belonging to the two given ShamirShares values together. Only possible when both schemes are the same.

Parameters:

other (ShamirShares) – Shares to be multiplied with these shares.

Return type:

ShamirShares

Returns:

New ShamirShares object where the shares have been multiplied together.

__rmul__(other)[source]

Multiply the shares belonging to this value with a given scalar integer or IntegerShares object. Note: This operation returns a Shamir sharing which inherits the statistical security of the integer sharing and should therefore only be used with caution.

Parameters:

other (Any) – IntegerShares or scalar to be multiplied with these shares.

Raises:

ValueError – raised when shares are incompatible.

Return type:

ShamirShares

Returns:

New ShamirShares object where the shares have been multiplied together.

__str__()[source]

String formatted version of this ShamirShares object. :rtype: str :return: Pretty string.

reconstruct_secret()[source]

Function that uses the shares from other parties to reconstruct the secret

Raises:

ValueError – In case not enough shares are known to reconstruct the secret.

Return type:

int

Returns:

original secret

serialize()[source]

Serialization function

Return type:

Dict[str, Dict[str, Union[int, Dict[int, int], Dict[str, Dict[str, int]]]]]

Returns:

json object containing the necessary information to deserialize