use of org.bouncycastle.crypto.Digest in project nem2-sdk-java by nemtech.
the class Hashes method sha256ForSharedKey.
/**
* Hasher used for shared keys
*
* @param sharedSecret the shared secret
* @return the shared key hash.
*/
public static byte[] sha256ForSharedKey(byte[] sharedSecret) {
Digest hash = new SHA256Digest();
byte[] info = "catapult".getBytes();
int length = 32;
byte[] sharedKey = new byte[length];
HKDFParameters params = new HKDFParameters(sharedSecret, null, info);
HKDFBytesGenerator hkdf = new HKDFBytesGenerator(hash);
hkdf.init(params);
hkdf.generateBytes(sharedKey, 0, length);
return sharedKey;
}
Aggregations