Replies: 2 comments 2 replies
-
We could use the HMAC implementation, but I did a bit of benchmarking in regards to scrypt for example, and our implementation is actually faster than the scrypt crate by 30%(And actually runs it in parallel if the parallelization parameter is greater than 1, which is actually an open issue on their repo). In general, the biggest thing really which I think 100% warrants us using an external library should be if there's any possibility of hardware acceleration. It'd be a bad idea to make a software implementation of sha256 because a lot of CPUs have support for hardware acceleration in regards to it. I don't know for certain if HMAC is in a similar situation, but if it is, we should 100% use the external library. There's a similar situation for AES(hence why it's imported instead of implemented ourselves), since implementing it ourselves would prevent us from using their native hardware acceleration. Sometimes it's better to use external libraries(especially if it involves a ton of oddly specific edgecases that bloats up the code, or if the external library has many different configurations for different cpus), but doing it ourselves can be good in situations where we could do it faster or better than the external library itself(provided that it's not too difficult to maintain). |
Beta Was this translation helpful? Give feedback.
-
Overall I think something like this issue isn't a priority and wouldn't help us reach any of our MVP's. So regardless of the discuss I don't think anybody on the team should work on this nomatter the discussion for at least until we have production grade software on mainnet. The only exception to this would be if there was a security vulnerability or if the implementation doesn't work. I think as a team we should focus on issues that move the needle forward. We have limited resources, etc, etc. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'd like to discuss about our own implementation of crypgoraphic primitives using in
ream-keystore
package. Although I believe that our implementation is correct and good to read (double-checked with the specification), I would like to suggest to use the existing libraries for these implementation.Rust Crypto team provides the most of the primitives we need to build a validator client, inclduing HMAC, PBKDF2, and scrypt. For example,
hmac.rs
can be simply replaced like the following diff (this passes all unit tests):Also, as HMAC is just a building block for PBKDF2 and scrypt, we can just delete
hmac.rs
file and use Rust Crypto's implementation by importing it.There are many pros and some con using external libraries:
Pros
Con
@Patchoulis @KolbyML
If we all are on the same line for this discussion, I'd love to open a new issue and work on this issue. (I mentioned relevant contributors but any feedbacks from anyone are welcomed!)
Beta Was this translation helpful? Give feedback.
All reactions