def Combine(shares: list): """Combine a list of shares to form a secret if the minimum number required is supplied. Args: shares(list): List of shares. Returns: str: secret """ secret = PlaintextToHexSecretSharer().recover_secret(shares) return secret
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.add_routes([ web.post('/create_identity', self._create_identity), web.post('/secret_sharding', self._secret_sharding), web.post('/secret_recovery', self._secret_recovery), ]) self._wallet_handle = None self._secret_sharer = PlaintextToHexSecretSharer()
def Split(secret: str, min_req: int, total_shares: int): """Split a secret into shares. Args: secret(str): Secret data representated as a string min_req(int): Minimum shares required to combine to form secret. total_shares(int): Total shares to split the secret into. Returns: list: shares """ if min_req >= total_shares: raise ValueError( 'Total shares must be more than minimum required.') shares = PlaintextToHexSecretSharer().split_secret( secret, min_req, total_shares) return shares