-
Notifications
You must be signed in to change notification settings - Fork 121
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 libsecp256k1's sha256 function #86
Conversation
Looks good to me. @fanatid what do you think? |
sorry, I don't think that is a good decision add sha256/hash256 to this package |
NACK |
@@ -1,3 +1,3 @@ | |||
[submodule "secp256k1-src"] | |||
path = src/secp256k1-src | |||
url = https://github.com/bitcoin/secp256k1 | |||
url = https://github.com/bitcoin-core/secp256k1 |
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.
ACK
@fanatid, I feel these do belong here rather than a separate hashing module. All the messages to be signed or verified in bitcoin are sha256 hashes. The way I see it, sha256 has a particular relevance to this library, moreso than ripemd160+sha256, etc. |
@chjj one of the items why I do not want merge this, because |
commit with updating secp256k1 url cherry-picked |
other -- sorry, maybe in |
JFYI, start working on experimental library: addon with support ripemd160,sha1,sha256 |
Is this written from scratch or an extension to secp256k1? |
@axic I'm planning write from scratch, not as extension of secp256k1.. |
@chjj with what buffer size you tested |
@fanatid, interesting. I was benchmarking the double sha with small transactions (<1kb). I wasn't testing large chunks of data. Let me see what numbers I get. This is making me think of considering something like:
Kind of ridiculous, but it could work. |
@fanatid I think I figured out what's happening here. It looks like node.js does compile openssl with asm support, so, my function was fast on smaller payloads due to the fact that I wasn't instantiating 2 js objects like I would be with the node On a related note, I've finally written bindings for almost everything I need in bitcoin to give bcoin some extra perf: https://github.com/bcoin-org/bcoin-native/tree/master/src I ended up just using the openssl hash functions. |
@chjj agree, openssl asm version can win on large parts of data. On small one one-call functions is faster because they don't create any JS objects and need 1 call instead 3 (create, update, digest). |
Quick and dirty. This would be really nice to have considering that it is roughly 2-4x faster than openssl (the double sha is especially fast since it doesn't require extra instantiation of js objects, unlike node's crypto module). I think it's reasonable to not expose an updateable object since the constant crossover between js->c++ adds overhead, and I can't think of that much in bitcoin that would require or benefit from it. Having it as a single function is just simple and fast.
Also updated the git submodule to point at the bitcoin-core org.