Skip to content

Commit 80773a6

Browse files
committed
Merge dashpay#425: Remove Schnorr experiment
e06e878 Remove Schnorr experiment (Pieter Wuille)
2 parents 04c8ef3 + e06e878 commit 80773a6

12 files changed

+2
-868
lines changed

Makefile.am

-4
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,6 @@ if ENABLE_MODULE_ECDH
154154
include src/modules/ecdh/Makefile.am.include
155155
endif
156156

157-
if ENABLE_MODULE_SCHNORR
158-
include src/modules/schnorr/Makefile.am.include
159-
endif
160-
161157
if ENABLE_MODULE_RECOVERY
162158
include src/modules/recovery/Makefile.am.include
163159
endif

configure.ac

+1-19
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,6 @@ AC_ARG_ENABLE(module_ecdh,
119119
[enable_module_ecdh=$enableval],
120120
[enable_module_ecdh=no])
121121

122-
AC_ARG_ENABLE(module_schnorr,
123-
AS_HELP_STRING([--enable-module-schnorr],[enable Schnorr signature module (experimental)]),
124-
[enable_module_schnorr=$enableval],
125-
[enable_module_schnorr=no])
126-
127122
AC_ARG_ENABLE(module_recovery,
128123
AS_HELP_STRING([--enable-module-recovery],[enable ECDSA pubkey recovery module (default is no)]),
129124
[enable_module_recovery=$enableval],
@@ -381,9 +376,6 @@ fi
381376
if test x"$use_jni" != x"no"; then
382377
AX_JNI_INCLUDE_DIR
383378
have_jni_dependencies=yes
384-
if test x"$enable_module_schnorr" = x"no"; then
385-
have_jni_dependencies=no
386-
fi
387379
if test x"$enable_module_ecdh" = x"no"; then
388380
have_jni_dependencies=no
389381
fi
@@ -392,7 +384,7 @@ if test x"$use_jni" != x"no"; then
392384
fi
393385
if test "x$have_jni_dependencies" = "xno"; then
394386
if test x"$use_jni" = x"yes"; then
395-
AC_MSG_ERROR([jni support explicitly requested but headers/dependencies were not found. Enable ECDH and Schnorr and try again.])
387+
AC_MSG_ERROR([jni support explicitly requested but headers/dependencies were not found. Enable ECDH and try again.])
396388
fi
397389
AC_MSG_WARN([jni headers/dependencies not found. jni support disabled])
398390
use_jni=no
@@ -421,10 +413,6 @@ if test x"$enable_module_ecdh" = x"yes"; then
421413
AC_DEFINE(ENABLE_MODULE_ECDH, 1, [Define this symbol to enable the ECDH module])
422414
fi
423415

424-
if test x"$enable_module_schnorr" = x"yes"; then
425-
AC_DEFINE(ENABLE_MODULE_SCHNORR, 1, [Define this symbol to enable the Schnorr signature module])
426-
fi
427-
428416
if test x"$enable_module_recovery" = x"yes"; then
429417
AC_DEFINE(ENABLE_MODULE_RECOVERY, 1, [Define this symbol to enable the ECDSA pubkey recovery module])
430418
fi
@@ -442,7 +430,6 @@ AC_MSG_NOTICE([Using bignum implementation: $set_bignum])
442430
AC_MSG_NOTICE([Using scalar implementation: $set_scalar])
443431
AC_MSG_NOTICE([Using endomorphism optimizations: $use_endomorphism])
444432
AC_MSG_NOTICE([Building ECDH module: $enable_module_ecdh])
445-
AC_MSG_NOTICE([Building Schnorr signatures module: $enable_module_schnorr])
446433
AC_MSG_NOTICE([Building ECDSA pubkey recovery module: $enable_module_recovery])
447434
AC_MSG_NOTICE([Using jni: $use_jni])
448435

@@ -451,12 +438,8 @@ if test x"$enable_experimental" = x"yes"; then
451438
AC_MSG_NOTICE([WARNING: experimental build])
452439
AC_MSG_NOTICE([Experimental features do not have stable APIs or properties, and may not be safe for production use.])
453440
AC_MSG_NOTICE([Building ECDH module: $enable_module_ecdh])
454-
AC_MSG_NOTICE([Building Schnorr signatures module: $enable_module_schnorr])
455441
AC_MSG_NOTICE([******])
456442
else
457-
if test x"$enable_module_schnorr" = x"yes"; then
458-
AC_MSG_ERROR([Schnorr signature module is experimental. Use --enable-experimental to allow.])
459-
fi
460443
if test x"$enable_module_ecdh" = x"yes"; then
461444
AC_MSG_ERROR([ECDH module is experimental. Use --enable-experimental to allow.])
462445
fi
@@ -476,7 +459,6 @@ AM_CONDITIONAL([USE_TESTS], [test x"$use_tests" != x"no"])
476459
AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"])
477460
AM_CONDITIONAL([USE_ECMULT_STATIC_PRECOMPUTATION], [test x"$set_precomp" = x"yes"])
478461
AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"])
479-
AM_CONDITIONAL([ENABLE_MODULE_SCHNORR], [test x"$enable_module_schnorr" = x"yes"])
480462
AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"])
481463
AM_CONDITIONAL([USE_JNI], [test x"$use_jni" == x"yes"])
482464
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$use_external_asm" = x"yes"])

include/secp256k1_schnorr.h

-173
This file was deleted.

src/java/org/bitcoin/NativeSecp256k1.java

+1-33
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* <p>You can find an example library that can be used for this at https://github.com/bitcoin/secp256k1</p>
3333
*
3434
* <p>To build secp256k1 for use with bitcoinj, run
35-
* `./configure --enable-jni --enable-experimental --enable-module-schnorr --enable-module-ecdh`
35+
* `./configure --enable-jni --enable-experimental --enable-module-ecdh`
3636
* and `make` then copy `.libs/libsecp256k1.so` to your system library path
3737
* or point the JVM to the folder containing it with -Djava.library.path
3838
* </p>
@@ -417,36 +417,6 @@ public static synchronized boolean randomize(byte[] seed) throws AssertFailExcep
417417
}
418418
}
419419

