From 769505e96f7514a9ac77dffef280019584ec1402 Mon Sep 17 00:00:00 2001 From: s1fr0 <28568419+s1fr0@users.noreply.github.com> Date: Thu, 13 Oct 2022 01:53:12 +0200 Subject: [PATCH] fix(rln): add mod on input pk --- contracts/Rln.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contracts/Rln.sol b/contracts/Rln.sol index 4df5fcc..c17673e 100644 --- a/contracts/Rln.sol +++ b/contracts/Rln.sol @@ -3,6 +3,7 @@ pragma solidity 0.8.15; import { IPoseidonHasher } from "./PoseidonHasher.sol"; contract RLN { + uint256 constant Q = 21888242871839275222246405745257275088548364400416034343698204186575808495617; uint256 public immutable MEMBERSHIP_DEPOSIT; uint256 public immutable DEPTH; uint256 public immutable SET_SIZE; @@ -42,7 +43,7 @@ contract RLN { } function _register(uint256 pubkey) internal { - members[pubkeyIndex] = pubkey; + members[pubkeyIndex] = mod(pubkey,Q); emit MemberRegistered(pubkey, pubkeyIndex); pubkeyIndex += 1; }