/** * Calculates RIGTMOST160(SHA3(input)). This is used in address calculations. * * * * @param input - data * * @return - 20 right bytes of the hash keccak of the data */ public static byte[] sha3omit12(byte[] input) { byte[] hash = sha3(input); return copyOfRange(hash, 12, hash.length); }
public byte[] encodeSignatureLong() { String signature = formatSignature(); byte[] sha3Fingerprint = sha3(signature.getBytes()); return sha3Fingerprint; }
public byte[] hash() { if (sha3 == null) sha3 = HashUtil.sha3(encode()); return sha3; }
public byte[] getHash() { if (!isEmpty(hash)) return hash; rlpParse(); byte[] plainMsg = this.getEncoded(); return HashUtil.sha3(plainMsg); }
public byte[] getRawHash() { rlpParse(); if (rawHash != null) return rawHash; byte[] plainMsg = this.getEncodedRaw(); return rawHash = HashUtil.sha3(plainMsg); } }
private byte[] createBalanceMsgHashRaw(Address receiverAddress, BigInteger openBlockNumber, BigInteger owedBalance, Address channelManagerAddr) { byte[] receiverAddressBytes = receiverAddress.getBytes(); byte[] channelAddressBytes = channelManagerAddr.getBytes(); byte[] openBlockNumberBytes = ByteUtils.prependZeros(openBlockNumber.toByteArray(), 4); byte[] balanceBytes = ByteUtils.prependZeros(Hex.decode(prependZeroIfNeeded(owedBalance)), 24); byte[] dataTypeName = "string message_idaddress receiveruint32 block_createduint192 balanceaddress contract".getBytes( Charset.forName("UTF-8")); byte[] dataValue = ByteUtils.concat("Sender balance proof signature".getBytes(), receiverAddressBytes, openBlockNumberBytes, balanceBytes, channelAddressBytes); return HashUtil.sha3(ByteUtils.concat(HashUtil.sha3(dataTypeName), HashUtil.sha3(dataValue))); }
private byte[] createClosingMsgHashRaw(Address senderAddress, BigInteger openBlockNumber, BigInteger owedBalance, Address channelManagerAddr) { byte[] receiverAddressBytes = senderAddress.getBytes(); byte[] channelAddressBytes = channelManagerAddr.getBytes(); byte[] openBlockNumberBytes = ByteUtils.prependZeros(openBlockNumber.toByteArray(), 4); byte[] balanceBytes = ByteUtils.prependZeros(Hex.decode(prependZeroIfNeeded(owedBalance)), 24); byte[] dataTypeName = "string message_idaddress senderuint32 block_createduint192 balanceaddress contract".getBytes( Charset.forName("UTF-8")); byte[] dataValue = ByteUtils.concat("Receiver closing signature".getBytes(), receiverAddressBytes, openBlockNumberBytes, balanceBytes, channelAddressBytes); return HashUtil.sha3(ByteUtils.concat(HashUtil.sha3(dataTypeName), HashUtil.sha3(dataValue))); }