NEWTON
Asked
3 months ago
79
views
0
Hey guys, I'm wondering:
So far I know some:
Happy hashing :)
trangnv
asked
3 months ago
1
Accepted answer
I'm no cryptographer, but AFAIK, these are the ones available at this moment. In general, Poseidon and Pedersen are the fastest and most commonly used in ZK applications.
As a rule of thumb, go with implementations made by Starkware or at least vetted by them, after all they are great mathematicians, and who knows Cairo better than them?!
Keccak I believe was implemented for EVM compatibility, as it's the most used one there. Pedersen seems to be the most common one alongside Poseidon for ZK, and well you can never go wrong with SHA256, although seems to be a bit slower to use with ZK.
You should try and implement them all in a Cairo program and see how many steps they use, for instance using Pedersen:
func main{pedersen_ptr: HashBuiltin*}() { let (res) = hash2{hash_ptr=pedersen_ptr}(1, 2); return (); } Number of steps: 11
In terms of security, you want a hash function to have the following properties (taken from here and can read more here):
For instance, MD5 has been proven to have hash collisions as described here.
ctrlc03
answered
3 months ago
0
Thanks for the great detailed answer Lord, So I would assume that all the listed (kekcak, Pederden, Poseidon, sha256) are preimage resistance, second preimage resistance and collision resistance. Pederden and Poseidon seem to be great choices here.
trangnv
answered
3 months ago
why does keccak256 replace sha256 in warp?
How to use Pedersen Hash in StarkNet / Cairo Language?
What libraries are secure to use in Cairo?
I can't find info on what `vm_enter_scope` does within hints in the cairo-lang repo
What Implicit arguments are in Cairo lang?
Cairo Lang / StarkNet: What are Revoked references? What is alloc_locals?
How to modify keccak.cairo and/or packed_keccak.cairo to compute a 512bits keccak hash instead of 256 bits?
Cairo: Unknown value for memory cell at address
How does a full node like pathfinder work
ApeWorX: Why are the cairo and starknet plugins not installing properly?
Can someone explain the difference between unsigned_div_rem and uint256_unsigned_div_rem?
How can I use start_prank with deploy_contract?
How can I use dynamic allocation in Cairo?
Why there is no fee for deploying an account contract (creating account)?