#blocks #bitcoin #16 #up #run #times #ripemd-160

bitcoin-ripemd

RIPEMD-160 -- made up of 80 stages made up of 5 blocks that run 16 times each

4 releases

0.1.16-alpha.0 Mar 31, 2023
0.1.13-alpha.0 Mar 17, 2023
0.1.12-alpha.0 Jan 19, 2023
0.1.10-alpha.0 Jan 18, 2023

#6 in #16

Download history 158/week @ 2024-07-21 128/week @ 2024-07-28 126/week @ 2024-08-04 153/week @ 2024-08-11 116/week @ 2024-08-18 119/week @ 2024-08-25 113/week @ 2024-09-01 115/week @ 2024-09-08 123/week @ 2024-09-15 118/week @ 2024-09-22 118/week @ 2024-09-29 84/week @ 2024-10-13 73/week @ 2024-10-20 102/week @ 2024-10-27 94/week @ 2024-11-03

353 downloads per month
Used in 86 crates (via bitcoin-hash)

MIT license

275KB
798 lines

Rust Crate Description: bitcoin-ripemd

Short Description

Rust implementation of the RIPEMD-160 hash function used in the Bitcoin system.

Long Description

The bitcoin-ripemd crate is a direct translation of the RIPEMD-160 hash function implementation from the Bitcoin codebase in C++ to Rust. The RIPEMD-160 hash function is used extensively in the Bitcoin system, particularly in the creation of Bitcoin addresses.

The RIPEMD-160 hash function takes an input message of arbitrary length and produces a fixed-length output of 160 bits. The function is based on the MD4 and MD5 hash functions, but with some modifications to improve its security.

The implementation in this crate includes the Ripemd160 struct, which represents the hash state and provides methods for initializing the state, updating it with new data, and finalizing the hash to produce the 160-bit output. The crate also includes helper functions for performing the various rounds and transformations of the algorithm.

Note that as this crate is still in the process of translation, some function bodies may still be undergoing translation.

Relevant Mathematical Equations

While there are no specific mathematical equations or concepts involved in the bitcoin-ripemd crate, the RIPEMD-160 hash function is based on the MD4 and MD5 hash functions, which themselves use concepts from modular arithmetic and bitwise operations.

16> could you teach me about how RIPEMD-160 works?

RIPEMD-160 is a cryptographic hash function that is used in various applications such as Bitcoin, OpenPGP, and SSH. It was designed by Hans Dobbertin, Antoon Bosselaers, and Bart Preneel as an improved version of the original RIPEMD hash function, which had been found to have weaknesses.

RIPEMD-160 operates on 512-bit blocks of input data and produces a fixed-length 160-bit output, making it a member of the same family of hash functions as SHA-1 and SHA-2. The algorithm uses a series of rounds of bit manipulation and nonlinear functions to transform the input data and create the output hash.

The algorithm starts by initializing a state of five 32-bit integers. Then, for each 512-bit block of input data, the state is transformed through a series of five rounds, each of which applies a different set of operations to the state.

The first two rounds are similar to those used in the MD4 and MD5 hash functions. They involve mixing the state with the input data, applying a nonlinear function, and shifting and rotating the state values.

The third and fourth rounds are similar to those used in the SHA-1 hash function. They involve mixing the state with the input data, applying a nonlinear function, and rotating and XORing the state values.

The fifth and final round involves permuting the state values in a fixed way, after which the resulting state is combined with the previous state and the input data to produce the final hash value.

RIPEMD-160 is designed to be resistant to various cryptographic attacks, including collision attacks, where two different inputs produce the same hash output. However, like all hash functions, it is not completely immune to attack, and its security has been called into question in recent years. Nonetheless, it remains a widely used hash function in many applications.

Dependencies

~88MB
~853K SLoC