refactor(poseidon): use correct constants in poseidon, i.e. hardcode Bn254(2,8,56)

This commit is contained in:
s1fr0 2022-10-04 01:09:33 +02:00
parent 40304d3567
commit c30913520f
No known key found for this signature in database
GPG Key ID: 2C041D60117BFF46
3 changed files with 856 additions and 492 deletions

File diff suppressed because it is too large Load Diff

View File

@ -79,20 +79,26 @@ contract RLN {
require(receiver != address(0), "RLN, _withdraw: empty receiver address");
// derive public key
uint256 pubkey = hash([secret, 0]);
uint256 pubkey = _hash(secret);
require(members[_pubkeyIndex] == pubkey, "RLN, _withdraw: not verified");
// delete member
members[_pubkeyIndex] = 0;
// refund deposit
(bool sent, _) = receiver.call{value: MEMBERSHIP_DEPOSIT}("");
(bool sent, bytes memory data) = receiver.call{value: MEMBERSHIP_DEPOSIT}("");
require(sent, "transfer failed");
emit MemberWithdrawn(pubkey, _pubkeyIndex);
}
function hash(uint256[2] memory input) internal view returns (uint256) {
function hash(
uint256 value
) external returns (uint256) {
return poseidonHasher.hash(value);
}
function _hash(uint256 input) internal view returns (uint256) {
return poseidonHasher.hash(input);
}
}

0
test/poseidon.ts Normal file
View File