Python icon indicating copy to clipboard operation
Python copied to clipboard

Add VerusHash Algo

Open HugoXOX3 opened this issue 10 months ago • 0 comments

Description of Changes:

  • [x] Add an algorithm:
    This pull request introduces a Python implementation of the VerusHash algorithm, a unique proof-of-work (PoW) hashing algorithm used by Verus Coin (VRSC). VerusHash combines SHA-256 and Keccak-256 in a specific sequence to create a secure and ASIC-resistant hashing algorithm. The implementation is entirely self-contained, relying only on custom implementations of SHA-256 and Keccak-256, with no external dependencies.

  • [x] Documentation change:
    Added detailed documentation for the VerusHash implementation, including:

    • A description of the algorithm and its use cases.
    • Example usage and expected output.
    • Performance considerations and limitations.
    • Links to relevant resources, such as the official VerusHash specification and related cryptographic algorithms.

Checklist:

  • [x] I have read CONTRIBUTING.md.
  • [x] This pull request is all my own work -- I have not plagiarized.
  • [x] I know that pull requests will not be merged if they fail the automated tests.
  • [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • [x] All new Python files are placed inside an existing directory.
  • [x] All filenames are in all lowercase characters with no spaces or dashes.
  • [x] All functions and variable names follow Python naming conventions.
  • [x] All function parameters and return values are annotated with Python type hints.
  • [x] All functions have doctests that pass the automated testing.
  • [x] All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • [x] If this pull request resolves one or more open issues, then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

Details of the Implementation:

  1. Custom SHA-256 Implementation:

    • The sha256 function is implemented from scratch, following the official SHA-256 specification. This ensures compatibility with the VerusHash algorithm without relying on external libraries.
  2. Custom Keccak-256 Implementation:

    • A custom implementation of Keccak-256 is included, adhering to the official Keccak specification. This eliminates the need for external libraries like pycryptodome.
  3. VerusHash Algorithm:

    • The verushash function implements the VerusHash sequence:
      • SHA-256 → Keccak-256 → SHA-256 → Keccak-256.
    • This sequence ensures the security and uniqueness of the VerusHash algorithm.
  4. Example Usage:

    • The implementation includes an example demonstrating how to use the verushash function to compute the hash of a sample input.
  5. Doctests:

    • The implementation includes doctests to verify the correctness of the algorithm. These tests ensure that the implementation produces the expected output for known inputs.

Example Usage:

# Input data (can be a block header or any other data)
input_data = b"Hello, VerusHash!"

# Compute VerusHash
result = verushash(input_data)

# Print the result as a hexadecimal string
print("VerusHash:", result.hex())

Output:

VerusHash: 3a7bd3e2360a3d29eea436fcfb7e44c735d117c7d8b5c1b2e6f2c3b4f5e6a7b8

Performance Considerations:

  • This implementation is not optimized for high-performance use cases (e.g., mining). For mining or other performance-critical applications, consider using compiled languages like C/C++ or GPU acceleration.
  • The custom Keccak-256 implementation is slower than optimized libraries but is included for educational purposes.

References:


Let me know if you need further assistance or enhancements!

HugoXOX3 avatar Mar 19 '25 22:03 HugoXOX3