'Fulfills a previous Transaction\'s Output by signing Inputs.
Note:
This method works only for the following Cryptoconditions
currently:
- Ed25519Fulfillment
- ThresholdSha256
Furthermore, note that all keys required to fully sign the
Transaction have to be passed to this method. A subset of all
will cause this method to fail.
Args:
private_keys (:obj:`list` of :obj:`str`): A complete list of
all private keys needed to sign all Fulfillments of this
Transaction.
Returns:
:class:`~bigchaindb.common.transaction.Transaction`'

def sign(self, private_keys):

    if ((private_keys is None) or (not isinstance(private_keys, list))):
        raise TypeError('`private_keys`    must    be    a    list    instance')
    def gen_public_key(private_key):
        public_key = private_key.get_verifying_key().encode()
        return public_key.decode()
    key_pairs = {gen_public_key(PrivateKey(private_key)): PrivateKey(private_key) for private_key in private_keys}
    tx_dict = self.to_dict()
    tx_dict = Transaction._remove_signatures(tx_dict)
    tx_serialized = Transaction._to_str(tx_dict)
    for (i, input_) in enumerate(self.inputs):
        self.inputs[i] = self._sign_input(input_, tx_serialized, key_pairs)
    return self
