{"id":15926442,"url":"https://github.com/zemse/poseidon2-evm","last_synced_at":"2026-03-01T09:34:34.768Z","repository":{"id":231851160,"uuid":"782865850","full_name":"zemse/poseidon2-evm","owner":"zemse","description":"Gas efficient Poseidon2 hash on EVM","archived":false,"fork":false,"pushed_at":"2026-02-14T09:05:40.000Z","size":213,"stargazers_count":23,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-14T22:57:59.608Z","etag":null,"topics":["evm","huff","poseidon2","solidity","yul"],"latest_commit_sha":null,"homepage":"","language":"Solidity","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/zemse.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-04-06T09:04:22.000Z","updated_at":"2026-02-14T09:05:44.000Z","dependencies_parsed_at":"2024-04-06T10:22:08.778Z","dependency_job_id":"5cbaba6f-215b-4365-be4c-fc3ef7011837","html_url":"https://github.com/zemse/poseidon2-evm","commit_stats":null,"previous_names":["zemse/poseidon2","zemse/poseidon2-evm"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/zemse/poseidon2-evm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zemse%2Fposeidon2-evm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zemse%2Fposeidon2-evm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zemse%2Fposeidon2-evm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zemse%2Fposeidon2-evm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zemse","download_url":"https://codeload.github.com/zemse/poseidon2-evm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zemse%2Fposeidon2-evm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29965680,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T09:33:09.965Z","status":"ssl_error","status_checked_at":"2026-03-01T09:25:48.915Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["evm","huff","poseidon2","solidity","yul"],"created_at":"2024-10-06T22:40:47.033Z","updated_at":"2026-03-01T09:34:34.754Z","avatar_url":"https://github.com/zemse.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Poseidon2 for EVM\n\nGas-optimized implementations of the [Poseidon2 hash function](https://eprint.iacr.org/2023/323.pdf) for the EVM.\n\n## Implementation Details\n\nSee impl-specific documentation:\n\n- [BN254 (t=4, Rf=8, Rp=56)](src/bn254/README.md)\n\n\u003e Goldilocks support is planned.\n\n## Gas Costs\n\n| Implementation | hash_1 | hash_2 | hash_3 |\n| -------------- | ------ | ------ | ------ |\n| Yul            | 20,304 | 20,304 | 20,304 |\n| Huff           | 14,845 | 14,845 | 14,845 |\n\nIt is recommended to use Yul implementation. Huff is experimental. Pure solidity impl is still kept in this repository for reference, but it costs 200k+ gas.\n\n## Deployed Contracts\n\nContracts are deployed with same address on popular EVM testnets.\n\n### BN254 (t=4, Rf=8, Rp=56)\n\nBoth contracts have same interface [IPoseidon2](./src/IPoseidon2.sol).\n\n| Implementation | Address                                    |\n| -------------- | ------------------------------------------ |\n| Yul            | 0xB25415b1512b1f179978b3028645Dbd6E1AaE20e |\n| Huff           | 0xB2541a90d8c72C6CfD85bC4E9e85B1595CAc00ff |\n\n_If you need help deploying the contract on new network, feel free to msg [@zemse](https://t.me/zemse)._\n\n## Usage example\n\n### Recommended: Helper Library\n\n1. Install the dependency.\n\n```bash\n# Foundry\nforge install zemse/poseidon2-evm\n\n# npm\nnpm install poseidon2-evm\n```\n\n2. Import the file\n\n```solidity\nimport {Poseidon2} from \"poseidon2-evm/src/bn254/Poseidon2.sol\";\n\ncontract MyContract {\n    function myFunction() external {\n        uint left;\n        uint right;\n\n        // Calls the globally deployed Yul contract\n        // Checks that left and right are valid field elements\n        uint result = Poseidon2.hash_2(left, right);\n    }\n\n    function myFunction2() external pure returns (uint256) {\n        uint left;\n        uint right;\n\n        // Explicitly use experimental Huff contract lowest gas\n        // Does not check if left and right are invalid field elements, this\n        // results incorrect hash value.\n        uint result = Poseidon2.hash_2_huff_unchecked(secret, nullifier);\n    }\n}\n```\n\n### Advanced: Direct Interface\n\nCopy the interface into your project [IPoseidon2.sol](./src/IPoseidon2.sol) and use it.\n\n```solidity\ninterface IPoseidon2 {\n    function hash_2(uint256 x, uint256 y) external pure returns (uint256);\n}\n\ncontract MyContract {\n    function someFunction() external {\n        // yul contract is deployed on most testnets\n        address poseidon2addy = 0xB25415b1512b1f179978b3028645Dbd6E1AaE20e;\n\n        uint left;\n        uint right;\n\n        // Makes direct call to the contract. But you need to make sure inputs i.e.\n        // left \u0026 right are valid field elements (\u003c PRIME).\n        uint result = IPoseidon2(poseidon2addy).hash_2(left, right);\n    }\n}\n```\n\n## Development\n\n- Run tests: forge test\n- Generate gas report: ./gas-report.sh\n- Generate yul code: npm run generate:yul\n- Generare huff code: npm run generate:huff\n\nTests include correctness vectors, fuzz testing against the reference Solidity implementation, and overflow safety checks for the ADDMOD optimization.\n\n## Security\n\n**Not yet audited.** These implementations have not undergone a formal third-party security audit. Review the code before using in production. Also see [SECURITY.md](./SECURITY.md).\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzemse%2Fposeidon2-evm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzemse%2Fposeidon2-evm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzemse%2Fposeidon2-evm/lists"}