aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/secp256k1/secp256.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-11-17 01:04:56 +0800
committerFelix Lange <fjl@twurst.com>2015-11-17 16:53:10 +0800
commit5159f8f6493bfa3cfb0ee3b1517f4576d4c9d2de (patch)
tree692c95113054434e13a0b77981e3c4953d4464aa /crypto/secp256k1/secp256.go
parent1b29aed1283bd050ac7b782b352a7c87d88d82ab (diff)
downloaddexon-5159f8f6493bfa3cfb0ee3b1517f4576d4c9d2de.tar
dexon-5159f8f6493bfa3cfb0ee3b1517f4576d4c9d2de.tar.gz
dexon-5159f8f6493bfa3cfb0ee3b1517f4576d4c9d2de.tar.bz2
dexon-5159f8f6493bfa3cfb0ee3b1517f4576d4c9d2de.tar.lz
dexon-5159f8f6493bfa3cfb0ee3b1517f4576d4c9d2de.tar.xz
dexon-5159f8f6493bfa3cfb0ee3b1517f4576d4c9d2de.tar.zst
dexon-5159f8f6493bfa3cfb0ee3b1517f4576d4c9d2de.zip
crypto/secp256k1: raise internal errors as recoverable Go panic
Diffstat (limited to 'crypto/secp256k1/secp256.go')
-rw-r--r--crypto/secp256k1/secp256.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/crypto/secp256k1/secp256.go b/crypto/secp256k1/secp256.go
index 634e1c0b8..4269b6a8c 100644
--- a/crypto/secp256k1/secp256.go
+++ b/crypto/secp256k1/secp256.go
@@ -35,6 +35,10 @@ package secp256k1
#define NDEBUG
#include "./libsecp256k1/src/secp256k1.c"
#include "./libsecp256k1/src/modules/recovery/main_impl.h"
+
+typedef void (*callbackFunc) (const char* msg, void* data);
+extern void secp256k1GoPanicIllegal(const char* msg, void* data);
+extern void secp256k1GoPanicError(const char* msg, void* data);
*/
import "C"
@@ -61,6 +65,8 @@ var context *C.secp256k1_context
func init() {
// around 20 ms on a modern CPU.
context = C.secp256k1_context_create(3) // SECP256K1_START_SIGN | SECP256K1_START_VERIFY
+ C.secp256k1_context_set_illegal_callback(context, C.callbackFunc(C.secp256k1GoPanicIllegal), nil)
+ C.secp256k1_context_set_error_callback(context, C.callbackFunc(C.secp256k1GoPanicError), nil)
}
var (