From 943314a0168ce7c1add3b6e170377550ad4029be Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 3 Jan 2024 15:14:01 -0800 Subject: [PATCH] fix java chomping leading zeros (#152) --- 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 }