`Zmq.Socket.get_curve_publickey` fails with EINVAL
rixed opened this issue · 0 comments
rixed commented
Here is the stacktrace:
Unix.Unix_error(Unix.EINVAL, "zmq_getsockopt", "")
Raised by primitive operation at file "zmq/src/zmq.ml", line 455, characters 4-47
The reason is pretty simple: for the curve related option, libzmq uses the size of the return buffer to choose between returning the raw key (if the buffer length is 32 or the z85 encoded version if it's 40+1 (+1 for some reason). Have a look at do_getsockopt_curve_key
in options.cpp
.
I'm about to send a PR that sets the return buffer length explicitly to 41 so we get back nice z85 keys. Other approaches are of course possible, such as adding an option for the user to choose, but I think it's more convenient to have only one format everywhere (given conversion functions between the two formats are available anyway).