/** * Compute an address from an encoded public key. * * @param pubBytes an encoded (uncompressed) public key * * @return 20-byte address */ public static byte[] computeAddress(byte[] pubBytes) { return HashUtil.sha3omit12(Arrays.copyOfRange(pubBytes, 1, pubBytes.length)); }
/** * The way to calculate new address inside ethereum * * @param addr - creating addres * @param nonce - nonce of creating address * * @return new address */ public static byte[] calcNewAddr(byte[] addr, byte[] nonce) { byte[] encSender = RLP.encodeElement(addr); byte[] encNonce = RLP.encodeBigInteger(new BigInteger(1, nonce)); return sha3omit12(RLP.encodeList(encSender, encNonce)); }