Produces a WBB signature for a give message

@param sk Secret key
@param m  Message
@return Signature
513980
public static ECP weakBBSign(BIG sk, BIG m) {
        BIG exp = IdemixUtils.modAdd(sk, m, IdemixUtils.GROUP_ORDER);
        exp.invmodp(IdemixUtils.GROUP_ORDER);

        return IdemixUtils.genG1.mul(exp);
    }
462175
function sk(key) {
    if (globalKeySanitize) {
      return key;
    } else {
      return key.replace(/\s+/g, '_')
                .replace(/\//g, '-')
                .replace(/[^a-zA-Z_\-0-9\.]/g, '');
    }
  }
122001
def hmac_signature(string, shared_secret, challenge_hmac):
    '''
    
    '''
    msg = salt.utils.stringutils.to_bytes(string)
    key = salt.utils.stringutils.to_bytes(shared_secret)
    challenge = salt.utils.stringutils.to_bytes(challenge_hmac)
    hmac_hash = hmac.new(key, msg, hashlib.sha256)
    valid_hmac = base64.b64encode(hmac_hash.digest())
    return valid_hmac == challenge
1059572
def http_signature(message, key_id, signature):
    """"""
    template = ('Signature keyId="%(keyId)s",algorithm="hmac-sha256",'
                'headers="%(headers)s",signature="%(signature)s"')
    headers = ['(request-target)', 'host', 'accept', 'date']
    return template % {
        'keyId': key_id,
        'signature': signature,
        'headers': ' '.join(headers),
    }
590891
public static byte[] sign(
      Signature signatureAlgorithm, PrivateKey privateKey, byte[] contentBytes)
      throws InvalidKeyException, SignatureException {
    signatureAlgorithm.initSign(privateKey);
    signatureAlgorithm.update(contentBytes);
    return signatureAlgorithm.sign();
  }
801050
public StringBuffer getMessageKey(StringBuffer sb)
    {
        if ((this.getKeyInformation() & NOT_UNIQUE) == 0)
        {
            if (sb == null)
                sb = new StringBuffer();
            boolean bCompoundDataAdded = false;
            if ((this.getKeyInformation() & COMPOUND_PARAM) != 0)
            {
                String strSaveKey = this.getKey();
                String strBaseParam = strSaveKey;
                if (Character.isDigit(strSaveKey.charAt(strSaveKey.length() - 1)))
                    strBaseParam = strSaveKey.substring(0, strSaveKey.length() - 1);
                int iMaxParam = this.getKeyInformation() & COMPOUND_MASK;
                if (iMaxParam == 0)
                    iMaxParam = COMPOUND_MASK;
                for (int i = 1; i <= iMaxParam; i++)
                {
                    this.setKey(strBaseParam + Integer.toString(i));
                    String data = this.getString();
                    if (data != null)
                    {
                        if (sb.length() > 0)
                            sb.append('/');
                        sb.append(data);
                        if (data.length() > 0)
                            bCompoundDataAdded = true;
                    }
                    else
                        if (iMaxParam == COMPOUND_MASK)
                            break;  // If there are a unlimited number of params, stop on first null.
                }
                this.setKey(strSaveKey);
            }
            if (!bCompoundDataAdded)
            {
                if (sb.length() > 0)
                    sb.append('/');
                String data = this.getString();
                if (data != null)
                    sb.append(data);
            }
        }
        return sb;
    }
553568
public String sign(final String message) throws EncryptionException {
      try {
         Signature sign = Signature.getInstance("SHA1withRSA");
         sign.initSign(privateKey);
         sign.update(message.getBytes(DEFAULT_CHARSET));

         return new String(Base64.encodeBase64(sign.sign()), DEFAULT_CHARSET);
      } catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) {
         throw new EncryptionException("Unable to sign message: ", e);
      }
   }
294637
function crypto_sign(sm, m, n, sk) {
  var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
  var i, j, x = new Float64Array(64);
  var p = [gf(), gf(), gf(), gf()];

  crypto_hash(d, sk, 32);
  d[0] &= 248;
  d[31] &= 127;
  d[31] |= 64;

  var smlen = n + 64;
  for (i = 0; i < n; i++) sm[64 + i] = m[i];
  for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];

  crypto_hash(r, sm.subarray(32), n+32);
  reduce(r);
  scalarbase(p, r);
  pack(sm, p);

  for (i = 32; i < 64; i++) sm[i] = sk[i];
  crypto_hash(h, sm, n + 64);
  reduce(h);

  for (i = 0; i < 64; i++) x[i] = 0;
  for (i = 0; i < 32; i++) x[i] = r[i];
  for (i = 0; i < 32; i++) {
    for (j = 0; j < 32; j++) {
      x[i+j] += h[i] * d[j];
    }
  }

  modL(sm.subarray(32), x);
  return smlen;
}
752579
private static String createSignature(String     stringToSign,
                                          String     awsSecretKey,
                                          String     algorithm)
            throws SignatureException {

        assert stringToSign != null;
        assert awsSecretKey != null;
        assert algorithm != null;

        String signature;

        try {
            byte[] secretyKeyBytes = awsSecretKey.getBytes(UTF8_CHARSET);
            SecretKeySpec secretKeySpec = new SecretKeySpec(secretyKeyBytes,
                                                            algorithm);
            Mac mac = Mac.getInstance(algorithm);
            mac.init(secretKeySpec);

            byte[] data = stringToSign.getBytes(UTF8_CHARSET);

            byte[] rawHmac = mac.doFinal(data);
            signature = rfc3986Conformance(new String(Codec.base64Encode(rawHmac)));
        } catch (Exception e) {
            throw new SignatureException("Failed to generate HMAC : " +
                                                               e.getMessage());
        }

        return signature;
    }
