Пример #1
0
def _get_bytestring_secret(shares, num_players, max_secret_length):
    '''
    Args:
        shares, a list of paired integer shares (see schemes/pairing.py)
        num_players, the number of total players
        max_secret_length, the max length of the share if it were represented as a bytestring
    Returns:
        the original secret as passed to share_authenticated_secret if all shares are valid
        otherwise, no guarantees are made about the value of the bytestring returned
    '''
    tuple_shares = [pairing.elegant_unpair(share) for share in shares]
    return serialization.convert_int_to_bytestring(sss._reconstruct_secret_int(num_players, max_secret_length + 1, tuple_shares))
Пример #2
0
def reconstruct_secret(num_players, max_secret_length, shares):
    '''
    Args:
        num_players, the total number of players (can be greater than or equal to the number of shares)
        max_secret_length, the maximum length of the secret represented as a bytestring (ie, len(secret))
        shares, a list of strings - each representing an integer value
    Returns:
        the original secret as passed to share_authenticated_secret if all shares are valid
        otherwise, no guarantees are made about the value of the bytestring returned
    '''
    points = [pairing.elegant_unpair(int(share)) for share in shares]
    secret_int = _reconstruct_secret_int(num_players, max_secret_length + 1, points)
    return serialization.convert_int_to_bytestring(secret_int)
def run_pair_unpair(tup):
    z = pairing.elegant_pair(tup[0], tup[1])
    result = pairing.elegant_unpair(z)
    return tup == result