Verify a Curve25519 signature.

@param publicKey The Curve25519 public key the signature belongs to.
@param message The message that was signed.
@param signature The signature to verify.
@return true if valid, false if not.
960363
public boolean verifySignature(byte[] publicKey, byte[] message, byte[] signature) {
    if (publicKey == null || publicKey.length != 32) {
      throw new IllegalArgumentException("Invalid public key!");
    }

    if (message == null || signature == null || signature.length != 64) {
      return false;
    }

    return provider.verifySignature(publicKey, message, signature);
  }
455040
function verifySecondSignature (transaction, publicKey) {
	var bytes = getBytes(transaction);
	var data2 = Buffer.alloc(bytes.length - 64);

	for (var i = 0; i < data2.length; i++) {
		data2[i] = bytes[i];
	}

	var hash = crypto.createHash('sha256').update(data2.toString('hex'), 'hex').digest();

	var signSignatureBuffer = Buffer.from(transaction.signSignature, 'hex');
	var publicKeyBuffer = Buffer.from(publicKey, 'hex');
	var res = naclInstance.crypto_sign_verify_detached(signSignatureBuffer, hash, publicKeyBuffer);

	return res;
}
1233995
public boolean verify() throws SignatureException {
        if (verified)
            return verifyResult;
        if (sigAttr != null) {
            sig.update(sigAttr);
            if (RSAdata != null) {
                byte msd[] = messageDigest.digest();
                messageDigest.update(msd);
            }
            verifyResult = (Arrays.equals(messageDigest.digest(), digestAttr) && sig.verify(digest));
        }
        else {
            if (RSAdata != null)
                sig.update(messageDigest.digest());
            verifyResult = sig.verify(digest);
        }
        verified = true;
        return verifyResult;
    }
642382
public byte[] calculateVrfSignature(byte[] privateKey, byte[] message) {
    if (privateKey == null || privateKey.length != 32) {
      throw new IllegalArgumentException("Invalid private key!");
    }

    byte[] random = provider.getRandom(64);
    return provider.calculateVrfSignature(random, privateKey, message);
  }
1273177
public String sign(String message) {
		try {
			final byte[] signature = signer.sign(message.getBytes(charsetName));
			return new String(Base64.encodeBase64(signature, false));
		} catch (UnsupportedEncodingException e) {
			throw new SignatureException("unsupported encoding: charsetName=" + charsetName, e);
		}
	}
1276349
public static void checkClassSignature(final String signature) {
        // ClassSignature:
        // FormalTypeParameters? ClassTypeSignature ClassTypeSignature*

        int pos = 0;
        if (getChar(signature, 0) == '<') {
            pos = checkFormalTypeParameters(signature, pos);
        }
        pos = checkClassTypeSignature(signature, pos);
        while (getChar(signature, pos) == 'L') {
            pos = checkClassTypeSignature(signature, pos);
        }
        if (pos != signature.length()) {
            throw new IllegalArgumentException(signature + ": error at index "
                    + pos);
        }
    }
467598
private boolean verifyUsingPublicKey(byte[] data, byte[] signature, PublicKey pubKey)
            throws GeneralSecurityException {
        Signature sig = Signature.getInstance("SHA256withRSA");
        sig.initVerify(pubKey);
        sig.update(data);
        return sig.verify(signature);
    }
1294400
function verify(publicKeys, sig, text) {
    // Parse signature.
    validateBase64(sig);
    const binsig = Buffer.from(sig, 'base64');

    // Check signature length.
    if (binsig.length !== 10 + nacl.sign.signatureLength) {
        throw new Error('Bad signature length');
    }

    // Check signature algorithm.
    if (binsig[0] !== 69 /* 'E' */ || binsig[1] !== 100 /* 'd' */) {
        throw new Error('Unknown signature algorithm');
    }

    // Find the appropriate key for signature based on
    // algorithm and public key fingerprint embedded into signature.
    let key = null;
    for (let i = 0; i < publicKeys.length; i++) {
        const binkey = Buffer.from(publicKeys[i], 'base64');

        // Check public  key format.
        if (binkey.length !== 10 + nacl.sign.publicKeyLength) {
            throw new Error('Bad public key length');
        }

        // If algorithm (2 bytes) and key number (8) bytes match,
        // we found the needed key.
        if (nacl.verify(binkey.subarray(0, 10), binsig.subarray(0, 10))) {
            key = binkey;
            break;
        }
    }
    if (!key) {
        throw new Error('Invalid signature: no matching key found');
    }

    const bintext = Buffer.from(text, 'utf8');
    if (!nacl.sign.detached.verify(bintext, binsig.subarray(10), key.subarray(10))) {
        throw new Error('Invalid signature');
    }
}
86946
def verify(self, signature):
        
        try:
            payload = self._payload()
            sigin = b'.'.join([self.protected.encode('utf-8'), payload])
            self.engine.verify(self.key, sigin, signature)
        except Exception as e:  # pylint: disable=broad-except
            raise InvalidJWSSignature('Verification failed', repr(e))
        return True
