コード例 #1
0
def test_int_share_recover():
    num_players = 5
    reconstruction_threshold = 3

    secret = 123456789
    max_secret_length = len(str(secret))
    shares = sss._share_secret_int(num_players, reconstruction_threshold, max_secret_length, secret)
    recovered_secret = sss._reconstruct_secret_int(num_players, max_secret_length, shares[:reconstruction_threshold])
    assert recovered_secret == secret
コード例 #2
0
ファイル: rss.py プロジェクト: michsoch/robust-secret-sharing
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))