Sign 'm' with the PrivKey 'key' and update our own 'sig_val'.
        Note that, even when 'sig_alg' is not None, we use the signature scheme
        of the PrivKey (neither do we care to compare the both of them).
490087
def _update_sig(self, m, key):
        
        if self.sig_alg is None:
            if self.tls_session.tls_version >= 0x0300:
                self.sig_val = key.sign(m, t='pkcs', h='md5-sha1')
            else:
                self.sig_val = key.sign(m, t='pkcs', h='md5')
        else:
            h, sig = _tls_hash_sig[self.sig_alg].split('+')
            if sig.endswith('pss'):
                t = "pss"
            else:
                t = "pkcs"
            self.sig_val = key.sign(m, t=t, h=h)
404129
function privKeyToPubKey(privKey, toCompressed) {
  toCompressed = toCompressed || false;

  const pkBuffer = Buffer.from(privKey, 'hex');
  var publicKey = secp256k1.publicKeyCreate(pkBuffer, toCompressed);
  return publicKey.toString('hex');
}
683786
def sign(s, passphrase, sig_format=SER_COMPACT, curve='secp160r1'):
    
    if isinstance(s, six.text_type):
        raise ValueError("Encode `s` to a bytestring yourself to" +
                         " prevent problems with different default encodings")
    curve = Curve.by_name(curve)
    privkey = curve.passphrase_to_privkey(passphrase)
    return privkey.sign(hashlib.sha512(s).digest(), sig_format)
1304284
def sign(self, byts):
        '''
        
        '''
        chosen_hash = c_hashes.SHA256()
        hasher = c_hashes.Hash(chosen_hash, default_backend())
        hasher.update(byts)
        digest = hasher.finalize()
        return self.priv.sign(digest,
                              c_ec.ECDSA(c_utils.Prehashed(chosen_hash))
                              )
1176028
def sign_message(self, key, message, verbose=False):
        
        secret_exponent = key.secret_exponent()
        if not secret_exponent:
            raise ValueError("Private key is required to sign a message")

        addr = key.address()

        msg_hash = self.hash_for_signing(message)
        is_compressed = key.is_compressed()

        sig = self.signature_for_message_hash(secret_exponent, msg_hash, is_compressed)

        if not verbose or message is None:
            return sig

        return self.signature_template.format(
            msg=message, sig=sig, addr=addr,
            net_name=self._network_name.upper())
951117
function setKey(key, val, ex, px, flag, req) {
  var saved = HashMap.prototype.setKey.apply(this, arguments);
  if(req && req.def) {
    this.modified(req);
  }
  return saved;
}
1499
function _sign($key, $signatureAlgorithm)
    {
        if ($key instanceof RSA) {
            switch ($signatureAlgorithm) {
                case 'md2WithRSAEncryption':
                case 'md5WithRSAEncryption':
                case 'sha1WithRSAEncryption':
                case 'sha224WithRSAEncryption':
                case 'sha256WithRSAEncryption':
                case 'sha384WithRSAEncryption':
                case 'sha512WithRSAEncryption':
                    $key->setHash(preg_replace('#WithRSAEncryption$#', '', $signatureAlgorithm));
                    $key->setSignatureMode(RSA::SIGNATURE_PKCS1);

                    $this->currentCert['signature'] = base64_encode("\0" . $key->sign($this->signatureSubject));
                    return $this->currentCert;
            }
        }

        return false;
    }
1357291
public void setSigningKey(String key) {
		Assert.hasText(key);
		key = key.trim();

		this.signingKey = key;

		if (isPublic(key)) {
			signer = new RsaSigner(key);
			logger.info("Configured with RSA signing key");
		}
		else {
			// Assume it's a MAC key
			this.verifierKey = key;
			signer = new MacSigner(key);
		}
	}
909783
def Sign(verifiable, keypair):
        
        prikey = bytes(keypair.PrivateKey)
        hashdata = verifiable.GetHashData()
        res = Crypto.Default().Sign(hashdata, prikey)
        return res