420-
public static byte[] schnorrSign(byte[] data, byte[] sec) throws AssertFailException {
421-
Preconditions.checkArgument(data.length == 32 && sec.length <= 32);
422-
423-
ByteBuffer byteBuff = nativeECDSABuffer.get();
424-
if (byteBuff == null) {
425-
byteBuff = ByteBuffer.allocateDirect(32 + 32);
426-
byteBuff.order(ByteOrder.nativeOrder());
427-
nativeECDSABuffer.set(byteBuff);
428-
}
429-
byteBuff.rewind();
430-
byteBuff.put(data);
431-
byteBuff.put(sec);
432-
433-
byte[][] retByteArray;
434-
435-
r.lock();
436-
try {
437-
retByteArray = secp256k1_schnorr_sign(byteBuff, Secp256k1Context.getContext());
438-
} finally {
439-
r.unlock();
440-
}
441-
442-
byte[] sigArr = retByteArray[0];
443-
int retVal = new BigInteger(new byte[] { retByteArray[1][0] }).intValue();
444-
445-
assertEquals(sigArr.length, 64, "Got bad signature length.");
446-
447-
return retVal == 0 ? new byte[0] : sigArr;
448-
}
449-
450420
private static native long secp256k1_ctx_clone(long context);
451421

452422
private static native int secp256k1_context_randomize(ByteBuffer byteBuff, long context);
@@ -471,8 +441,6 @@ public static byte[] schnorrSign(byte[] data, byte[] sec) throws AssertFailExcep
471441

472442
private static native byte[][] secp256k1_ec_pubkey_parse(ByteBuffer byteBuff, long context, int inputLen);
473443

474-
private static native byte[][] secp256k1_schnorr_sign(ByteBuffer byteBuff, long context);
475-
476444
private static native byte[][] secp256k1_ecdh(ByteBuffer byteBuff, long context, int inputLen);
477445

478446
}

src/java/org/bitcoin/NativeSecp256k1Test.java

-21
Original file line numberDiff line numberDiff line change
@@ -167,22 +167,6 @@ public static void testRandomize() throws AssertFailException {
167167
assertEquals( result, true, "testRandomize");
168168
}
169169

