public static boolean verifySignature (ECKey pubkey, byte[] data, byte[] signature) throws NoSuchProviderException, NoSuchAlgorithmException { MessageDigest hashHandler = MessageDigest.getInstance("SHA256", "BC"); hashHandler.update(data); byte[] hash = hashHandler.digest(); return pubkey.verify(hash, signature); }
/** * Verifies the given ASN.1 encoded ECDSA signature against a hash using the public key, and throws an exception * if the signature doesn't match * @throws java.security.SignatureException if the signature does not match. */ public void verifyOrThrow(byte[] hash, byte[] signature) throws SignatureException { if (!verify(hash, signature)) throw new SignatureException(); }
/** * Verifies the given ASN.1 encoded ECDSA signature against a hash using the public key, and throws an exception * if the signature doesn't match * @throws java.security.SignatureException if the signature does not match. */ public void verifyOrThrow(byte[] hash, byte[] signature) throws SignatureException { if (!verify(hash, signature)) throw new SignatureException(); }
/** * Verifies the given ASN.1 encoded ECDSA signature against a hash using the public key. * * @param hash Hash of the data to verify. * @param signature ASN.1 encoded signature. */ public boolean verify(byte[] hash, byte[] signature) { return ECKey.verify(hash, signature, getPubKey()); }
/** * Verifies the given ASN.1 encoded ECDSA signature against a hash using the public key. * * @param hash Hash of the data to verify. * @param signature ASN.1 encoded signature. */ public boolean verify(byte[] hash, byte[] signature) { return ECKey.verify(hash, signature, getPubKey()); }
/** * Verifies the given ASN.1 encoded ECDSA signature against a hash using the public key, and throws an exception * if the signature doesn't match * @throws java.security.SignatureException if the signature does not match. */ public void verifyOrThrow(byte[] hash, byte[] signature) throws SignatureException { if (!verify(hash, signature)) throw new SignatureException(); }
/** * Verifies the given ASN.1 encoded ECDSA signature against a hash using the public key. * * @param hash Hash of the data to verify. * @param signature ASN.1 encoded signature. */ public boolean verify(byte[] hash, byte[] signature) { return ECKey.verify(hash, signature, getPubKey()); }
/** * Verifies the given ASN.1 encoded ECDSA signature against a hash using the public key, and throws an exception * if the signature doesn't match * @throws java.security.SignatureException if the signature does not match. */ public void verifyOrThrow(byte[] hash, byte[] signature) throws SignatureException { if (!verify(hash, signature)) throw new SignatureException(); }
/** * Verifies the given R/S pair (signature) against a hash using the public key. */ public boolean verify(Sha256Hash sigHash, ECDSASignature signature) { return ECKey.verify(sigHash.getBytes(), signature, getPubKey()); }
private int findSigInRedeem(byte[] signatureBytes, Sha256Hash hash) { checkArgument(chunks.get(0).isOpCode()); // P2SH scriptSig int numKeys = Script.decodeFromOpN(chunks.get(chunks.size() - 2).opcode); TransactionSignature signature = TransactionSignature.decodeFromBitcoin(signatureBytes, true); for (int i = 0 ; i < numKeys ; i++) { if (ECKey.fromPublicOnly(chunks.get(i + 1).data).verify(hash, signature)) { return i; } } throw new IllegalStateException("Could not find matching key for signature on " + hash.toString() + " sig " + Utils.HEX.encode(signatureBytes)); }
/** * Returns true if the digital signature attached to the message verifies. Don't do anything with the alert if it * doesn't verify, because that would allow arbitrary attackers to spam your users. */ public boolean isSignatureValid() { return ECKey.verify(Sha256Hash.hashTwice(content), signature, params.getAlertSigningKey()); }
/** * Verifies the given R/S pair (signature) against a hash using the public key. */ public boolean verify(Sha256Hash sigHash, ECDSASignature signature) { return ECKey.verify(sigHash.getBytes(), signature, getPubKey()); }
private int findSigInRedeem(byte[] signatureBytes, Sha256Hash hash) { checkArgument(chunks.get(0).isOpCode()); // P2SH scriptSig int numKeys = Script.decodeFromOpN(chunks.get(chunks.size() - 2).opcode); TransactionSignature signature = TransactionSignature.decodeFromBitcoin(signatureBytes, true); for (int i = 0 ; i < numKeys ; i++) { if (ECKey.fromPublicOnly(chunks.get(i + 1).data).verify(hash, signature)) { return i; } } throw new IllegalStateException("Could not find matching key for signature on " + hash.toString() + " sig " + Utils.HEX.encode(signatureBytes)); }
private int findSigInRedeem(byte[] signatureBytes, Sha256Hash hash) { checkArgument(chunks.get(0).isOpCode()); // P2SH scriptSig int numKeys = Script.decodeFromOpN(chunks.get(chunks.size() - 2).opcode); TransactionSignature signature = TransactionSignature.decodeFromBitcoin(signatureBytes, true); for (int i = 0 ; i < numKeys ; i++) { if (ECKey.fromPublicOnly(chunks.get(i + 1).data).verify(hash, signature)) { return i; } } throw new IllegalStateException("Could not find matching key for signature on " + hash.toString() + " sig " + HEX.encode(signatureBytes)); }
/** * Returns true if the digital signature attached to the message verifies. Don't do anything with the alert if it * doesn't verify, because that would allow arbitrary attackers to spam your users. */ public boolean isSignatureValid() { return ECKey.verify(Sha256Hash.hashTwice(content), signature, params.getAlertSigningKey()); }
/** * Returns true if the digital signature attached to the message verifies. Don't do anything with the alert if it * doesn't verify, because that would allow arbitrary attackers to spam your users. */ public boolean isSignatureValid() { return ECKey.verify(Sha256Hash.hashTwice(content), signature, params.getAlertSigningKey()); }
/** * Verifies the given R/S pair (signature) against a hash using the public key. */ public boolean verify(Sha256Hash sigHash, ECDSASignature signature) { return ECKey.verify(sigHash.getBytes(), signature, getPubKey()); }
/** * Verifies the given R/S pair (signature) against a hash using the public key, and throws an exception * if the signature doesn't match * @throws java.security.SignatureException if the signature does not match. */ public void verifyOrThrow(Sha256Hash sigHash, ECDSASignature signature) throws SignatureException { if (!ECKey.verify(sigHash.getBytes(), signature, getPubKey())) throw new SignatureException(); }
/** * Verifies the given R/S pair (signature) against a hash using the public key, and throws an exception * if the signature doesn't match * @throws java.security.SignatureException if the signature does not match. */ public void verifyOrThrow(Sha256Hash sigHash, ECDSASignature signature) throws SignatureException { if (!ECKey.verify(sigHash.getBytes(), signature, getPubKey())) throw new SignatureException(); }
/** * Verifies the given R/S pair (signature) against a hash using the public key, and throws an exception * if the signature doesn't match * @throws java.security.SignatureException if the signature does not match. */ public void verifyOrThrow(Sha256Hash sigHash, ECDSASignature signature) throws SignatureException { if (!ECKey.verify(sigHash.getBytes(), signature, getPubKey())) throw new SignatureException(); }