692267
function signStr(str, key) {
  var hmac = crypto.createHmac('sha1', key);
  hmac.update(str);
  return hmac.digest('base64').replace(/\+/g, '-').replace(/\//g, '_');
}
922106
def add_key(self, key_name, private):
        
        payload = {
            'name': key_name,
            'priv': private
        }

        data = json.dumps(payload)

        req = self.request(self.uri + '/keys', data=data)
        response = req.put().json()

        self.update_keys()
        return response
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))
350789
def _handle_status(self, key, value):
        
        if key in (
                "USERID_HINT",
                "NEED_PASSPHRASE",
                "BAD_PASSPHRASE",
                "GOOD_PASSPHRASE",
                "MISSING_PASSPHRASE",
                "PINENTRY_LAUNCHED",
                "BEGIN_SIGNING",
                "CARDCTRL",
                "INV_SGNR",
                "SIGEXPIRED",
                "KEY_CONSIDERED",
            ):
            self.status = key.replace("_", " ").lower()
        elif key == "SIG_CREATED":
            (self.sig_type, self.sig_algo, self.sig_hash_algo,
             self.what, self.timestamp, self.fingerprint) = value.split()
        elif key == "KEYEXPIRED":
            self.status = "skipped signing key, key expired"
            if (value is not None) and (len(value) > 0):
                 self.status += " on {}".format(str(value))
        elif key == "KEYREVOKED":
            self.status = "skipped signing key, key revoked"
            if (value is not None) and (len(value) > 0):
                 self.status += " on {}".format(str(value))
        elif key == "NODATA":
            self.status = nodata(value)
        elif key == "PROGRESS":
            self.status = progress(value.split(' ', 1)[0])
        else:
            raise ValueError("Unknown status message: %r" % key)
679589
def sign(self, msg, key):
        

        if not isinstance(key, rsa.RSAPrivateKey):
            raise TypeError(
                "The key must be an instance of rsa.RSAPrivateKey")
        sig = key.sign(msg, self.padding, self.hash)
        return sig
373584
def gen_signature(self, privkey, pubkey, sig_path):
        '''
        
        '''
        return salt.crypt.gen_signature(privkey,
                                        pubkey,
                                        sig_path,
                                        self.passphrase)
11372
function signTx (tx, privKey) {
  if (!tx.match(/^tx\_.+/)) {
    throw Error('Not a valid transaction')
  }

  const binaryKey = (() => {
    if (program.file) {
      return fs.readFileSync(program.file)
    } else if (privKey) {
      return Buffer.from(privKey, 'hex')
    } else {
      throw Error('Must provide either [privkey] or [file]')
    }
  })()

  const decryptedKey = program.password ? Crypto.decryptKey(program.password, binaryKey) : binaryKey

  // Split the base58Check part of the transaction
  const base58CheckTx = tx.split('_')[1]
  // ... and sign the binary create_contract transaction
  const binaryTx = Crypto.decodeBase58Check(base58CheckTx)

  const signature = Crypto.sign(binaryTx, decryptedKey)

  // the signed tx deserializer expects a 4-tuple:
  // <tag, version, signatures_array, binary_tx>
  const unpackedSignedTx = [
    Buffer.from([11]),
    Buffer.from([1]),
    [Buffer.from(signature)],
    binaryTx
  ]

  console.log(Crypto.encodeTx(unpackedSignedTx))
}
385703
public String sign(String privateKeyId, String message) {
		Base64EncodedSigner signer = cache.get(privateKeyId);

		if (signer != null) {
			return signer.sign(message);
		}

		Base64EncodedSignerImpl signerImpl = new Base64EncodedSignerImpl();
		signerImpl.setAlgorithm(algorithm);
		signerImpl.setCharsetName(charsetName);
		signerImpl.setProvider(provider);
		PrivateKey privateKey = privateKeyMap.get(privateKeyId);

		if (privateKey == null) {
			throw new SignatureException("private key not found: privateKeyId=" + privateKeyId);
		}

		signerImpl.setPrivateKey(privateKey);
		cache.put(privateKeyId, signerImpl);
		return signerImpl.sign(message);
	}