From 23f1a0b783b351cc185dd46fd5f9992c74801469 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 24 Jun 2020 12:51:32 +0200 Subject: [PATCH] crypto/secp256k1: enable 128-bit int code and endomorphism optimization (#21203) * crypto/secp256k1: enable use of __int128 This speeds up scalar & field calculations a lot. * crypto/secp256k1: enable endomorphism optimization --- crypto/secp256k1/secp256.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crypto/secp256k1/secp256.go b/crypto/secp256k1/secp256.go index 35d0eef34a..9a7c06d7ce 100644 --- a/crypto/secp256k1/secp256.go +++ b/crypto/secp256k1/secp256.go @@ -8,10 +8,19 @@ package secp256k1 /* #cgo CFLAGS: -I./libsecp256k1 #cgo CFLAGS: -I./libsecp256k1/src/ + +#ifdef __SIZEOF_INT128__ +# define HAVE___INT128 +# define USE_FIELD_5X52 +# define USE_SCALAR_4X64 +#else +# define USE_FIELD_10X26 +# define USE_SCALAR_8X32 +#endif + +#define USE_ENDOMORPHISM #define USE_NUM_NONE -#define USE_FIELD_10X26 #define USE_FIELD_INV_BUILTIN -#define USE_SCALAR_8X32 #define USE_SCALAR_INV_BUILTIN #define NDEBUG #include "./libsecp256k1/src/secp256k1.c"