예제 #1
0
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])
예제 #2
0
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])