mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-19 21:40:34 +02:00
Moves the message key to the HKDF function
This commit is contained in:
@@ -99,7 +99,7 @@ class Nip44v2 {
|
||||
): String = decrypt(EncryptedInfo.decodePayload(payload), conversationKey)
|
||||
|
||||
fun checkHMacAad(
|
||||
messageKey: MessageKey,
|
||||
messageKey: Hkdf.MessageKey,
|
||||
decoded: EncryptedInfo,
|
||||
) {
|
||||
val calculatedMac = hmacAad(messageKey.hmacKey, decoded.ciphertext, decoded.nonce)
|
||||
@@ -208,13 +208,7 @@ class Nip44v2 {
|
||||
fun getMessageKeys(
|
||||
conversationKey: ByteArray,
|
||||
nonce: ByteArray,
|
||||
): MessageKey = hkdf.fastExpand(conversationKey, nonce)
|
||||
|
||||
class MessageKey(
|
||||
val chachaKey: ByteArray,
|
||||
val chachaNonce: ByteArray,
|
||||
val hmacKey: ByteArray,
|
||||
)
|
||||
): Hkdf.MessageKey = hkdf.fastExpand(conversationKey, nonce)
|
||||
|
||||
/** @return 32B shared secret */
|
||||
fun computeConversationKey(
|
||||
|
@@ -20,7 +20,6 @@
|
||||
*/
|
||||
package com.vitorpamplona.quartz.nip44Encryption.crypto
|
||||
|
||||
import com.vitorpamplona.quartz.nip44Encryption.Nip44v2.MessageKey
|
||||
import java.nio.ByteBuffer
|
||||
import javax.crypto.Mac
|
||||
import javax.crypto.spec.SecretKeySpec
|
||||
@@ -123,4 +122,10 @@ class Hkdf(
|
||||
hmacKey = hmacKey,
|
||||
)
|
||||
}
|
||||
|
||||
class MessageKey(
|
||||
val chachaKey: ByteArray,
|
||||
val chachaNonce: ByteArray,
|
||||
val hmacKey: ByteArray,
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user