609721
def verify_message(self, key_or_address, signature, message=None, msg_hash=None):
        
        if isinstance(key_or_address, str):
            # they gave us a private key or a public key already loaded.
            key = self._network.parse.address(key_or_address)
        else:
            key = key_or_address

        try:
            msg_hash = self.hash_for_signing(message) if message is not None else msg_hash
            pair, is_compressed = self.pair_for_message_hash(signature, msg_hash)
        except EncodingError:
            return False
        return self.pair_matches_key(pair, key, is_compressed)
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)
573745
function verify(public_key, data, signature) {
  var pubkey = bitcoinjs.ECPubKey.fromHex(public_key);
  var hash = bitcoinjs.crypto.hash256(new Buffer(data, 'hex'));
  var ecsignature = bitcoinjs.ECSignature.fromDER(new Buffer(signature, 'hex'));
  return pubkey.verify(hash, ecsignature);
}
1107408
def checkvalid(s, m, pk):
    
    if len(s) != b // 4:
        raise ValueError("signature length is wrong")

    if len(pk) != b // 8:
        raise ValueError("public-key length is wrong")

    s = bytearray(s)
    m = bytearray(m)
    pk = bytearray(pk)

    R = decodepoint(s[: b // 8])
    A = decodepoint(pk)
    S = decodeint(s[b // 8 : b // 4])
    h = Hint(encodepoint(R) + pk + m)

    (x1, y1, z1, t1) = P = scalarmult_B(S)
    (x2, y2, z2, t2) = Q = edwards_add(R, scalarmult(A, h))

    if (
        not isoncurve(P)
        or not isoncurve(Q)
        or (x1 * z2 - x2 * z1) % q != 0
        or (y1 * z2 - y2 * z1) % q != 0
    ):
        raise SignatureMismatch("signature does not pass verification")
1092897
public byte[] sign(String privateKeyId, byte[] message) {
		Signer signer = cache.get(privateKeyId);

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

		SignerImpl signerImpl = new SignerImpl();
		PrivateKey privateKey = privateKeyMap.get(privateKeyId);

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

		signerImpl.setPrivateKey(privateKey);
		signerImpl.setAlgorithm(algorithm);
		signerImpl.setProvider(provider);
		cache.put(privateKeyId, signerImpl);
		return signerImpl.sign(message);
	}
1122253
function verifySignature(publicKey, idToken) {
  var verifier = crypto.createVerify('sha256');
  verifier.update(idToken.playerId, 'utf8');
  verifier.update(idToken.bundleId, 'utf8');
  verifier.update(convertTimestampToBigEndian(idToken.timestamp));
  verifier.update(idToken.salt, 'base64');

  if (!verifier.verify(publicKey, idToken.signature, 'base64')) {
    throw new Error('Invalid Signature');
  }
}
1232243
def Verify(self, message, signature, hash_algorithm=None):
    """"""
    # This method accepts both PSS and PKCS1v15 padding. PSS is preferred but
    # old clients only support PKCS1v15.

    if hash_algorithm is None:
      hash_algorithm = hashes.SHA256()

    last_e = None
    for padding_algorithm in [
        padding.PSS(
            mgf=padding.MGF1(hash_algorithm),
            salt_length=padding.PSS.MAX_LENGTH),
        padding.PKCS1v15()
    ]:
      try:
        self._value.verify(signature, message, padding_algorithm,
                           hash_algorithm)
        return True

      except exceptions.InvalidSignature as e:
        last_e = e

    raise VerificationError(last_e)
621406
func Verify(publicKey [32]byte, message []byte, signature *[64]byte) bool {

	publicKey[31] &= 0x7F

	/* Convert the Curve25519 public key into an Ed25519 public key.  In
	particular, convert Curve25519's "montgomery" x-coordinate into an
	Ed25519 "edwards" y-coordinate:

	ed_y = (mont_x - 1) / (mont_x + 1)

	NOTE: mont_x=-1 is converted to ed_y=0 since fe_invert is mod-exp

	Then move the sign bit into the pubkey from the signature.
	*/

	var edY, one, montX, montXMinusOne, montXPlusOne edwards25519.FieldElement
	edwards25519.FeFromBytes(&montX, &publicKey)
	edwards25519.FeOne(&one)
	edwards25519.FeSub(&montXMinusOne, &montX, &one)
	edwards25519.FeAdd(&montXPlusOne, &montX, &one)
	edwards25519.FeInvert(&montXPlusOne, &montXPlusOne)
	edwards25519.FeMul(&edY, &montXMinusOne, &montXPlusOne)

	var A_ed [32]byte
	edwards25519.FeToBytes(&A_ed, &edY)

	A_ed[31] |= signature[63] & 0x80
	signature[63] &= 0x7F

	return ed25519.Verify(&A_ed, message, signature)
}