Optimized RIPEMD160 #788

Open
opened 2025-12-28 17:14:15 +00:00 by sami · 0 comments
Owner

Originally created by @roman-khimov on GitHub (Aug 25, 2021).

We use golang.org/x/crypto/ripemd160 which is cross-platform, but doesn't have and won't have any optimized platform-specific version of the hash. Surprisingly, even though everyone and their dog in crypto space are using RIPEMD160 there are no asm implementations of it in Go. And even in C there is just ia-32 implementation in openssl. So either generic implementation is compiled into perfect assembly and optimizing it makes no sense (but it is slower than SHA256 in the profiler, so I doubt that), or no one really tried.

It'd be interesting to check this and try to make some amd64 version.

Even though it's not exactly a bottleneck every script we have gets hashed with SHA256 and then RIPEMD160, so the number of hashes we do is quite substantial and having an optimized version can't hurt.

Originally created by @roman-khimov on GitHub (Aug 25, 2021). We use `golang.org/x/crypto/ripemd160` which is cross-platform, but doesn't have and won't have any optimized platform-specific version of the hash. Surprisingly, even though everyone and their dog in crypto space are using RIPEMD160 there are no asm implementations of it in Go. And even in C there is just [ia-32 implementation in openssl](https://github.com/openssl/openssl/blob/master/crypto/ripemd/asm/rmd-586.pl). So either generic implementation is compiled into perfect assembly and optimizing it makes no sense (but it is slower than SHA256 in the profiler, so I doubt that), or no one really tried. It'd be interesting to check this and try to make some amd64 version. Even though it's not exactly a bottleneck every script we have gets hashed with SHA256 and then RIPEMD160, so the number of hashes we do is quite substantial and having an optimized version can't hurt.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neo-go#788
No description provided.