mirror of
https://github.com/vacp2p/rln-contract.git
synced 2025-02-15 16:07:08 +00:00
refactor(poseidon): use correct constants in poseidon, i.e. hardcode Bn254(2,8,56)
This commit is contained in:
parent
40304d3567
commit
c30913520f
File diff suppressed because it is too large
Load Diff
@ -79,20 +79,26 @@ contract RLN {
|
|||||||
require(receiver != address(0), "RLN, _withdraw: empty receiver address");
|
require(receiver != address(0), "RLN, _withdraw: empty receiver address");
|
||||||
|
|
||||||
// derive public key
|
// derive public key
|
||||||
uint256 pubkey = hash([secret, 0]);
|
uint256 pubkey = _hash(secret);
|
||||||
require(members[_pubkeyIndex] == pubkey, "RLN, _withdraw: not verified");
|
require(members[_pubkeyIndex] == pubkey, "RLN, _withdraw: not verified");
|
||||||
|
|
||||||
// delete member
|
// delete member
|
||||||
members[_pubkeyIndex] = 0;
|
members[_pubkeyIndex] = 0;
|
||||||
|
|
||||||
// refund deposit
|
// refund deposit
|
||||||
(bool sent, _) = receiver.call{value: MEMBERSHIP_DEPOSIT}("");
|
(bool sent, bytes memory data) = receiver.call{value: MEMBERSHIP_DEPOSIT}("");
|
||||||
require(sent, "transfer failed");
|
require(sent, "transfer failed");
|
||||||
|
|
||||||
emit MemberWithdrawn(pubkey, _pubkeyIndex);
|
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);
|
return poseidonHasher.hash(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
0
test/poseidon.ts
Normal file
0
test/poseidon.ts
Normal file
Loading…
x
Reference in New Issue
Block a user