Sign a Transaction with the private key of this account.

 If the account is unlocked, this is equivalent to
 `tx.sign(account.privkey)`.

 @param tx [Transaction] the transaction to sign
 @raise [ValueError] if the account is locked
550512
def sign_tx(tx)
      if privkey
        logger.info "signing tx", tx: tx, account: self
        tx.sign privkey
      else
        raise ValueError, "Locked account cannot sign tx"
      end
    end
765250
def SignMessage(self, message, script_hash):
        

        keypair = self.GetKeyByScriptHash(script_hash)
        prikey = bytes(keypair.PrivateKey)
        res = Crypto.Default().Sign(message, prikey)
        return res, keypair.PublicKey
793990
public static byte[] sign(byte[] text, PrivateKey key, String algorithm) throws SignatureException {
        Signature signature;
        try {
            signature = Signature.getInstance(algorithm);
            signature.initSign(key);
        } catch (GeneralSecurityException e) {
            throw new IllegalArgumentException("cannot initialize signature for algorithm " + algorithm, e);
        }
        signature.update(text);
        return signature.sign();
    }
813038
function sign(private_key, data) {
  var key = new bitcoinjs.ECKey(new BigInteger(private_key, 16), false);
  var hash = bitcoinjs.crypto.hash256(new Buffer(data, 'hex'));
  return key.sign(hash).toDER().toString('hex');
}
1078392
def AddTransaction(self, tx):
        
        if BC.Default() is None:
            return False

        if tx.Hash.ToBytes() in self.MemPool.keys():
            return False

        if BC.Default().ContainsTransaction(tx.Hash):
            return False

        if not tx.Verify(self.MemPool.values()):
            logger.error("Verifying tx result... failed")
            return False

        self.MemPool[tx.Hash.ToBytes()] = tx

        return True
677652
def sign_hmac(secret, payload)
      secret = secret.encode('ASCII')
      payload = payload.encode('ASCII')

      # Decode the private key
      raw_key = Base64.urlsafe_decode64(secret)

      # Create a signature using the private key and the URL
      digest = OpenSSL::Digest.new('sha1')
      raw_signature = OpenSSL::HMAC.digest(digest, raw_key, payload)

      # Encode the signature into base64 for url use form.
      signature =  Base64.urlsafe_encode64(raw_signature)
      return signature
    end
1347280
def broadcast_transaction(hex_tx, blockchain_client):
    
    if isinstance(blockchain_client, BitcoindClient):
        bitcoind = blockchain_client.bitcoind
    elif isinstance(blockchain_client, AuthServiceProxy):
        bitcoind = blockchain_client
    else:
        raise Exception('A BitcoindClient object is required')

    try:
        resp = bitcoind.sendrawtransaction(hex_tx)
    except httplib.BadStatusLine:
        raise Exception('Invalid HTTP status code from bitcoind.')

    if len(resp) > 0:
        return {'tx_hash': resp, 'success': True}
    else:
        raise Exception('Invalid response from bitcoind.')
1326662
def sign(ctx, filename):
    
    if filename:
        tx = filename.read()
    else:
        tx = sys.stdin.read()
    tx = TransactionBuilder(eval(tx), bitshares_instance=ctx.bitshares)
    tx.appendMissingSignatures()
    tx.sign()
    print_tx(tx.json())
65243
async function signTransaction (tx) {
  const networkId = this.getNetworkId()
  const rlpBinaryTx = Crypto.decodeBase64Check(Crypto.assertedType(tx, 'tx'))
  // Prepend `NETWORK_ID` to begin of data binary
  const txWithNetworkId = Buffer.concat([Buffer.from(networkId), rlpBinaryTx])

  const signatures = [await this.sign(txWithNetworkId)]
  return buildTx({ encodedTx: rlpBinaryTx, signatures }, TX_TYPE.signed).tx
}
1090303
def sign(self, h):
        
        if not self.is_private():
            raise RuntimeError("Key must be private to be able to sign")
        val = from_bytes_32(h)
        r, s = self._generator.sign(self.secret_exponent(), val)
        return sigencode_der(r, s)
