Skip to content

Request for Bounty Consideration: rotateLeft(..., -32) Bug in Blake2bfMessageDigest.java #6353

@jumbobaam

Description

@jumbobaam

In Blake2bfMessageDigest.java, the following line was used:

v[l] = Long.rotateLeft(v[l] ^ v[i], -32);
While Java's Long.rotateLeft accepts negative values due to internal modulo behavior, this usage violates cryptographic clarity, portability, and specification compliance. BLAKE2f explicitly defines a 32-bit right rotation, not a left rotation with a negative shift.

✅ Suggested and Implemented Fix

v[l] = Long.rotateRight(v[l] ^ v[i], 32);
This version:

Matches the BLAKE2f spec

Is portable to other languages (e.g., C, Rust)

Avoids silent implementation divergence

Removes ambiguity in security-critical code

🔐 Security & Functional Impact
Although Java produces the correct result here, the use of rotateLeft(..., -32) is:

Non-obvious and error-prone

Incompatible with spec-verification or cross-language implementations

Potentially misleading during audits or cryptographic reviews

Risky if the code is refactored, translated, or reviewed by cryptographers expecting exact spec compliance

If used in blockchain systems (like BLAKE2f in Ethereum precompiles or Tron’s hashing), such divergence could lead to:

Signature verification failures

Proof mismatch across clients

Inconsistent behavior across JVMs or FFI boundaries

🎯 Why This Deserves Bounty Consideration
Affects cryptographic correctness

Triggered by a single-line change

Clear, documented, and reproducible behavior

Fix is adopted as suggested

Similar bugs have historically caused CVEs in other protocols (TLS, Bitcoin, Ethereum)

I appreciate your time and your commitment to secure and portable cryptographic implementations. Please let me know if additional clarifications or PoC materials are needed to support the bounty eligibility review.

Best regards,
@jumbobalm

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions