cairo-vm-go
cairo-vm-go copied to clipboard
Poseidon Hash
One of the builtin required by the VM is the Poseidon Hash. It doesn't check when anything is written to it, and only triggers when inferring a value from it.
A Poseidon slot uses 6 cells. The first three are used as inputs (therefore the program should write to it before infering). The last three cells store the result of doing the Poseidon Permutation over the inputs.
The Bitwise and Pedersen Builtins are examples of how to implement the Poseidon Builtin. The general solution flow is:
- Read the input values, error accordingly
- Perform the Poseidon Hash
- Write the three output values
The difficult part of this is executing the math of the Poseidon Hash efficiently