Skip to content

Commit

Permalink
remove unneeded crypto code
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Feb 13, 2024
1 parent c2f4f5b commit 17a12a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
14 changes: 0 additions & 14 deletions library/src/main/java/org/xmtp/android/library/Crypto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,5 @@ class Crypto {
hkdfGenerator.generateBytes(hkdf, 0, hkdf.size)
return hkdf
}

fun generateHmacSignature(
secret: ByteArray,
info: ByteArray,
message: ByteArray,
): ByteArray {
val derivationParameters = HKDFParameters(secret, ByteArray(0), info)
val digest = SHA256Digest()
val hkdfGenerator = HKDFBytesGenerator(digest)
hkdfGenerator.init(derivationParameters)
val hkdf = ByteArray(32)
hkdfGenerator.generateBytes(hkdf, 0, hkdf.size)
return calculateMac(hkdf, message)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ class MessageV2Builder(val senderHmac: ByteArray? = null, val shouldPush: Boolea
val info = "$thirtyDayPeriodsSinceEpoch-${client.address}"
val infoEncoded = info.toByteStringUtf8().toByteArray()
val senderHmacGenerated =
Crypto.generateHmacSignature(keyMaterial, infoEncoded, headerBytes)
Crypto.calculateMac(
Crypto.deriveKey(keyMaterial, ByteArray(0), infoEncoded),
headerBytes
)

return buildFromCipherText(
headerBytes,
Expand Down

0 comments on commit 17a12a2

Please sign in to comment.