def test_bad_configuration_threshold():
    num_players = 2
    reconstruction_threshold = 5

    max_secret_length = len(secret)

    with pytest.raises(ValueError):
        sss.share_secret(num_players, reconstruction_threshold, max_secret_length, secret)
def test_bad_configuration_prime_small_secret():
    num_players = 5
    reconstruction_threshold = 2

    bad_secret = '\xFF\xFF'
    max_secret_length = len(bad_secret) - 1

    with pytest.raises(ValueError):
        sss.share_secret(num_players, reconstruction_threshold, max_secret_length, bad_secret)
def share_and_break(num_players, reconstruction_threshold, secret, end, num_broken):
    max_secret_length = len(secret)
    shares = sss.share_secret(num_players, reconstruction_threshold, max_secret_length, secret)

    broken_shares = []
    for share in shares[:num_broken]:
        if share.startswith('1'):
            broken_shares.append('2' + share[1:])
        else:
            broken_shares.append('1' + share[1:])

    return sss.reconstruct_secret(num_players, max_secret_length, broken_shares + shares[:num_broken])
def share_and_recover(num_players, reconstruction_threshold, secret, end):
    max_secret_length = len(secret)
    shares = sss.share_secret(num_players, reconstruction_threshold, max_secret_length, secret)
    return sss.reconstruct_secret(num_players, max_secret_length, shares[:end])
def test_bad_configuration_prime_none():
    num_players = 40
    reconstruction_threshold = 30

    with pytest.raises(ValueError):
        sss.share_secret(num_players, reconstruction_threshold, 5000, secret)