-
Notifications
You must be signed in to change notification settings - Fork 795
Add curve functions wrappers #671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Not sure why the CI is failing |
| return public_key_buffer; | ||
| } | ||
|
|
||
| namespace z85 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
z85 is not necessarily only used for curve, so I think I would prefer zmq::z85_endcode/z85_decode.
|
|
||
| namespace curve { | ||
|
|
||
| inline std::pair<std::string, std::string> keypair() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The style of the library would be to name these zmq::curve_keypair and zmq::curve_public.
| char *buffer = new char[buffer_size]; | ||
| auto *result = zmq_z85_encode(buffer, data.data(), data.size()); | ||
| if (result == nullptr) | ||
| throw zmq::error_t(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This leaks memory.
Could do std::string dest(buffer_size - 1); and write to that directly.
|
|
||
| inline std::vector<uint8_t> decode(const std::string& encoded) | ||
| { | ||
| size_t dest_size = static_cast<double>(encoded.size()) * 0.8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit afraid of these floating point computations here and in encode.
What about (encoded.size() * size_t{4}) / size_t{5}?
|
Could you try bumping the C++ version of the gcc-9 test to gcc-11? |
Fixes #670