├── webapp ├── .gitignore ├── .env.example ├── package.json ├── index.html ├── vite.config.js ├── json_abi │ └── CommentVerifier.json └── app.js ├── relayer ├── .gitignore ├── .env.example ├── package.json ├── json_abi │ └── CommentVerifier.json ├── relayer.js └── package-lock.json ├── screenshot.png ├── circuit ├── Nargo.toml ├── src │ └── main.nr └── target │ ├── circuit.json │ └── debug_circuit.json ├── contracts └── CommentVerifier.sol └── README.md /webapp/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .env -------------------------------------------------------------------------------- /relayer/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .env -------------------------------------------------------------------------------- /webapp/.env.example: -------------------------------------------------------------------------------- 1 | CHAIN_ID = "534351" 2 | COMMENT_VERIFIER_ADDRESS = "0x123abc" -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Turupawn/EcrecoverInclusionProof/HEAD/screenshot.png -------------------------------------------------------------------------------- /relayer/.env.example: -------------------------------------------------------------------------------- 1 | RPC_URL="https://sepolia-rpc.scroll.io" 2 | COMMENT_VERIFIER_ADDRESS = "0x123abc" 3 | RELAYER_PRIVATE_KEY ="123abc" 4 | RELAYER_ADDRESS = "0x123abv" -------------------------------------------------------------------------------- /circuit/Nargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "circuit" 3 | type = "bin" 4 | authors = [""] 5 | compiler_version = "0.22.0" 6 | 7 | [dependencies] 8 | ecrecover = { tag = "v0.19.0", git = "https://github.com/colinnielsen/ecrecover-noir" } -------------------------------------------------------------------------------- /relayer/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "relayer", 3 | "version": "1.0.0", 4 | "description": "huh", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1", 9 | "start": "node relayer.js" 10 | }, 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "cors": "^2.8.5", 15 | "dotenv": "^10.0.0", 16 | "ethers": "^6.9.0", 17 | "express": "^4.18.2", 18 | "node-fetch": "^3.1.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /webapp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "verification-counter", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "vite --open", 9 | "build": "vite build", 10 | "preview": "vite preview", 11 | "relayer": "node relayer/relayer.js" 12 | }, 13 | "author": "", 14 | "license": "ISC", 15 | "dependencies": { 16 | "@noir-lang/backend_barretenberg": "^0.22.0", 17 | "@noir-lang/noir_js": "^0.22.0", 18 | "dotenv": "^16.3.1", 19 | "@alch/alchemy-web3": "^1.1.7", 20 | "cors": "^2.8.5", 21 | "node-fetch": "^3.1.0" 22 | }, 23 | "devDependencies": { 24 | "rollup-plugin-copy": "^3.5.0", 25 | "vite": "^4.5.0", 26 | "vite-plugin-environment": "^1.1.3" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /circuit/src/main.nr: -------------------------------------------------------------------------------- 1 | use dep::std::ecdsa_secp256k1::verify_signature; 2 | use dep::std; 3 | use dep::std::scalar_mul; 4 | use dep::std::hash; 5 | use dep::ecrecover; 6 | 7 | fn main( 8 | pub_key_x: [u8; 32], 9 | pub_key_y: [u8; 32], 10 | signature: [u8; 64], 11 | hashed_message: pub [u8; 32], 12 | root: pub Field, 13 | index: Field, 14 | hash_path: [Field; 2] 15 | ) { 16 | // First, let's check if signature is vaild and corresponds to the public key provided 17 | let valid_signature = verify_signature(pub_key_x, pub_key_y, signature, hashed_message); 18 | assert(valid_signature); 19 | 20 | // Grab the ethereum address from the public key 21 | let key = ecrecover::secp256k1::PubKey::from_xy(pub_key_x, pub_key_y); 22 | let leaf = key.to_eth_address(); 23 | 24 | // Check if the address is part of the merkle tree 25 | let computedRoot = std::merkle::compute_merkle_root(leaf, index, hash_path); 26 | 27 | assert (root == computedRoot); 28 | } -------------------------------------------------------------------------------- /webapp/index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |