{"id":18420719,"url":"https://github.com/maximedgr/zk-xrpl-evm-workshop","last_synced_at":"2025-08-12T18:41:54.771Z","repository":{"id":253164466,"uuid":"842287534","full_name":"maximedgr/zk-xrpl-evm-workshop","owner":"maximedgr","description":"With just two lines of code, it is possible to easily generate and verify a ZK proof on the XRPL EVM Sidechain using hardhat-circom plugin !✨","archived":false,"fork":false,"pushed_at":"2024-08-30T03:01:49.000Z","size":2531,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T08:23:10.612Z","etag":null,"topics":["blockchain","circom","circuit","evm","hardhat","snarkjs","xrpl","zk","zk-snarks"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maximedgr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-14T03:40:18.000Z","updated_at":"2025-03-09T09:22:35.000Z","dependencies_parsed_at":"2024-08-14T22:32:23.498Z","dependency_job_id":"47ef4942-dd3c-45ce-a59a-604f1b2da470","html_url":"https://github.com/maximedgr/zk-xrpl-evm-workshop","commit_stats":null,"previous_names":["maximedgr/zk-xrpl-evm-workshop"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximedgr%2Fzk-xrpl-evm-workshop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximedgr%2Fzk-xrpl-evm-workshop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximedgr%2Fzk-xrpl-evm-workshop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximedgr%2Fzk-xrpl-evm-workshop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maximedgr","download_url":"https://codeload.github.com/maximedgr/zk-xrpl-evm-workshop/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248952350,"owners_count":21188426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","circom","circuit","evm","hardhat","snarkjs","xrpl","zk","zk-snarks"],"created_at":"2024-11-06T04:22:50.407Z","updated_at":"2025-04-14T20:10:32.941Z","avatar_url":"https://github.com/maximedgr.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Play with ZK on the XRPL EVM Sidechain ✨\n\nWith just two lines of code, it is possible to easily generate and verify a ZK proof on the XRPL EVM Sidechain!✨    \n\nIn this example, we will generate a zk proof (SNARK) and verify it on-chain on the XRPL EVM Sidechain using a Circom circuit representing the multiplication of two integers `a` and `b` such as `a x b = c`.  \nWe want to prove to the verifier that for a given result c, we know the integers a and b without revealing them.  \nThis tutorial uses [hardhat-circom](https://github.com/projectsophon/hardhat-circom), a Hardhat plugin integrating [Circom](https://github.com/iden3/circom) and [SnarkJS](https://github.com/iden3/snarkjs) into Hardhat's build process.  \n\n### Install\n`npm i`\n\n### Configure\n1. Add and populate `.env` with `DEV_PRIVATE_KEY=your_DEV_priv_key`.\n2. Fund your account with XRP on Devnet using this faucet: https://bridge.xrplevm.org/.\n3. You can configure `hardhat.config.ts` and `circuits.config.json` as you like.\n\n## Powers of Tau\n\nYou must provide a Powers of Tau from a Phase 1 ceremony. We recommend using one of the `.ptau` files from the Hermez Protocol's ceremony, available from [their Dropbox folder](https://www.dropbox.com/sh/mn47gnepqu88mzl/AACaJkBU7mmCq8uU8ml0-0fma?dl=0).  \n\nThese are all named `powersOfTau28_hez_final_*.ptau` where the `*` is some number. This number indicates the number of constraints (`2^x`) that can exist in your circuits.  \n\nNb: I have already included in the repository, within the circuit folder, a .ptau file for a constraint count of up to (2^15).  \n\n\n### Circuits and Proof\n\nCircuits are located within the `circuits` folder. Each circuit will have its own sub-folder with the actual `.circom` file, which represents the circuit, and an `input.json` file containing the circuit's inputs (what you want to prove).\n\n### Compile\nRun: `npx hardhat circom --verbose`  \nThis will generate the **out** folder with `multiplier.zkey`, `multiplier.vkey`, `multiplier.r1cs`, and `circuit.wasm`, as well as the Solidity verifier `MultiplierVerifier.sol` under the `contracts` folder.\n\n### Deploy Contract - Generate and Verify proof\n\nRun: `npx hardhat run scripts/deploy_generate_verify.ts --network XRPL_EVM_Sidechain_Devnet`  \nThis script does four things:  \n1. Deploys the `MultiplierVerifier.sol` contract.\n2. Generates a proof from circuit intermediaries with `generateProof()` in `generate.ts`.\n3. Generates calldata with `generateCallData()` in `generate.ts`.\n\nAfter generating your proof, you will see a `proof.json` file in the circuit's **out** folder. This is actually the proof and contains an attribute `publicSignals`. For example, if you are proving that you know two numbers `a` and `b` such that `a * b = c`, the value `c` might be part of `publicSignals`, while `a` and `b` remain private. The verifier checks that the proof is valid for the given `c` without knowing `a` and `b`.\n\n### Commands\n\nHere are some commands to generate new proofs and verify them once your circuit is generated and the verifier is deployed.  \n\n1. Generate a New Proof:\nDescription: Generates a new proof and saves it to the proof.json file.  \nAssociated Script: `scripts/generate.ts`  \n*Note*: Modify the value of `BASE_PATH` according to the circuit you want to use.  \nRun:`npx hardhat run scripts/generate.ts --network XRPL_EVM_Sidechain_Devnet`  \n\n2. Verify an Existing Proof:\nDescription: Verify an existing proof by interacting with the deployed contract.  \nAssociated Script: `scripts/verify.ts`  \n*Note*: Modify the value of `BASE_PATH` according to the circuit you want to use, and update the value of `VERIFIER_CONTRACT_ADDRESS` with the address of your deployed contract on-chain.  \nCommand:`npx hardhat run scripts/verify.ts --network XRPL_EVM_Sidechain_Devnet`  \n\n### Play arround\n\n- Try modifying the inputs and generating a new proof, then verify it with the same verifier. What happens?\n*Expected Outcome*: The proof remains valid and the verifier accepts it because the circuit is the same!\n\n- Try modifying your proof in the proof.json file by changing the value of publicSignals, and then verify it. What happens?\n*Expected Outcome*: The proof is no longer valid! The new value of publicSignals, which represents the public statement, does not satisfy the relation defined in your circuit.\n\n### Verify the Contract\n\n1. Run `npx hardhat flatten contracts/MultiplierVerifier.sol \u003e Flattened.sol`.\n2. Go to https://explorer.xrplevm.org/ and verify your deployed contract using `Flattened.sol`.\n\n### Documentation\n\n- XRPL EVM Sidechain documentation: https://opensource.ripple.com/docs/evm-sidechain/intro-to-evm-sidechain/\n- SnarkJS: https://github.com/iden3/snarkjs\n- Based on tutorials from https://github.com/projectsophon/hardhat-circom \u0026 https://github.com/gmchad/zardkat.\n\n\n### Troubleshooting\n\nYou may encounter errors during deployment *(solidity compiler version: * contracts/MultiplierVerifier.sol (^0.6.11))* of the contract related to the automatically generated verifier contract. Simply modify the Solidity version in the contract file to match the one specified in your Hardhat configuration file.\n\n## More XRPL EVM Sidechain Tutorials\n\n| Repo                | Link                                                    |\n|---------------------|---------------------------------------------------------|\n| Deploy your first Solidity contract on the XRPL EVM Sidechain using Hardhat 👷 | [GitHub Repository](https://github.com/maximedgr/xrpl-evm-quickstart-hardhat) |\n| Next.js x Rainbowkit Wallet configured for the XRPL EVM Sidechain 🌈 | [GitHub Repository](https://github.com/maximedgr/xrpl-evm-quickstart-rainbowkit) |\n\n### Additional Resources\n|Resources|Link|\n|---|---|\n|Docs|https://docs.xrplevm.org/docs/evm-sidechain/intro-to-evm-sidechain/|\n|Bridge \u0026 Faucet|https://bridge.xrplevm.org/|\n|MetaMask|https://metamask.io/|\n|Solidity|https://docs.soliditylang.org/en/v0.8.26/|\n|Hardhat|https://hardhat.org/|\n|Remix IDE|https://remix.ethereum.org/|\n|Grants|https://xrplgrants.org/|\n|Accelerator|https://xrplaccelerator.org/|\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximedgr%2Fzk-xrpl-evm-workshop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaximedgr%2Fzk-xrpl-evm-workshop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximedgr%2Fzk-xrpl-evm-workshop/lists"}