496012
def sign_transaction(provider: Provider, unsigned: MutableTransaction,
                     key: Kutil) -> Transaction:
    ''''''

    parent_outputs = [find_parent_outputs(provider, i) for i in unsigned.ins]
    return key.sign_transaction(parent_outputs, unsigned)
1069526
def sign_with_privkey(
    digest: bytes,
    privkey: Ed25519PrivateKey,
    global_pubkey: Ed25519PublicPoint,
    nonce: int,
    global_commit: Ed25519PublicPoint,
) -> Ed25519Signature:
    
    h = _ed25519.H(privkey)
    a = _ed25519.decodecoord(h)

    S = (nonce + _ed25519.Hint(global_commit + global_pubkey + digest) * a) % _ed25519.l
    return Ed25519Signature(_ed25519.encodeint(S))
166087
def sign(self, msg, key):
        

        if not isinstance(key, ec.EllipticCurvePrivateKey):
            raise TypeError(
                "The private key must be an instance of "
                "ec.EllipticCurvePrivateKey")

        self._cross_check(key.public_key())
        num_bits = key.curve.key_size
        num_bytes = (num_bits + 7) // 8
        asn1sig = key.sign(msg, ec.ECDSA(self.hash_algorithm()))
        # Cryptography returns ASN.1-encoded signature data; decode as JWS
        # uses raw signatures (r||s)
        (r, s) = decode_dss_signature(asn1sig)
        return int_to_bytes(r, num_bytes) + int_to_bytes(s, num_bytes)
865946
def acquire(self, lock_transactions=None):
        

        if not self.personal_lock.acquire(timeout=self.lock_timeout):
            raise LockTimeoutError(self)

        self.with_count += 1

        if lock_transactions is None:
            lock_transactions = self.lock_transactions

        if lock_transactions and self.db_state.active_connection is not self:
            if not self.db_state.transaction_lock.acquire(timeout=self.lock_timeout):
                self.personal_lock.release()
                raise LockTimeoutError(self)

            self.db_state.active_connection = self

        if not self.db_state.lock.acquire(timeout=self.lock_timeout):
            self.personal_lock.release()

            if lock_transactions:
                self.db_state.active_connection = None
                self.db_state.transaction_lock.release()

            raise LockTimeoutError(self)

        try:
            # If the connection is closed, an exception is thrown
            in_transaction = self.in_transaction
        except sqlite3.ProgrammingError:
            in_transaction = False

        self.was_in_transaction = in_transaction
105246
def CreateKey(self, private_key=None):
        
        if private_key is None:
            private_key = bytes(Random.get_random_bytes(32))

        key = KeyPair(priv_key=private_key)
        self._keys[key.PublicKeyHash.ToBytes()] = key
        return key
728861
def broadcast_transaction(hex_tx, blockchain_client):
    
    if not isinstance(blockchain_client, ChainComClient):
        raise Exception('A ChainComClient object is required')

    auth = blockchain_client.auth
    if not auth or len(auth) != 2:
        raise Exception('ChainComClient object must have auth credentials.')

    url = CHAIN_API_BASE_URL + '/bitcoin/transactions/send'
    payload = json.dumps({ 'signed_hex': hex_tx })
    r = requests.post(url, data=payload, auth=auth)

    try:
        data = r.json()
    except ValueError, e:
        raise Exception('Received non-JSON from chain.com.')

    if 'transaction_hash' in data:
        reply = {}
        reply['tx_hash'] = data['transaction_hash']
        reply['success'] = True
        return reply
    else:
        raise Exception('Tx hash missing from chain.com response: ' + str(data) + '\noriginal: ' + str(payload))
1313936
def _make_txn(signer, setting_key, payload):
    
    serialized_payload = payload.SerializeToString()
    header = TransactionHeader(
        signer_public_key=signer.get_public_key().as_hex(),
        family_name='sawtooth_settings',
        family_version='1.0',
        inputs=_config_inputs(setting_key),
        outputs=_config_outputs(setting_key),
        dependencies=[],
        payload_sha512=hashlib.sha512(serialized_payload).hexdigest(),
        batcher_public_key=signer.get_public_key().as_hex()
    ).SerializeToString()

    return Transaction(
        header=header,
        header_signature=signer.sign(header),
        payload=serialized_payload)