waku-org / js-rln

Browser library providing the cryptographic functions for Waku RLN Relay https://rfc.vac.dev/spec/17/
Apache License 2.0
5 stars 1 forks source link

fix: use correct offset when converting commitment to bigint #103

Closed adklempner closed 6 months ago

adklempner commented 6 months ago

The function that converts a Uint8Array to bigint was using a DataView to access the underlying buffer representing the credentials generated from zerokit. By accessing the buffer of a subarray directly without specifying the offset, it reads bytes from the beginning of the buffer, which results in the bigint representation of IdTrapdoor NOT IdCommitment. Applications using the library to generate credentials would end up sending the wrong value to the RLN smart contract.

Fix is to add the correct offset to the DataView.

weboko commented 6 months ago

Can you introduce unit test for identity and util function, please? Can be done as follow up, @adklempner