diff --git a/library/src/main/java/org/xmtp/android/library/messages/PrivateKey.kt b/library/src/main/java/org/xmtp/android/library/messages/PrivateKey.kt index f67a0d4e4..dcf9b5007 100644 --- a/library/src/main/java/org/xmtp/android/library/messages/PrivateKey.kt +++ b/library/src/main/java/org/xmtp/android/library/messages/PrivateKey.kt @@ -4,12 +4,15 @@ import com.google.protobuf.kotlin.toByteString import kotlinx.coroutines.runBlocking import org.web3j.crypto.ECKeyPair import org.web3j.crypto.Hash +import org.web3j.crypto.Keys import org.web3j.crypto.Sign import org.xmtp.android.library.KeyUtil import org.xmtp.android.library.SigningKey +import org.xmtp.android.library.toHex import org.xmtp.proto.message.contents.PublicKeyOuterClass import org.xmtp.proto.message.contents.SignatureOuterClass import java.security.SecureRandom +import java.util.Arrays import java.util.Date typealias PrivateKey = org.xmtp.proto.message.contents.PrivateKeyOuterClass.PrivateKey @@ -96,7 +99,16 @@ fun PrivateKey.generate(): PrivateKey { } val PrivateKey.walletAddress: String - get() = publicKey.walletAddress + get() { + val address = Keys.getAddress( + Arrays.copyOfRange( + publicKey.secp256K1Uncompressed.bytes.toByteArray(), + 1, + publicKey.secp256K1Uncompressed.bytes.toByteArray().size + ) + ) + return Keys.toChecksumAddress(address.toHex()) + } fun PrivateKey.sign(key: PublicKeyOuterClass.UnsignedPublicKey): PublicKeyOuterClass.SignedPublicKey { val bytes = key.toByteArray()