806125
@Override
    public String sign(String message) {
        return sign(message, secret.getBytes(Charsets.UTF_8));
    }
1106941
public static ECKey signatureToKey(byte[] messageHash, ECDSASignature sig) throws SignatureException {
        final byte[] keyBytes = signatureToKeyBytes(messageHash, sig);
        return ECKey.fromPublicOnly(keyBytes);
    }
247779
function signature(m) {
    return m.get(f.signature)
            .orElse(_ => m.get(f.name))
            .getOrElse('(Anonymous)');
  }
236456
public static int crypto_sign_open(
  Sha512 sha512provider,
  byte[] m, long mlen,
  byte[] sm, long smlen,
  byte[] pk
)
{
  byte[] pkcopy = new byte[32];
  byte[] rcopy = new byte[32];
  byte[] scopy = new byte[32];
  byte[] h = new byte[64];
  byte[] rcheck = new byte[32];
  ge_p3 A = new ge_p3();
  ge_p2 R = new ge_p2();

  if (smlen < 64) return -1;
  if ((sm[63] & 224) != 0) return -1;
  if (ge_frombytes.ge_frombytes_negate_vartime(A,pk) != 0) return -1;

  byte[] pubkeyhash = new byte[64];
  sha512provider.calculateDigest(pubkeyhash,pk,32);

  System.arraycopy(pk, 0, pkcopy, 0, 32);
  System.arraycopy(sm, 0, rcopy, 0, 32);
  System.arraycopy(sm, 32, scopy, 0, 32);

  System.arraycopy(sm, 0, m, 0, (int)smlen);
  System.arraycopy(pkcopy, 0, m, 32, 32);
  sha512provider.calculateDigest(h,m,smlen);
  sc_reduce.sc_reduce(h);

  ge_double_scalarmult.ge_double_scalarmult_vartime(R,h,A,scopy);
  ge_tobytes.ge_tobytes(rcheck,R);
  if (crypto_verify_32.crypto_verify_32(rcheck,rcopy) == 0) {
    System.arraycopy(m, 64, m, 0, (int)(smlen - 64));
    //memset(m + smlen - 64,0,64);
    return 0;
  }

//badsig:
  //memset(m,0,smlen);
  return -1;
}
900164
def key_sign(rsakey, message, digest):
    """"""
    padding = _asymmetric.padding.PKCS1v15()
    signature = rsakey.sign(message, padding, digest)
    return signature
1085687
def encrypt(self, k, a, m):
        
        hkey = k[:_inbytes(self.keysize)]
        ekey = k[_inbytes(self.keysize):]

        # encrypt
        iv = _randombits(self.blocksize)
        cipher = Cipher(algorithms.AES(ekey), modes.CBC(iv),
                        backend=self.backend)
        encryptor = cipher.encryptor()
        padder = PKCS7(self.blocksize).padder()
        padded_data = padder.update(m) + padder.finalize()
        e = encryptor.update(padded_data) + encryptor.finalize()

        # mac
        t = self._mac(hkey, a, iv, e)

        return (iv, e, t)
881135
public ECDSASignature sign(byte[] messageHash) {
        ECDSASignature sig = doSign(messageHash);
        // Now we have to work backwards to figure out the recId needed to recover the
        // signature.
        int recId = -1;
        byte[] thisKey = this.pub.getEncoded(/* compressed */ false);
        for (int i = 0; i < 4; i++) {
            byte[] k = ECKey.recoverPubBytesFromSignature(i, sig, messageHash);
            if (k != null && Arrays.equals(k, thisKey)) {
                recId = i;
                break;
            }
        }
        if (recId == -1)
            throw new RuntimeException("Could not construct a recoverable key. This should never happen.");
        sig.v = (byte) (recId + 27);
        return sig;
    }
690504
public static TransactionWitness redeemP2WPKH(@Nullable TransactionSignature signature, ECKey pubKey) {
        checkArgument(pubKey.isCompressed(), "only compressed keys allowed");
        TransactionWitness witness = new TransactionWitness(2);
        witness.setPush(0, signature != null ? signature.encodeToBitcoin() : new byte[0]); // signature
        witness.setPush(1, pubKey.getPubKey()); // pubkey
        return witness;
    }