Skip to content

Conversation

anim001k
Copy link

Description

Fixes a potential crash in @semaphore-protocol/utils when decodeMessage receives non-string bytes32 values (like addresses, hashes, or arbitrary uint256).

Problem

The decodeBytes32String function in ethers v6 throws an exception when attempting to decode invalid UTF-8 sequences or non-string bytes32 values. This could cause UI/CLI applications to crash unexpectedly.

Solution

  • Added try-catch wrapper around decodeBytes32String call
  • Returns hex representation as fallback when decoding fails
  • Maintains backward compatibility for valid string inputs
  • Added test coverage for invalid bytes32 handling

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