mirror of
https://github.com/vacp2p/rln-contract.git
synced 2025-01-23 04:49:23 +00:00
feat: integrate LazyIMT with getting the merkle proof from the chain
This commit is contained in:
parent
a647a84005
commit
71f310a501
File diff suppressed because one or more lines are too long
@ -29,7 +29,7 @@
|
||||
"prettier:write": "prettier --write **/*.{json,md,yml} --ignore-path=.prettierignore"
|
||||
},
|
||||
"dependencies": {
|
||||
"@zk-kit/imt.sol": "2.0.0-beta",
|
||||
"@zk-kit/imt.sol": "https://gitpkg.now.sh/privacy-scaling-explorations/zk-kit/packages/imt.sol?0699fd1e5ad3683ae0090e0626f75d7834145500",
|
||||
"poseidon-solidity": "^0.0.5"
|
||||
}
|
||||
}
|
||||
|
18
pnpm-lock.yaml
generated
18
pnpm-lock.yaml
generated
@ -6,8 +6,8 @@ settings:
|
||||
|
||||
dependencies:
|
||||
'@zk-kit/imt.sol':
|
||||
specifier: 2.0.0-beta
|
||||
version: 2.0.0-beta
|
||||
specifier: https://gitpkg.now.sh/privacy-scaling-explorations/zk-kit/packages/imt.sol?0699fd1e5ad3683ae0090e0626f75d7834145500
|
||||
version: '@gitpkg.now.sh/privacy-scaling-explorations/zk-kit/packages/imt.sol?0699fd1e5ad3683ae0090e0626f75d7834145500'
|
||||
poseidon-solidity:
|
||||
specifier: ^0.0.5
|
||||
version: 0.0.5
|
||||
@ -49,12 +49,6 @@ packages:
|
||||
antlr4ts: 0.5.0-alpha.4
|
||||
dev: true
|
||||
|
||||
/@zk-kit/imt.sol@2.0.0-beta:
|
||||
resolution: {integrity: sha512-bH7RvI5WHAEswUwPspUY582O2+71xbYv5aL+DM4xkaA0GdMyMLUwf5c1yJ4wrt46hp07iXCXJsLXdtLNsTnvZw==}
|
||||
dependencies:
|
||||
poseidon-solidity: 0.0.5
|
||||
dev: false
|
||||
|
||||
/ajv@6.12.6:
|
||||
resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==}
|
||||
dependencies:
|
||||
@ -468,3 +462,11 @@ packages:
|
||||
/wrappy@1.0.2:
|
||||
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
|
||||
dev: true
|
||||
|
||||
'@gitpkg.now.sh/privacy-scaling-explorations/zk-kit/packages/imt.sol?0699fd1e5ad3683ae0090e0626f75d7834145500':
|
||||
resolution: {tarball: https://gitpkg.now.sh/privacy-scaling-explorations/zk-kit/packages/imt.sol?0699fd1e5ad3683ae0090e0626f75d7834145500}
|
||||
name: imt.sol
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
poseidon-solidity: 0.0.5
|
||||
dev: false
|
||||
|
@ -1,3 +1,3 @@
|
||||
forge-std/=lib/forge-std/src/
|
||||
@zk-kit/imt.sol/=node_modules/@zk-kit/imt.sol/
|
||||
@zk-kit/imt.sol/=node_modules/@zk-kit/imt.sol/contracts
|
||||
poseidon-solidity/=node_modules/poseidon-solidity/
|
@ -80,16 +80,16 @@ if [ "$contract_name" = "rln" ]; then
|
||||
--chain $chain_name \
|
||||
$poseidon_t3_name
|
||||
|
||||
# Get the BinaryIMT contract address from ./broadcast/Deploy.s.sol/$chain_id/run-latest.json
|
||||
binary_imt_name=$(cat ./broadcast/Deploy.s.sol/$chain_id/run-latest.json | jq -r '.["transactions"][1]["contractName"]')
|
||||
binary_imt_address=$(cat ./broadcast/Deploy.s.sol/$chain_id/run-latest.json | jq -r '.["transactions"][1]["contractAddress"]')
|
||||
# Get the LazyIMT contract address from ./broadcast/Deploy.s.sol/$chain_id/run-latest.json
|
||||
lazy_imt_name=$(cat ./broadcast/Deploy.s.sol/$chain_id/run-latest.json | jq -r '.["transactions"][1]["contractName"]')
|
||||
lazy_imt_address=$(cat ./broadcast/Deploy.s.sol/$chain_id/run-latest.json | jq -r '.["transactions"][1]["contractAddress"]')
|
||||
|
||||
echo "Verifying $binary_imt_name library"
|
||||
forge verify-contract $binary_imt_address \
|
||||
echo "Verifying $lazy_imt_name library"
|
||||
forge verify-contract $lazy_imt_address \
|
||||
--libraries "poseidon-solidity/PoseidonT3.sol:$poseidon_t3_name:$poseidon_t3_address" \
|
||||
--watch \
|
||||
--chain $chain_name \
|
||||
$binary_imt_name
|
||||
$lazy_imt_name
|
||||
|
||||
# Get the Verifier contract address from ./broadcast/Deploy.s.sol/$chain_id/run-latest.json
|
||||
verifier_name=$(cat ./broadcast/Deploy.s.sol/$chain_id/run-latest.json | jq -r '.["transactions"][2]["contractName"]')
|
||||
|
@ -3,7 +3,7 @@
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import { IVerifier } from "./IVerifier.sol";
|
||||
import { BinaryIMT, BinaryIMTData } from "@zk-kit/imt.sol/BinaryIMT.sol";
|
||||
import { LazyIMT, LazyIMTData } from "@zk-kit/imt.sol/LazyIMT.sol";
|
||||
|
||||
/// The tree is full
|
||||
error FullTree();
|
||||
@ -84,7 +84,7 @@ abstract contract RlnBase {
|
||||
uint32 public immutable deployedBlockNumber;
|
||||
|
||||
/// @notice the Incremental Merkle Tree
|
||||
BinaryIMTData public imtData;
|
||||
LazyIMTData public imtData;
|
||||
|
||||
/// Emitted when a new member is added to the set
|
||||
/// @param idCommitment The idCommitment of the member
|
||||
@ -107,7 +107,7 @@ abstract contract RlnBase {
|
||||
SET_SIZE = 1 << depth;
|
||||
verifier = IVerifier(_verifier);
|
||||
deployedBlockNumber = uint32(block.number);
|
||||
BinaryIMT.initWithDefaultZeroes(imtData, 20);
|
||||
LazyIMT.init(imtData, 20);
|
||||
}
|
||||
|
||||
/// Allows a user to register as a member
|
||||
@ -130,7 +130,7 @@ abstract contract RlnBase {
|
||||
members[idCommitment] = idCommitmentIndex;
|
||||
indexToCommitment[idCommitmentIndex] = idCommitment;
|
||||
memberExists[idCommitment] = true;
|
||||
BinaryIMT.insert(imtData, idCommitment);
|
||||
LazyIMT.insert(imtData, idCommitment);
|
||||
stakedAmounts[idCommitment] = stake;
|
||||
|
||||
emit MemberRegistered(idCommitment, idCommitmentIndex);
|
||||
@ -237,7 +237,7 @@ abstract contract RlnBase {
|
||||
}
|
||||
|
||||
function root() external view returns (uint256) {
|
||||
return imtData.root;
|
||||
return LazyIMT.root(imtData, 20);
|
||||
}
|
||||
|
||||
function getCommitments(uint256 startIndex, uint256 endIndex) public view returns (uint256[] memory) {
|
||||
@ -250,4 +250,8 @@ abstract contract RlnBase {
|
||||
}
|
||||
return commitments;
|
||||
}
|
||||
|
||||
function merkleProofElements(uint40 index) public view returns (uint256[] memory) {
|
||||
return LazyIMT.merkleProofElements(imtData, index, 20);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user