Avoids creating a byte array and recreating it again inside of the Mac instance.
This commit is contained in:
@@ -210,7 +210,7 @@ class Nip44v2 {
|
||||
"AAD associated data must be 32 bytes, but it was ${aad.size} bytes"
|
||||
}
|
||||
|
||||
return hkdf.extract(aad + message, key)
|
||||
return hkdf.extract(aad, message, key)
|
||||
}
|
||||
|
||||
fun getMessageKeys(
|
||||
|
||||
@@ -37,6 +37,18 @@ class Hkdf(
|
||||
return mac.doFinal(key)
|
||||
}
|
||||
|
||||
fun extract(
|
||||
key1: ByteArray,
|
||||
key2: ByteArray,
|
||||
salt: ByteArray,
|
||||
): ByteArray {
|
||||
val mac = Mac.getInstance(algorithm)
|
||||
mac.init(SecretKeySpec(salt, algorithm))
|
||||
mac.update(key1)
|
||||
mac.update(key2)
|
||||
return mac.doFinal()
|
||||
}
|
||||
|
||||
fun expand(
|
||||
key: ByteArray,
|
||||
nonce: ByteArray,
|
||||
|
||||
Reference in New Issue
Block a user