From d6a72826bb0fa900f39905a54c3d9f989f54cce7 Mon Sep 17 00:00:00 2001 From: Laurenz Honauer Date: Thu, 28 Jul 2022 09:26:08 +0200 Subject: [PATCH] Enable generation of testnet xPub --- include/mpc_crypto.h | 2 +- src/mpc_crypto_ecdsa_bip.cpp | 4 ++-- src/mpc_crypto_jni.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/mpc_crypto.h b/include/mpc_crypto.h index 0b9b764..8eaba89 100644 --- a/include/mpc_crypto.h +++ b/include/mpc_crypto.h @@ -160,7 +160,7 @@ MPCCRYPTO_API int MPCCrypto_restoreEddsaKey(const uint8_t* prv_backup_key, int p MPCCRYPTO_API int MPCCrypto_initDeriveBIP32(int peer, MPCCryptoShare* share, int hardened, unsigned index, MPCCryptoContext** context); MPCCRYPTO_API int MPCCrypto_getResultDeriveBIP32(MPCCryptoContext* context, MPCCryptoShare** new_share); MPCCRYPTO_API int MPCCrypto_getBIP32Info(MPCCryptoShare* share, bip32_info_t* bip32_info); -MPCCRYPTO_API int MPCCrypto_serializePubBIP32(MPCCryptoShare* share, char* out, int* out_size); +MPCCRYPTO_API int MPCCrypto_serializePubBIP32(MPCCryptoShare* share, char* out, int* out_size, bool main = true); #ifdef __cplusplus diff --git a/src/mpc_crypto_ecdsa_bip.cpp b/src/mpc_crypto_ecdsa_bip.cpp index 9179d54..6315653 100644 --- a/src/mpc_crypto_ecdsa_bip.cpp +++ b/src/mpc_crypto_ecdsa_bip.cpp @@ -932,7 +932,7 @@ MPCCRYPTO_API int MPCCrypto_getBIP32Info(MPCCryptoShare* share_ptr, bip32_info_t return rv; } -MPCCRYPTO_API int MPCCrypto_serializePubBIP32(MPCCryptoShare* share_ptr, char* out, int* out_size) +MPCCRYPTO_API int MPCCrypto_serializePubBIP32(MPCCryptoShare* share_ptr, char* out, int* out_size, bool main) { error_t rv = 0; if (!share_ptr) return rv = ub::error(E_BADARG); @@ -953,7 +953,7 @@ MPCCRYPTO_API int MPCCrypto_serializePubBIP32(MPCCryptoShare* share_ptr, char* o bip_node.set_parent_fingerprint(bip_key_info.parent_fingerprint); bip_node.set_level(bip_key_info.level); - std::string s = bip_node.serialize_pub(Q.to_compressed_oct()); + std::string s = bip_node.serialize_pub(Q.to_compressed_oct(), main); int len = (int)s.length()+1; int buf_size = *out_size; *out_size = len; diff --git a/src/mpc_crypto_jni.cpp b/src/mpc_crypto_jni.cpp index e89425a..b5cb001 100644 --- a/src/mpc_crypto_jni.cpp +++ b/src/mpc_crypto_jni.cpp @@ -512,13 +512,13 @@ JNIEXPORT jint JNICALL Java_com_unboundTech_mpc_Native_getBIP32Info(JNIEnv *env, return 0; } -JNIEXPORT jint JNICALL Java_com_unboundTech_mpc_Native_serializePubBIP32(JNIEnv *env, jclass, jlong share_handle, jcharArray j_out, jobject j_out_size) +JNIEXPORT jint JNICALL Java_com_unboundTech_mpc_Native_serializePubBIP32(JNIEnv *env, jclass, jlong share_handle, jcharArray j_out, jobject j_out_size, jboolean main) { error_t rv = 0; MPCCryptoShare* share = (MPCCryptoShare*)(uintptr_t)share_handle; int str_size = 0; - rv = MPCCrypto_serializePubBIP32(share, nullptr, &str_size); + rv = MPCCrypto_serializePubBIP32(share, nullptr, &str_size, main); int out_size = str_size-1; if (j_out_size) set_int_ref(env, j_out_size, out_size);