-
Notifications
You must be signed in to change notification settings - Fork 162
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
Expose SHA-256 functions #146
Conversation
A couple other repos that would benefit from this change are nim-blscurve (current workaround to expose sha256 at https://github.com/status-im/nim-blscurve/blob/master/blscurve/blst/blst_sha256.c) and the in-progress nim-kzg-4844 repo. |
I don't see a compelling need for exposing the CTX structure. I mean why not instead of exposing init/update/final expose single-shot subroutine? One that simply takes data and emits its hash... With private CTX allocated on stack... |
I mean
for src/exports.c. |
That's a good idea too. I like that approach. Will make the change. |
/* | ||
* SHA-256 hash function. | ||
*/ | ||
void blst_sha256(unsigned char md[32], const void *msg, size_t len); |
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.
Not that it actually matters in the context, but blst.h follows a specific convention for naming arguments that reflects so called typemaps in blst.swg. For this reason I'll change this line as I commit.
BTW, how would byte *msg
look at your side? I mean void*
is a convenient way to avoid specific type warnings [or rather excessive casts], but at the same type time it masks potentially meaningful programming mistakes. For example passing pointer to an integer might work in specific context, but formally speaking it's not exactly legit.
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.
A byte *msg
would be fine on our end. Our input is uint8_t*
(byte*
) so it works well.
Any hard objections, @henridf? |
nope, I think this should work fine on my end too |
Thanks! |
This PR exposes the blst sha256 functions in the auxiliary header. This is for c-kzg-4844 which currently patches blst to expose these functions. It would beneficial to us if these functions were exported. This PR only makes these functions available from C and not any of the other bindings. This is all we want/need at the moment.