Closed Hugongra closed 1 month ago
Hi @Hugongra
This code is independent of the library. You create new hashing functions (even those not needed by Bitcoin) although they also exist in the library. The measurements are also outside the scope of this project.
Overview
This pull request enriches the bitcoin-utils package by introducing a comprehensive suite of cryptographic hash functions and utility scripts designed to assess and demonstrate the robustness of these functions.
Modifications
hashfunctions.py Implemented Functions: hash_sha256(b: bytes) -> bytes: Computes SHA-256 hash. hash_ripemd160(b: bytes) -> bytes: Computes RIPEMD-160 hash. hash_sha1(b: bytes) -> bytes: Computes SHA-1 hash. calculate_hash_rate(hash_function, duration_seconds=1): Measures the computation rate for any given hash function. estimate_computers_needed(hash_rate_per_computer, years_to_break): Estimates the computational resources needed for breaking a hash via a preimage attack in specified years.
security_hash_functions.py Purpose: Demonstrates the use of hash functions to calculate hash rates and estimate the number of computers required to theoretically perform a preimage attack on SHA-256 within one year.
Rationale
This update aims to provide tools for understanding and evaluating the security implications of using different cryptographic hash functions in blockchain technologies. It also serves as an educational resource for learning about the computational demands and security strength of these cryptographic functions.
Invitation for Collaboration
Feedback and suggestions on these implementations are highly encouraged, especially in areas of enhancing security features and educational clarity. Contributions for further cryptographic explorations are also welcome.