worldcoin / developer-portal

The Worldcoin Developer Portal provides tools to interact with the Worldcoin SDK. Easiest way to get started with World ID.
https://developer.worldcoin.org
MIT License
66 stars 35 forks source link

fix: handle hex strings shorter than 64 characters (excluding 0x) #719

Closed 0xPenryn closed 5 months ago

0xPenryn commented 5 months ago

Handles inputs to proof verification shorter than 64 hex characters for nullifier_hash, merkle_root, external_nullifier, and signal_hash.

As these are all outputs of a hash function, there's no guarantee that the output is above a certain value, and we shouldn't expect to receive hex strings pre-padded.

This issue was identified during testing of an unrelated Android bug, where the merkle_root was valid, but only 63 hex characters long.

For the above-named inputs, this PR slices off 0x from the string, pads the hex string with 0 up to 64 characters, and adds the 0x back, then attempts to parse the hex string as a uint256.

penryn-lgtm-bot[bot] commented 5 months ago

lgtm 👍