Cinterop for arrays of pointers

This commit is contained in:
kngako
2024-08-05 22:34:45 +02:00
parent 3c01a2aad4
commit 9e287feb26
4 changed files with 64 additions and 40 deletions

View File

@@ -107,13 +107,13 @@ public class Secp256k1CFunctions {
public static native byte[] secp256k1_musig_partial_sig_agg(long ctx, byte[] session, byte[][] psigs);
public static native byte[][] secp256k1_frost_shares_gen(long ctx, byte[][] vss_commitment, byte[] pok64, byte[] seed32, int total_signers, byte[][] ids33);
public static native byte[][][] secp256k1_frost_shares_gen(long ctx, byte[] pok64, byte[] seed32, int threshold, int total_signers, byte[][] ids33);
public static native byte[][] secp256k1_frost_share_agg(long ctx, byte[][][] vss_commitments, byte[] id33);
public static native byte[][] secp256k1_frost_share_agg(long ctx, byte[][][] vss_commitments, int totalShareCount, int threshold, byte[] id33);
public static native int secp256k1_frost_share_verify(long ctx, byte[] id33, byte[] share, byte[][] vss_commitment);
public static native byte[] secp256k1_frost_compute_pubshare(long ctx, byte[] id33, byte[][][] vss_commitments);
public static native byte[] secp256k1_frost_compute_pubshare(long ctx, int threshold, byte[] id33, byte[][][] vss_commitments, int totalSignersCount);
public static native byte[] secp256k1_frost_pubkey_tweak(long ctx, byte[] public_key);

View File

@@ -130,30 +130,39 @@ public object NativeSecp256k1 : Secp256k1 {
}
override fun frostSharesGen(
vssCommitment: Array<ByteArray>,
pok64: ByteArray,
seed32: ByteArray,
threshold: Int,
totalSigners: Int,
ids33: Array<ByteArray>
): Array<ByteArray> {
return Secp256k1CFunctions.secp256k1_frost_shares_gen(
): Pair<Array<ByteArray>, Array<ByteArray>> {
val result = Secp256k1CFunctions.secp256k1_frost_shares_gen(
Secp256k1Context.getContext(),
vssCommitment,
pok64,
seed32,
threshold,
totalSigners,
ids33
)
return Pair(
result[0],
result[1]
)
}
override fun frostShareAggregate(
totalShares: Array<ByteArray>,
vssCommitments: Array<Array<ByteArray>>,
totalShareCount: Int,
threshold: Int,
id33: ByteArray
): Pair<ByteArray, ByteArray> {
val result = Secp256k1CFunctions.secp256k1_frost_share_agg(
Secp256k1Context.getContext(),
vssCommitments,
totalShareCount,
threshold,
id33
)
return Pair(
@@ -177,13 +186,17 @@ public object NativeSecp256k1 : Secp256k1 {
}
override fun frostComputePublicShare(
threshold: Int,
id33: ByteArray,
vssCommitments: Array<Array<ByteArray>>
vssCommitments: Array<Array<ByteArray>>,
totalSignersCount: Int
): ByteArray {
return Secp256k1CFunctions.secp256k1_frost_compute_pubshare(
Secp256k1Context.getContext(),
threshold,
id33,
vssCommitments
vssCommitments,
totalSignersCount
)
}