Poseidon hash function deployment on EVM chains at 0x7eaE9c24323C8101C9B798319a4131d71B5af7fF and libraries to interact with it.
| Feature | Supported |
|---|---|
| ZK friendly | ✅ |
| Iden3 implementation | ✅ |
| Circom compatible | ✅ |
| Create X deployment | ✅ |
| NPM library | WIP |
| Mutiple parameters | WIP |
Poseidon is a very popular hashing function in the Ethereum ecosystem, particularly in privacy-preserving applications. It offers significant advantages by reducing zk-SNARK circuit complexity, size and proof generation time. This library provides an easy-to-use interface, enabling developers to implement Poseidon easly in their projects.
Call the poseidon hash function from your contract by using an interface.
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
import {IPoseidon, PoseidonLib} from "https://github.com/Turupawn/poseidon-addresses/blob/master/src/Poseidon.sol";
contract MyContract {
function hash(uint a, uint b) public view returns(uint) {
return IPoseidon(PoseidonLib.getAddress()).poseidon([a, b]);
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
interface IPoseidon {
function poseidon(uint[2] memory inputs) external view returns(uint output);
}[
{
"inputs": [
{
"internalType": "uint256[2]",
"name": "inputs",
"type": "uint256[2]"
}
],
"name": "poseidon",
"outputs": [
{
"internalType": "uint256",
"name": "output",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
]Poseidon hash should be compatible with any EVM chain full compatible with Ethereum. In case you need us to deploy it in a new chain please submit an issue.
Alternatively, you can deploy the it yourself by running the deploy script. To do so first, clone the repo and install the dependencies.
git clone https://github.com/Turupawn/poseidon-deploy.git
cd poseidon-deploy
git submodule update --init
npm installThen, edit the .env file and run the deploy script. Notice you will need CreateX to be deployed on the destination chain.
node scripts/deploy.mjsThe contract address will be printed on the terminal.