mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-21 15:05:19 +00:00
JNI bridging for the new version blinded key api
This commit is contained in:
parent
6fb0f1708f
commit
dba0ca910e
@ -30,6 +30,7 @@ set(SOURCES
|
||||
config_base.cpp
|
||||
contacts.cpp
|
||||
conversation.cpp
|
||||
blinded_key.cpp
|
||||
util.cpp)
|
||||
|
||||
add_library( # Sets the name of the library.
|
||||
|
34
libsession-util/src/main/cpp/blinded_key.cpp
Normal file
34
libsession-util/src/main/cpp/blinded_key.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include <jni.h>
|
||||
#include <session/blinding.hpp>
|
||||
|
||||
#include "util.h"
|
||||
#include "jni_utils.h"
|
||||
|
||||
//
|
||||
// Created by Thomas Ruffie on 29/7/2024.
|
||||
//
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_util_BlindKeyAPI_blindVersionKeyPair(JNIEnv *env,
|
||||
jobject thiz,
|
||||
jbyteArray ed25519_secret_key) {
|
||||
return jni_utils::run_catching_cxx_exception_or_throws<jobject>(env, [=] {
|
||||
const auto [pk, sk] = session::blind_version_key_pair(util::ustring_from_bytes(env, ed25519_secret_key));
|
||||
|
||||
jclass kp_class = env->FindClass("network/loki/messenger/libsession_util/util/KeyPair");
|
||||
jmethodID kp_constructor = env->GetMethodID(kp_class, "<init>", "([B[B)V");
|
||||
return env->NewObject(kp_class, kp_constructor, util::bytes_from_ustring(env, {pk.data(), pk.size()}), util::bytes_from_ustring(env, {sk.data(), sk.size()}));
|
||||
});
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jbyteArray JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_util_BlindKeyAPI_blindVersionSign(JNIEnv *env,
|
||||
jobject thiz,
|
||||
jbyteArray ed25519_secret_key,
|
||||
jlong timestamp) {
|
||||
return jni_utils::run_catching_cxx_exception_or_throws<jbyteArray>(env, [=] {
|
||||
auto bytes = session::blind_version_sign(util::ustring_from_bytes(env, ed25519_secret_key), session::Platform::android, timestamp);
|
||||
return util::bytes_from_ustring(env, bytes);
|
||||
});
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package network.loki.messenger.libsession_util.util
|
||||
|
||||
object BlindKeyAPI {
|
||||
init {
|
||||
System.loadLibrary("session_util")
|
||||
}
|
||||
|
||||
external fun blindVersionKeyPair(ed25519SecretKey: ByteArray): KeyPair
|
||||
external fun blindVersionSign(ed25519SecretKey: ByteArray, timestamp: Long): ByteArray
|
||||
}
|
Loading…
Reference in New Issue
Block a user