예제 #1
0
    def _assert_validator_transaction(self, public_key, target_file):
        filename = os.path.join(self._temp_dir, target_file)
        batch_list = batch_pb.BatchList()
        with open(filename, 'rb') as batch_file:
            batch_list.ParseFromString(batch_file.read())

        self.assertEqual(1, len(batch_list.batches))

        batch = batch_list.batches[0]
        self.assertEqual(1, len(batch.transactions))
        batch_header = batch_pb.BatchHeader()
        batch_header.ParseFromString(batch.header)

        self.assertEqual(public_key, batch_header.signer_public_key)

        txn = batch.transactions[0]
        txn_header = txn_pb.TransactionHeader()
        txn_header.ParseFromString(txn.header)

        self.assertEqual(public_key, txn_header.signer_public_key)
        self.assertEqual('sawtooth_validator_registry', txn_header.family_name)

        payload = vr_pb.ValidatorRegistryPayload()
        payload.ParseFromString(txn.payload)
        self._assert_key_state(payload.signup_info.poet_public_key)
예제 #2
0
def create_batch(transactions, private_key, public_key):
    transaction_ids = [t.header_signature for t in transactions]

    header = batch_pb2.BatchHeader(signer_pubkey=public_key,
                                   transaction_ids=transaction_ids)

    header_bytes = header.SerializeToString()

    signature = signing.sign(header_bytes, private_key)

    batch = batch_pb2.Batch(header=header_bytes,
                            transactions=transactions,
                            header_signature=signature)

    return batch
def create_batch(transactions, signer):
    transaction_ids = [t.header_signature for t in transactions]

    header = batch_pb2.BatchHeader(
        signer_public_key=signer.get_public_key().as_hex(),
        transaction_ids=transaction_ids)

    header_bytes = header.SerializeToString()

    signature = signer.sign(header_bytes)

    batch = batch_pb2.Batch(header=header_bytes,
                            transactions=transactions,
                            header_signature=signature)

    return batch
예제 #4
0
def create_batch(transactions, private_key, public_key):
    transaction_signatures = [t.signature for t in transactions]

    header = batch_pb2.BatchHeader(
        signer=public_key,
        transaction_signatures=transaction_signatures)

    header_bytes = header.SerializeToString()

    signature = bitcoin.ecdsa_sign(
        header_bytes,
        private_key)

    batch = batch_pb2.Batch(
        header=header_bytes,
        transactions=transactions,
        signature=signature)

    return batch
예제 #5
0
def _create_batch(signer, transactions):
    """Creates a batch from a list of transactions and a signer, and signs
    the resulting batch with the given signing key.

    Args:
        signer (:obj:`Signer`): Cryptographic signer to sign the batch
        transactions (list of `Transaction`): The transactions to add to the
            batch.

    Returns:
        `Batch`: The constructed and signed batch.
    """
    txn_ids = [txn.header_signature for txn in transactions]
    batch_header = batch_pb.BatchHeader(
        signer_public_key=signer.get_public_key().as_hex(),
        transaction_ids=txn_ids).SerializeToString()

    return batch_pb.Batch(header=batch_header,
                          header_signature=signer.sign(batch_header),
                          transactions=transactions)
예제 #6
0
def _create_batch(pubkey, signing_key, transactions):
    """Creates a batch from a list of transactions and a public key, and signs
    the resulting batch with the given signing key.

    Args:
        pubkey (str): The public key associated with the signing key.
        signing_key (str): The private key for signing the batch.
        transactions (list of `Transaction`): The transactions to add to the
            batch.

    Returns:
        `Batch`: The constructed and signed batch.
    """
    txn_ids = [txn.header_signature for txn in transactions]
    batch_header = batch_pb.BatchHeader(
        signer_pubkey=pubkey, transaction_ids=txn_ids).SerializeToString()

    return batch_pb.Batch(header=batch_header,
                          header_signature=signing.sign(
                              batch_header, signing_key),
                          transactions=transactions)