diff --git a/library/src/main/java/org/xmtp/android/library/Contacts.kt b/library/src/main/java/org/xmtp/android/library/Contacts.kt index 07489042b..7e44b16b8 100644 --- a/library/src/main/java/org/xmtp/android/library/Contacts.kt +++ b/library/src/main/java/org/xmtp/android/library/Contacts.kt @@ -60,7 +60,7 @@ class ConsentList(val client: Client) { val preferences: MutableList = mutableListOf() for (envelope in envelopes.envelopesList) { - val payload = uniffi.xmtp_dh.eciesDecryptK256Sha3256( + val payload = uniffi.xmtp_dh.userPreferencesDecrypt( publicKey.toByteArray().toUByteArray().toList(), privateKey.toByteArray().toUByteArray().toList(), envelope.message.toByteArray().toUByteArray().toList() @@ -101,7 +101,7 @@ class ConsentList(val client: Client) { } }.build() - val message = uniffi.xmtp_dh.eciesEncryptK256Sha3256( + val message = uniffi.xmtp_dh.userPreferencesEncrypt( publicKey.toByteArray().toUByteArray().toList(), privateKey.toByteArray().toUByteArray().toList(), payload.toByteArray().toUByteArray().toList() diff --git a/library/src/main/java/org/xmtp/android/library/messages/Topic.kt b/library/src/main/java/org/xmtp/android/library/messages/Topic.kt index b9d9b279d..9927f852d 100644 --- a/library/src/main/java/org/xmtp/android/library/messages/Topic.kt +++ b/library/src/main/java/org/xmtp/android/library/messages/Topic.kt @@ -23,7 +23,7 @@ sealed class Topic { } is directMessageV2 -> wrap("m-$addresses") - is preferenceList -> wrap("pppp-$identifier") + is preferenceList -> wrap("userpreferences-$identifier") } } diff --git a/library/src/main/java/xmtp_dh.kt b/library/src/main/java/xmtp_dh.kt index 3aec9f9ae..58647c6f8 100644 --- a/library/src/main/java/xmtp_dh.kt +++ b/library/src/main/java/xmtp_dh.kt @@ -22,6 +22,7 @@ import com.sun.jna.IntegerType import com.sun.jna.Native import com.sun.jna.Pointer import com.sun.jna.Structure +import com.sun.jna.Callback import com.sun.jna.ptr.* import java.nio.ByteBuffer import java.nio.ByteOrder @@ -106,7 +107,6 @@ class RustBufferByReference : ByReference(16) { open class ForeignBytes : Structure() { @JvmField var len: Int = 0 - @JvmField var data: Pointer? = null @@ -192,7 +192,6 @@ public interface FfiConverterRustBuffer : FfiConverter { - override fun lift(error_buf: RustBuffer.ByValue): EciesException = - FfiConverterTypeEciesError.lift(error_buf) + companion object ErrorHandler : CallStatusErrorHandler { + override fun lift(error_buf: RustBuffer.ByValue): UserPreferencesException = + FfiConverterTypeUserPreferencesError.lift(error_buf) } } -public object FfiConverterTypeEciesError : FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): EciesException { +public object FfiConverterTypeUserPreferencesError : + FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): UserPreferencesException { return when (buf.getInt()) { - 1 -> EciesException.GenericException(FfiConverterString.read(buf)) + 1 -> UserPreferencesException.GenericException(FfiConverterString.read(buf)) else -> throw RuntimeException("invalid error enum value, something is very wrong!!") } } - override fun allocationSize(value: EciesException): Int { + override fun allocationSize(value: UserPreferencesException): Int { return 4 } - override fun write(value: EciesException, buf: ByteBuffer) { + override fun write(value: UserPreferencesException, buf: ByteBuffer) { when (value) { - is EciesException.GenericException -> { + is UserPreferencesException.GenericException -> { buf.putInt(1) Unit } @@ -720,16 +720,16 @@ fun `diffieHellmanK256`( }) } -@Throws(EciesException::class) +@Throws(UserPreferencesException::class) -fun `eciesEncryptK256Sha3256`( +fun `userPreferencesEncrypt`( `publicKeyBytes`: List, `privateKeyBytes`: List, `messageBytes`: List, ): List { return FfiConverterSequenceUByte.lift( - rustCallWithError(EciesException) { _status -> - _UniFFILib.INSTANCE.uniffi_xmtp_dh_fn_func_ecies_encrypt_k256_sha3_256( + rustCallWithError(UserPreferencesException) { _status -> + _UniFFILib.INSTANCE.uniffi_xmtp_dh_fn_func_user_preferences_encrypt( FfiConverterSequenceUByte.lower(`publicKeyBytes`), FfiConverterSequenceUByte.lower(`privateKeyBytes`), FfiConverterSequenceUByte.lower(`messageBytes`), @@ -738,16 +738,16 @@ fun `eciesEncryptK256Sha3256`( }) } -@Throws(EciesException::class) +@Throws(UserPreferencesException::class) -fun `eciesDecryptK256Sha3256`( +fun `userPreferencesDecrypt`( `publicKeyBytes`: List, `privateKeyBytes`: List, `messageBytes`: List, ): List { return FfiConverterSequenceUByte.lift( - rustCallWithError(EciesException) { _status -> - _UniFFILib.INSTANCE.uniffi_xmtp_dh_fn_func_ecies_decrypt_k256_sha3_256( + rustCallWithError(UserPreferencesException) { _status -> + _UniFFILib.INSTANCE.uniffi_xmtp_dh_fn_func_user_preferences_decrypt( FfiConverterSequenceUByte.lower(`publicKeyBytes`), FfiConverterSequenceUByte.lower(`privateKeyBytes`), FfiConverterSequenceUByte.lower(`messageBytes`), @@ -756,11 +756,11 @@ fun `eciesDecryptK256Sha3256`( }) } -@Throws(EciesException::class) +@Throws(UserPreferencesException::class) fun `generatePrivatePreferencesTopicIdentifier`(`privateKeyBytes`: List): String { return FfiConverterString.lift( - rustCallWithError(EciesException) { _status -> + rustCallWithError(UserPreferencesException) { _status -> _UniFFILib.INSTANCE.uniffi_xmtp_dh_fn_func_generate_private_preferences_topic_identifier( FfiConverterSequenceUByte.lower(`privateKeyBytes`), _status diff --git a/library/src/main/jniLibs/arm64-v8a/libuniffi_xmtp_dh.so b/library/src/main/jniLibs/arm64-v8a/libuniffi_xmtp_dh.so index 2a220f2c7..52a48219a 100755 Binary files a/library/src/main/jniLibs/arm64-v8a/libuniffi_xmtp_dh.so and b/library/src/main/jniLibs/arm64-v8a/libuniffi_xmtp_dh.so differ diff --git a/library/src/main/jniLibs/armeabi-v7a/libuniffi_xmtp_dh.so b/library/src/main/jniLibs/armeabi-v7a/libuniffi_xmtp_dh.so index 998c8594f..86d3cd7be 100755 Binary files a/library/src/main/jniLibs/armeabi-v7a/libuniffi_xmtp_dh.so and b/library/src/main/jniLibs/armeabi-v7a/libuniffi_xmtp_dh.so differ diff --git a/library/src/main/jniLibs/x86/libuniffi_xmtp_dh.so b/library/src/main/jniLibs/x86/libuniffi_xmtp_dh.so index b0869c8d3..2c61bbc66 100755 Binary files a/library/src/main/jniLibs/x86/libuniffi_xmtp_dh.so and b/library/src/main/jniLibs/x86/libuniffi_xmtp_dh.so differ diff --git a/library/src/main/jniLibs/x86_64/libuniffi_xmtp_dh.so b/library/src/main/jniLibs/x86_64/libuniffi_xmtp_dh.so index 0ff5eb79f..e3361d8a7 100755 Binary files a/library/src/main/jniLibs/x86_64/libuniffi_xmtp_dh.so and b/library/src/main/jniLibs/x86_64/libuniffi_xmtp_dh.so differ