exponentiation.utils module

Utility functions for exponent.py

exponentiation.utils.convert_to_secfxp(to_convert, secfxp)[source]

Converts (list of) to_convert of secure type to secfxp. Secfxp is assumed to have more fractional bits than type(to_convert).

Parameters:
  • to_convert (Union[SecureFixedPoint, List[SecureFixedPoint]]) – (list of) secure type

  • secfxp (Type[SecureFixedPoint]) – type to use for conversion

Return type:

Union[SecureFixedPoint, List[SecureFixedPoint]]

Returns:

converted (list of) secure fixed points

exponentiation.utils.convert_to_secint(to_convert)[source]

Converts (list of) to_convert of secure type to secint with the same modulus. to_convert is assumed to be a share of an integer.

Parameters:

to_convert (Union[SecureFixedPoint, List[SecureFixedPoint]]) – (list of) secure type

Return type:

Union[SecureInteger, List[SecureInteger]]

Returns:

converted (list of) secure integers

exponentiation.utils.secure_ge_vec(value_or_list_1, value_or_list_2, strict=False)[source]

Securely performs \(a >= b\) elementwise.

Parameters:
  • value_or_list_1 (Union[List[TypeVar(SecureNumberType, bound= SecureNumber)], TypeVar(SecureNumberType, bound= SecureNumber)]) – first list or single value to use in comparison

  • value_or_list_2 (Union[List[TypeVar(SecureNumberType, bound= SecureNumber)], TypeVar(SecureNumberType, bound= SecureNumber)]) – second list or single value to use in comparison

  • strict (bool) – set to true to perform \(>\) instead of \(>=\)

Return type:

Union[TypeVar(SecureNumberType, bound= SecureNumber), List[TypeVar(SecureNumberType, bound= SecureNumber)]]

Returns:

bitvector containing the result of the comparison

Raises:

ValueError – raised when the two imput vectors have unequal (\(>1\)) lengths