From c0bc1eac996ec83738bb40a7374e9e7ce3a54d27 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 3 Jan 2024 14:40:23 -0800 Subject: [PATCH] fix java chomping leading zeros --- library/src/main/java/org/xmtp/android/library/KeyUtil.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/src/main/java/org/xmtp/android/library/KeyUtil.kt b/library/src/main/java/org/xmtp/android/library/KeyUtil.kt index 94b6faba4..2c2b3c9de 100644 --- a/library/src/main/java/org/xmtp/android/library/KeyUtil.kt +++ b/library/src/main/java/org/xmtp/android/library/KeyUtil.kt @@ -14,6 +14,10 @@ object KeyUtil { val newPublicKey = ByteArray(64) System.arraycopy(publicKey, publicKey.size - 64, newPublicKey, 0, 64) byteArrayOf(0x4.toByte()) + newPublicKey + } else if (publicKey.size < 64) { + val newPublicKey = ByteArray(64) + System.arraycopy(publicKey, 0, newPublicKey, 64 - publicKey.size, publicKey.size) + byteArrayOf(0x4.toByte()) + newPublicKey } else { byteArrayOf(0x4.toByte()) + publicKey }