From 0c288055e8ab9c5f9cb44ad732833da449f30278 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer <naomi@xmtp.com> Date: Mon, 18 Nov 2024 18:43:13 -0800 Subject: [PATCH] update the frames client to use the new signer --- .../src/main/java/org/xmtp/android/library/Client.kt | 4 ++++ .../org/xmtp/android/library/frames/FramesClient.kt | 11 +++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/library/src/main/java/org/xmtp/android/library/Client.kt b/library/src/main/java/org/xmtp/android/library/Client.kt index 0bc5246c1..10a5c0dfc 100644 --- a/library/src/main/java/org/xmtp/android/library/Client.kt +++ b/library/src/main/java/org/xmtp/android/library/Client.kt @@ -208,6 +208,10 @@ class Client() { return Pair(ffiClient, dbPath) } + fun signInstallationKey(message: String): ByteArray { + return ffiClient.signWithInstallationKey(message) + } + fun findGroup(groupId: String): Group? { return try { Group(this, ffiClient.conversation(groupId.hexToByteArray())) diff --git a/library/src/main/java/org/xmtp/android/library/frames/FramesClient.kt b/library/src/main/java/org/xmtp/android/library/frames/FramesClient.kt index e8700414a..e7ee956c4 100644 --- a/library/src/main/java/org/xmtp/android/library/frames/FramesClient.kt +++ b/library/src/main/java/org/xmtp/android/library/frames/FramesClient.kt @@ -6,8 +6,6 @@ import org.xmtp.android.library.XMTPException import org.xmtp.android.library.frames.FramesConstants.PROTOCOL_VERSION import org.xmtp.android.library.messages.PrivateKeyBuilder import org.xmtp.android.library.messages.Signature -import org.xmtp.android.library.messages.getPublicKeyBundle -import org.xmtp.proto.message.contents.PublicKeyOuterClass.SignedPublicKeyBundle import java.security.MessageDigest import org.xmtp.proto.message.contents.Frames.FrameActionBody import org.xmtp.proto.message.contents.Frames.FrameAction @@ -45,17 +43,14 @@ class FramesClient(private val xmtpClient: Client, var proxy: OpenFramesProxy = return FramePostPayload("xmtp@$PROTOCOL_VERSION", untrustedData, trustedData) } - private suspend fun signDigest(digest: ByteArray): Signature { - val signedPrivateKey = xmtpClient.keys.identityKey - val privateKey = PrivateKeyBuilder.buildFromSignedPrivateKey(signedPrivateKey) - return PrivateKeyBuilder(privateKey).sign(digest) + private fun signDigest(message: String): ByteArray { + return xmtpClient.signInstallationKey(message) } private suspend fun buildSignedFrameAction(actionBodyInputs: FrameActionBody): ByteArray { - val digest = sha256(actionBodyInputs.toByteArray()) + val digest = sha256(actionBodyInputs.toByteArray()).toString() val signature = signDigest(digest) - val publicKeyBundle = getPublicKeyBundle() val frameAction = FrameAction.newBuilder().also { it.actionBody = actionBodyInputs.toByteString() it.signature = signature