/** * Calculates the SHA-256 hash of the given bytes, * and then hashes the resulting hash again. * * @param input the bytes to hash * @return the double-hash (in big-endian order) */ public static byte[] hashTwice(byte[] input) { return hashTwice(input, 0, input.length); }
/** * Calculates the SHA-256 hash of the given bytes, * and then hashes the resulting hash again. * * @param input the bytes to hash * @return the double-hash (in big-endian order) */ public static byte[] hashTwice(byte[] input) { return hashTwice(input, 0, input.length); }
/** * Calculates the SHA-256 hash of the given bytes, * and then hashes the resulting hash again. * * @param input the bytes to hash * @return the double-hash (in big-endian order) */ public static byte[] hashTwice(byte[] input) { return hashTwice(input, 0, input.length); }
/** * Calculates the SHA-256 hash of the given bytes, * and then hashes the resulting hash again. * * @param input the bytes to hash * @return the double-hash (in big-endian order) */ public static byte[] hashTwice(byte[] input) { return hashTwice(input, 0, input.length); }
static byte[] addChecksum(byte[] input) { int inputLength = input.length; byte[] checksummed = new byte[inputLength + 4]; System.arraycopy(input, 0, checksummed, 0, inputLength); byte[] checksum = Sha256Hash.hashTwice(input); System.arraycopy(checksum, 0, checksummed, inputLength, 4); return checksummed; }
static byte[] addChecksum(byte[] input) { int inputLength = input.length; byte[] checksummed = new byte[inputLength + 4]; System.arraycopy(input, 0, checksummed, 0, inputLength); byte[] checksum = Sha256Hash.hashTwice(input); System.arraycopy(checksum, 0, checksummed, inputLength, 4); return checksummed; }
static byte[] addChecksum(byte[] input) { int inputLength = input.length; byte[] checksummed = new byte[inputLength + 4]; System.arraycopy(input, 0, checksummed, 0, inputLength); byte[] checksum = Sha256Hash.hashTwice(input); System.arraycopy(checksum, 0, checksummed, inputLength, 4); return checksummed; }
static byte[] addChecksum(byte[] input) { int inputLength = input.length; byte[] checksummed = new byte[inputLength + 4]; System.arraycopy(input, 0, checksummed, 0, inputLength); byte[] checksum = Sha256Hash.hashTwice(input); System.arraycopy(checksum, 0, checksummed, inputLength, 4); return checksummed; }
/** * Creates a new instance containing the hash of the calculated hash of the given bytes. * * @param contents the bytes on which the hash value is calculated * @return a new instance containing the calculated (two-time) hash */ public static Sha256Hash twiceOf(byte[] contents) { return wrap(hashTwice(contents)); }
/** * Creates a new instance containing the hash of the calculated hash of the given bytes. * * @param contents the bytes on which the hash value is calculated * @return a new instance containing the calculated (two-time) hash */ public static Sha256Hash twiceOf(byte[] contents) { return wrap(hashTwice(contents)); }
/** * Creates a new instance containing the hash of the calculated hash of the given bytes. * * @param contents the bytes on which the hash value is calculated * @return a new instance containing the calculated (two-time) hash */ public static Sha256Hash twiceOf(byte[] contents) { return wrap(hashTwice(contents)); }
/** * Creates a new instance containing the hash of the calculated hash of the given bytes. * * @param contents the bytes on which the hash value is calculated * @return a new instance containing the calculated (two-time) hash */ public static Sha256Hash twiceOf(byte[] contents) { return wrap(hashTwice(contents)); }
/** * 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()); }
/** * 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 the transaction hash as you see them in the block explorer. */ @Override public Sha256Hash getHash() { if (hash == null) { hash = Sha256Hash.wrapReversed(Sha256Hash.hashTwice(unsafeBitcoinSerialize())); } return hash; }
private static Sha256Hash combineLeftRight(byte[] left, byte[] right) { return Sha256Hash.wrapReversed(Sha256Hash.hashTwice( reverseBytes(left), 0, 32, reverseBytes(right), 0, 32)); }
private static Sha256Hash combineLeftRight(byte[] left, byte[] right) { return Sha256Hash.wrapReversed(Sha256Hash.hashTwice( reverseBytes(left), 0, 32, reverseBytes(right), 0, 32)); }
private static Sha256Hash combineLeftRight(byte[] left, byte[] right) { return Sha256Hash.wrapReversed(Sha256Hash.hashTwice( reverseBytes(left), 0, 32, reverseBytes(right), 0, 32)); }
public Sha256Hash getHash(){ try { UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(vchSig.calculateMessageSizeInBytes()+8); vin.bitcoinSerialize(bos); Utils.int64ToByteStreamLE(sigTime, bos); return Sha256Hash.wrapReversed(Sha256Hash.hashTwice(bos.toByteArray())); } catch (IOException e) { throw new RuntimeException(e); // Cannot happen. } } }