Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable generation of testnet xPub #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/mpc_crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/mpc_crypto_ecdsa_bip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/mpc_crypto_jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down