AztecProtocol / aztec-packages

Apache License 2.0
158 stars 160 forks source link

Add separator to poseidon hash #5714

Closed benesjan closed 2 months ago

benesjan commented 3 months ago

Look for TODO(#5714) in the codebase.

benesjan commented 2 months ago

Closing this as there is not really a notion of "separator" the same way it is in pedersen so having a separate param for it is not necessary. Here is Mike's comment for context:

So Poseidon hashes don't need generators and generator indices in the same way that pedersen does. With pedersen, to compute pedersen_hash(val1, val2, val3), we do val1G1 + val2G2 + val3*G3. The generator indices that we defined via enums were then used to derive the generator points G1, G2, G3. (Very roughly speaking). So domain separation with pedersen was quite clever: we could derive a different set of points H1,H2,H3 if we wanted to hash three values under different circumstances. With poseidon, there aren't generator points, so we have to explicitly domain-separate by passing a domain separator to the hash. So poseidon(val1, val2, val3) isn't domain separated. We'd need to do poseidon(my_domain_separator, val1, val2, val3). In the specs & diagrams, I've proposed that we write strings for domain separators, and convert each string to a field. E.g. poseidon("az_nullifier".to_field, val1, val2, val3). That's just an example. I'm a bit more explicit in the spec as to what the domain separator strings could be.