170-
/**
171-
* This tests signSchnorr() for a valid secretkey
172-
*/
173-
public static void testSchnorrSign() throws AssertFailException{
174-
175-
byte[] data = BaseEncoding.base16().lowerCase().decode("CF80CD8AED482D5D1527D7DC72FCEFF84E6326592848447D2DC0B0E87DFC9A90".toLowerCase()); //sha256hash of "testing"
176-
byte[] sec = BaseEncoding.base16().lowerCase().decode("67E56582298859DDAE725F972992A07C6C4FB9F62A8FFF58CE3CA926A1063530".toLowerCase());
177-
178-
byte[] resultArr = NativeSecp256k1.schnorrSign(data, sec);
179-
String sigString = javax.xml.bind.DatatypeConverter.printHexBinary(resultArr);
180-
assertEquals( sigString, "C5E929AA058B982048760422D3B563749B7D0E50C5EBD8CD2FFC23214BD6A2F1B072C13880997EBA847CF20F2F90FCE07C1CA33A890A4127095A351127F8D95F" , "testSchnorrSign");
181-
}
182-
183-
/**
184-
* This tests signSchnorr() for a valid secretkey
185-
*/
186170
public static void testCreateECDHSecret() throws AssertFailException{
187171

188172
byte[] sec = BaseEncoding.base16().lowerCase().decode("67E56582298859DDAE725F972992A07C6C4FB9F62A8FFF58CE3CA926A1063530".toLowerCase());
@@ -216,11 +200,6 @@ public static void main(String[] args) throws AssertFailException{
216200
testSignPos();
217201
testSignNeg();
218202

219-
//Test Schnorr (partial support) //TODO
220-
testSchnorrSign();
221-
//testSchnorrVerify
222-
//testSchnorrRecovery
223-
224203
//Test privKeyTweakAdd() 1
225204
testPrivKeyTweakAdd_1();
226205

src/java/org_bitcoin_NativeSecp256k1.c

-34
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "include/secp256k1.h"
66
#include "include/secp256k1_ecdh.h"
77
#include "include/secp256k1_recovery.h"
8-
#include "include/secp256k1_schnorr.h"
98

109

1110
SECP256K1_API jlong JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ctx_1clone
@@ -333,39 +332,6 @@ SECP256K1_API jlong JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1p
333332
return 0;
334333
}
335334

336-
SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1schnorr_1sign
337-
(JNIEnv* env, jclass classObject, jobject byteBufferObject, jlong ctx_l)
338-
{
339-
secp256k1_context *ctx = (secp256k1_context*)(uintptr_t)ctx_l;
340-
unsigned char* data = (unsigned char*) (*env)->GetDirectBufferAddress(env, byteBufferObject);
341-
unsigned char* secKey = (unsigned char*) (data + 32);
342-
343-
jobjectArray retArray;
344-
jbyteArray sigArray, intsByteArray;
345-
unsigned char intsarray[1];
346-
unsigned char sig[64];
347-
348-
int ret = secp256k1_schnorr_sign(ctx, sig, data, secKey, NULL, NULL);
349-
350-
intsarray[0] = ret;
351-
352-
retArray = (*env)->NewObjectArray(env, 2,
353-
(*env)->FindClass(env, "[B"),
354-
(*env)->NewByteArray(env, 1));
355-
356-
sigArray = (*env)->NewByteArray(env, 64);
357-
(*env)->SetByteArrayRegion(env, sigArray, 0, 64, (jbyte*)sig);
358-
(*env)->SetObjectArrayElement(env, retArray, 0, sigArray);
359-
360-
intsByteArray = (*env)->NewByteArray(env, 1);
361-
(*env)->SetByteArrayRegion(env, intsByteArray, 0, 1, (jbyte*)intsarray);
362-
(*env)->SetObjectArrayElement(env, retArray, 1, intsByteArray);
363-
364-
(void)classObject;
365-
366-
return retArray;
367-
}
368-
369335
SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdh
370336
(JNIEnv* env, jclass classObject, jobject byteBufferObject, jlong ctx_l, jint publen)
371337
{

0 commit comments

Comments
 (0)