Export Schnorr signature API (#32)
Implement Schnorr signatures (BIP 340)
This commit is contained in:
@@ -64,4 +64,8 @@ public class Secp256k1CFunctions {
|
||||
public static native byte[] secp256k1_ecdsa_recover(long ctx, byte[] sig, byte[] msg32, int recid);
|
||||
|
||||
public static native byte[] secp256k1_compact_to_der(long ctx, byte[] sig);
|
||||
|
||||
public static native byte[] secp256k1_schnorrsig_sign(long ctx, byte[] msg, byte[] seckey, byte[] aux_rand32);
|
||||
|
||||
public static native int secp256k1_schnorrsig_verify(long ctx, byte[] sig, byte[] msg, byte[] pubkey);
|
||||
}
|
||||
|
||||
@@ -84,6 +84,14 @@ public object NativeSecp256k1 : Secp256k1 {
|
||||
return Secp256k1CFunctions.secp256k1_compact_to_der(Secp256k1Context.getContext(), sig)
|
||||
}
|
||||
|
||||
override fun verifySchnorr(signature: ByteArray, data: ByteArray, pub: ByteArray): Boolean {
|
||||
return Secp256k1CFunctions.secp256k1_schnorrsig_verify(Secp256k1Context.getContext(), signature, data, pub) == 1
|
||||
}
|
||||
|
||||
override fun signSchnorr(data: ByteArray, sec: ByteArray, auxrand32: ByteArray?): ByteArray {
|
||||
return Secp256k1CFunctions.secp256k1_schnorrsig_sign(Secp256k1Context.getContext(), data, sec, auxrand32)
|
||||
}
|
||||
|
||||
override fun cleanup() {
|
||||
return Secp256k1CFunctions.secp256k1_context_destroy(Secp256k1Context.getContext())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user