ExWeb3 / ex_keccak

Elixir library for computing Keccak SHA3-256 hashes using a NIF built tiny-keccak Rust crate.
Apache License 2.0
25 stars 20 forks source link

Just a question #31

Closed somoza closed 2 years ago

somoza commented 2 years ago

Sorry for the use issues for this... Please close it as soon you answer me.

I'm just curious... Why did you use rust for this and not native erlang? Did you make some benchmarks or something to make this decision?

tzumby commented 2 years ago

Hey @somoza, this is def the right place to ask this kind of questions :).

At the time I wrote this, there was only a C based Nif that wasn't maintained anymore. From what I could research there was no pure Erlang implementation. Maybe that's changed now ?

In terms of benchmark, I don't think we need to compare Erlang with Rust on those operations. Rust would probably be orders of magnitude faster.

somoza commented 2 years ago

Thanks for tour answer! I found that BCrypt.base module uses the Erlang crypto.erl

May this do the work?

somoza commented 2 years ago

If so, I would be glad to help on building a prototype using the Erlang library, and besides, compare both with some benchmarking.

tzumby commented 2 years ago

Yes, the bcrypt_elixir lib does use the native crypto module. Erlang crypto does includes sha3, but that won't help with this as the final padding is different and results in a different hash. I supposed one could take the native implementation and change the padding.

somoza commented 2 years ago

Yup, you're right. I'm not an Erlang programmer but I will try to add this to the Erlang OTP anyway. Thanks!

somoza commented 2 years ago

It depends on the OpenSSL release (Erlang uses its apis), so we have to wait. The other option is to program it on pure erlang as someone did on Rust ^^

https://github.com/openssl/openssl/issues/19304#issuecomment-1263230431