Exemple #1
0
/*
Generate a new CURVE keypair

See: http://api.zeromq.org/4-1:zmq-curve-keypair#toc2
*/
func NewCurveKeypair() (z85_public_key, z85_secret_key string, err error) {
	var pubkey, seckey [41]byte
	if i, err := C.zmq_curve_keypair((*C.char)(unsafe.Pointer(&pubkey[0])), (*C.char)(unsafe.Pointer(&seckey[0]))); i != 0 {
		return "", "", errget(err)
	}
	return string(pubkey[:40]), string(seckey[:40]), nil
}
Exemple #2
0
// Because gozmq does not yet expose this for us, we have to expose it ourselves
func CurveKeyPair() (string, string, error) {
	var pub [41]C.char
	var priv [41]C.char

	// Because gozmq does not yet expose this for us, we have to expose it ourselves
	if rc, err := C.zmq_curve_keypair(&pub[0], &priv[0]); rc != 0 {
		return "", "", casterr(err)
	}

	return C.GoString(&pub[0]), C.GoString(&priv[0]), nil
}