Exemple #1
0
func init() {
	N, _ = new(big.Int).SetString("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", 16)
	// 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)
}
Exemple #2
0
func init() {
	N, _ = new(big.Int).SetString("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", 16)
	// N / 2 == 57896044618658097711785492504343953926418782139537452191302581570759080747168
	HalfN, _ = new(big.Int).SetString("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0", 16)

	// 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)
}
Exemple #3
0
	// work around issue 1560.
	if runtime.GOMAXPROCS(0) < 2 {
		runtime.GOMAXPROCS(2)
	}

	C.callbackInit()
	go C.runCallbacks()
}

// Func holds a pointer to the C callback function.
// When called, it calls the provided function f in a
// a Go context with the given argument.
//
// It can be used by first converting it to a function pointer
// and then calling from C.
// Here is an example that sets up the callback function:
// 	//static void (*callback)(void (*f)(void*), void *arg);
//	//void setCallback(void *c){
//	//	callback = c;
//	//}
//     import "C"
//	import "rog-go.googlecode.com/hg/exp/callback"
//
//	func init() {
//		C.setCallback(callback.Func)
//	}
//
var Func = callbackFunc

var callbackFunc = unsafe.Pointer(C.callbackFunc())
Exemple #4
0
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)
}