use of org.spongycastle.crypto.digests.KeccakDigest in project aion by aionnetwork.
the class HashUtil method keccak256.
/**
* Computes the keccak-256 hash of the given input.
*
* @param input Data for hashing
* @return Hash
*/
public static byte[] keccak256(byte[] input) {
KeccakDigest digest = new KeccakDigest(256);
digest.update(input, 0, input.length);
byte[] hash = new byte[32];
digest.doFinal(hash, 0);
return hash;
}
use of org.spongycastle.crypto.digests.KeccakDigest in project aion by aionnetwork.
the class ECKeySecp256k1 method computeAddress.
/**
* Compute an address from an encoded public key.
*
* NOTE: This address computation is Ethereum-specific.
*
* @param pubBytes
* an encoded (uncompressed) public key
* @return 20-byte address
*/
public byte[] computeAddress(byte[] pubBytes) {
byte[] input = Arrays.copyOfRange(pubBytes, 1, pubBytes.length);
KeccakDigest digest = new KeccakDigest(256);
digest.update(input, 0, input.length);
byte[] keccak256 = new byte[32];
digest.doFinal(keccak256, 0);
return copyOfRange(keccak256, 12, keccak256.length);
}
Aggregations