shamir.shamir_secret_sharing_integers module

Utility for Shamir secret sharing over the integers.

class shamir.shamir_secret_sharing_integers.IntegerShares(shamir_sss, shares, degree, scaling)[source]

Bases: SupportsSerialization

Class that keeps track of the shares for a certain value that is secret shared over the integers.

class SerializedIntegerShares[source]

Bases: TypedDict

Class which contains the information of the integer shares from which deserialization is possible.

degree: int
scaling: int
scheme: SerializedShamirSecretSharingIntegers
shares: dict[int, int]
__add__(other)[source]

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

Parameters:

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

Raises:

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

Return type:

IntegerShares

Returns:

New IntegerShares object where the shares have been added together.

__eq__(other)[source]

Compare equality between this IntegerShares and the other object.

Parameters:

other (object) – Object to compare with.

Return type:

bool

Returns:

Boolean stating (in)equality

__mul__(other)[source]

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

Parameters:

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

Return type:

IntegerShares

Returns:

New IntegerShares object where the shares have been multiplied together.

__rmul__(other)[source]

Multiply the shares belonging to this value with a given scalar integer or ShamirShares object.

Parameters:

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

Return type:

Any

Returns:

New IntegerShares object where the shares have been multiplied together.

static deserialize(obj, **_kwargs)[source]

Deserialization function for the integer shares and corresponding scheme, which will be passed to the communication module

Parameters:
  • obj (SerializedIntegerShares) – serialization of the integer shares.

  • **_kwargs (Any) – optional extra keyword arguments

Return type:

IntegerShares

Returns:

Deserialized IntegerShares object.

reconstruct_secret(modulus=0)[source]

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

Parameters:

modulus (int) – the modulus to use

Raises:

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

Return type:

int

Returns:

original secret

serialize(**_kwargs)[source]

Serialization function for the integer shares and corresponding scheme, which will be passed to the communication module

Parameters:

**_kwargs (Any) – optional extra keyword arguments

Return type:

SerializedIntegerShares

Returns:

Dictionary containing the serialization of this IntegerShare object.

class shamir.shamir_secret_sharing_integers.ShamirSecretSharingIntegers(kappa=40, max_int=5, number_of_parties=10, polynomial_degree=4)[source]

Bases: SupportsSerialization

Class with Shamir Secret sharing functionality over the integers

class SerializedShamirSecretSharingIntegers[source]

Bases: TypedDict

Class which contains the information of the shamir secret share from which deserialization is possible.

kappa: int
max_int: int
number_of_parties: int
polynomial_degree: int
__eq__(other)[source]

Compare equality between this ShamirSecretSharingIntegers and the other object.

Parameters:

other (object) – Object to compare with.

Return type:

bool

Returns:

Boolean stating (in)equality

__init__(kappa=40, max_int=5, number_of_parties=10, polynomial_degree=4)[source]

Initialize a secret sharing over the integers

Parameters:
  • kappa (int) – statistical security parameter

  • max_int (int) – Value that together with kappa and number_of_parties determines the interval from which polynomial coefficients are randomly sampled. In general, the Paillier modulus is used for max.

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

  • polynomial_degree (int) – degree of polynomials used to share secrets

static deserialize(obj, **_kwargs)[source]

Deserialization function for the shamir secret sharing integers scheme, which will be passed to the communication module

Parameters:
Return type:

ShamirSecretSharingIntegers

Returns:

Deserialized ShamirSecretSharingInteger scheme.

serialize(**_kwargs)[source]

Serialization function for the shamir secret sharing integers scheme, which will be passed to the communication module

Parameters:

**_kwargs (Any) – optional extra keyword arguments

Return type:

SerializedShamirSecretSharingIntegers

Returns:

Dictionary containing the serialization of this ShamirSecretSharingIntegers scheme.

share_secret(secret)[source]

Function that creates shares of a value for each party

Parameters:

secret (int) – secret to be shared

Return type:

IntegerShares

Returns:

sharing of the secret

property van_der_monde: list[list[int]]

Vandermonde matrix for evaluation of polynomials at points [1,..,n]. This essentialy creates a matrix that precomputes i**j for all possible i**j that are needed for the evaluation of sharing polynomials. We now have that i**j = Vm[i][j]. To evaluate a polynomial p(x) = a0 + a1 * x + … + ad * x**d we can simply compute a0 * Vm[x][0] + a1 * Vm[x][1] + … + ad * Vm[x][d].

Returns:

A VanDerMonde matrix of dimpensions self.polynomial_degree + 1 x self.number_of_parties