Skip to content

Conversation

viktorking7
Copy link

Description

Security Fix: Replaced unsafe bit shift operation with proper SNARK scalar field reduction in packages/proof/src/hash.ts.

Problem

The hash function was using >> 8n bit shift which discards 8 least significant bits of the keccak256 hash, significantly reducing cryptographic entropy and increasing collision risk.

Solution

  • Replaced bit shift with modular arithmetic using SNARK scalar field modulus
  • Preserves full hash entropy (256 bits → 248 bits was unsafe)
  • Maintains SNARK compatibility with proper field reduction
  • Eliminates collision risk from entropy loss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant