crypto/secp256k1: raise internal errors as recoverable Go panic
This commit is contained in:
@ -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 (
|
||||
|
Reference in New Issue
Block a user