Fix for handling nonce processing
This commit is contained in:
parent
d74895079d
commit
64e15574db
@ -1403,15 +1403,6 @@ JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256
|
|||||||
|
|
||||||
CHECKRESULT((*penv)->GetArrayLength(penv, jpok64) != 64, "pok64 length must be 64 bytes");
|
CHECKRESULT((*penv)->GetArrayLength(penv, jpok64) != 64, "pok64 length must be 64 bytes");
|
||||||
|
|
||||||
// for (i = 0; i < jn_participants; i++)
|
|
||||||
// {
|
|
||||||
// jbyteArray id33 = (jbyteArray)(*penv)->GetObjectArrayElement(penv, jids33, i);
|
|
||||||
// size = (*penv)->GetArrayLength(penv, id33);
|
|
||||||
// CHECKRESULT(size != 33, "invalid id33 size");
|
|
||||||
// ids33[i] = (*penv)->GetByteArrayElements(penv, id33, 0);
|
|
||||||
// (*penv)->ReleaseByteArrayElements(penv, id33, ids33[i], 0);
|
|
||||||
// }
|
|
||||||
|
|
||||||
for (i = 0; i < jn_participants; i++)
|
for (i = 0; i < jn_participants; i++)
|
||||||
{
|
{
|
||||||
jbyteArray jid33 = (jbyteArray)(*penv)->GetObjectArrayElement(penv, jids33, i);
|
jbyteArray jid33 = (jbyteArray)(*penv)->GetObjectArrayElement(penv, jids33, i);
|
||||||
@ -2014,22 +2005,23 @@ JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256
|
|||||||
* Signature: (J[[BI[B[B[B[[B[B[B)[B
|
* Signature: (J[[BI[B[B[B[[B[B[B)[B
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256k1_1frost_1nonce_1process
|
JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256k1_1frost_1nonce_1process
|
||||||
(JNIEnv *penv, jclass clazz, jlong jctx, jobjectArray jpubnonces, jint n_pubnonces, jbyteArray jmsg32, jbyteArray jpubkey, jbyteArray jmy_id33, jobjectArray jids33, jbyteArray jtweak_cache, jbyteArray jadaptor)
|
(JNIEnv *penv, jclass clazz, jlong jctx, jobjectArray jpubnonces, jint n_pubnonces, jbyteArray jmsg32, jbyteArray jaggregate_public_key, jbyteArray jmy_id33, jobjectArray jids33, jbyteArray jtweak_cache, jbyteArray jadaptor)
|
||||||
{
|
{
|
||||||
secp256k1_context *ctx = (secp256k1_context *)jctx;
|
secp256k1_context *ctx = (secp256k1_context *)jctx;
|
||||||
|
|
||||||
secp256k1_frost_session session;
|
secp256k1_frost_session session;
|
||||||
|
|
||||||
secp256k1_frost_pubnonce **pubnonces;
|
secp256k1_frost_pubnonce **pubnonces;
|
||||||
jbyte *in66, *pub, *my_id33;
|
jbyte *in66, *public_key_bytes;
|
||||||
|
|
||||||
jbyteArray jpubnonce;
|
jbyteArray jpubnonce;
|
||||||
|
|
||||||
unsigned char msg32[32];
|
unsigned char msg32[32];
|
||||||
|
unsigned char my_id33[33];
|
||||||
|
|
||||||
secp256k1_xonly_pubkey public_key;
|
secp256k1_xonly_pubkey aggregate_public_key;
|
||||||
|
|
||||||
unsigned char *ids33[n_pubnonces];
|
const unsigned char *ids33[n_pubnonces];
|
||||||
|
|
||||||
secp256k1_frost_tweak_cache tweak_cache;
|
secp256k1_frost_tweak_cache tweak_cache;
|
||||||
secp256k1_pubkey adaptor;
|
secp256k1_pubkey adaptor;
|
||||||
@ -2045,7 +2037,7 @@ JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256
|
|||||||
if (jmsg32 == NULL)
|
if (jmsg32 == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (jpubkey == NULL)
|
if (jaggregate_public_key == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (jmy_id33 == NULL)
|
if (jmy_id33 == NULL)
|
||||||
@ -2080,17 +2072,17 @@ JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256
|
|||||||
CHECKRESULT(size != 32, "invalid message size");
|
CHECKRESULT(size != 32, "invalid message size");
|
||||||
copy_bytes_from_java(penv, jmsg32, size, msg32);
|
copy_bytes_from_java(penv, jmsg32, size, msg32);
|
||||||
|
|
||||||
CHECKRESULT((*penv)->GetArrayLength(penv, jpubkey) != 32, "public key must be 32 bytes");
|
CHECKRESULT((*penv)->GetArrayLength(penv, jaggregate_public_key) != 32, "public key must be 32 bytes");
|
||||||
pub = (*penv)->GetByteArrayElements(penv, jpubkey, 0);
|
public_key_bytes = (*penv)->GetByteArrayElements(penv, jaggregate_public_key, 0);
|
||||||
result = secp256k1_xonly_pubkey_parse(ctx, &public_key, (unsigned char *)pub);
|
result = secp256k1_xonly_pubkey_parse(ctx, &aggregate_public_key, (unsigned char *)public_key_bytes);
|
||||||
(*penv)->ReleaseByteArrayElements(penv, jpubkey, pub, 0);
|
(*penv)->ReleaseByteArrayElements(penv, jaggregate_public_key, public_key_bytes, 0);
|
||||||
CHECKRESULT(!result, "secp256k1_xonly_pubkey_parse failed");
|
CHECKRESULT(!result, "secp256k1_xonly_pubkey_parse failed");
|
||||||
|
|
||||||
my_id33 = (*penv)->GetByteArrayElements(penv, jmy_id33, 0);
|
size = (*penv)->GetArrayLength(penv, jmy_id33);
|
||||||
(*penv)->ReleaseByteArrayElements(penv, jmy_id33, my_id33, 0);
|
CHECKRESULT(size != 33, "invalid my_id33 size");
|
||||||
|
copy_bytes_from_java(penv, jmy_id33, size, my_id33);
|
||||||
|
|
||||||
CHECKRESULT((*penv)->GetArrayLength(penv, jids33) != n_pubnonces, "invalid ids33 array size");
|
CHECKRESULT((*penv)->GetArrayLength(penv, jids33) != n_pubnonces, "invalid ids33 array size");
|
||||||
|
|
||||||
for (i = 0; i < n_pubnonces; i++)
|
for (i = 0; i < n_pubnonces; i++)
|
||||||
{
|
{
|
||||||
jbyteArray jid33 = (jbyteArray)(*penv)->GetObjectArrayElement(penv, jids33, i);
|
jbyteArray jid33 = (jbyteArray)(*penv)->GetObjectArrayElement(penv, jids33, i);
|
||||||
@ -2113,9 +2105,9 @@ JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256
|
|||||||
size = (*penv)->GetArrayLength(penv, jadaptor);
|
size = (*penv)->GetArrayLength(penv, jadaptor);
|
||||||
CHECKRESULT((size != 33) && (size != 65), "invalid public key size");
|
CHECKRESULT((size != 33) && (size != 65), "invalid public key size");
|
||||||
|
|
||||||
pub = (*penv)->GetByteArrayElements(penv, jadaptor, 0);
|
public_key_bytes = (*penv)->GetByteArrayElements(penv, jadaptor, 0);
|
||||||
result = secp256k1_ec_pubkey_parse(ctx, &adaptor, (unsigned char *)pub, size);
|
result = secp256k1_ec_pubkey_parse(ctx, &adaptor, (unsigned char *)public_key_bytes, size);
|
||||||
(*penv)->ReleaseByteArrayElements(penv, jadaptor, pub, 0);
|
(*penv)->ReleaseByteArrayElements(penv, jadaptor, public_key_bytes, 0);
|
||||||
CHECKRESULT(!result, "secp256k1_ec_pubkey_parse failed");
|
CHECKRESULT(!result, "secp256k1_ec_pubkey_parse failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2125,9 +2117,9 @@ JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256
|
|||||||
(const secp256k1_frost_pubnonce *const *)pubnonces,
|
(const secp256k1_frost_pubnonce *const *)pubnonces,
|
||||||
n_pubnonces,
|
n_pubnonces,
|
||||||
msg32,
|
msg32,
|
||||||
&public_key,
|
&aggregate_public_key,
|
||||||
my_id33,
|
my_id33,
|
||||||
(const unsigned char * const*) ids33,
|
ids33,
|
||||||
jtweak_cache == NULL ? NULL : &tweak_cache,
|
jtweak_cache == NULL ? NULL : &tweak_cache,
|
||||||
jadaptor == NULL ? NULL : &adaptor
|
jadaptor == NULL ? NULL : &adaptor
|
||||||
);
|
);
|
||||||
|
@ -830,6 +830,7 @@ public object Secp256k1Native : Secp256k1 {
|
|||||||
val nAdaptor = adaptor?.let {
|
val nAdaptor = adaptor?.let {
|
||||||
allocPublicKey(it).ptr
|
allocPublicKey(it).ptr
|
||||||
}
|
}
|
||||||
|
|
||||||
secp256k1_frost_nonce_process(
|
secp256k1_frost_nonce_process(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
session = nSession.ptr,
|
session = nSession.ptr,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user