iavl icon indicating copy to clipboard operation
iavl copied to clipboard

Let the user choose the underlying hash function

Open liamsi opened this issue 5 years ago • 0 comments

It would be cool if iavl would allow the user to choose the underlying hash function used.

While several hash functions are benchmarked internally, https://github.com/cosmos/iavl/blob/4f7cdd76d77f2c23b8098ddb00eb4b2439a0dfa3/benchmarks/hash_test.go#L25-L30 only sha256 is really used and hardcoded in some places, e.g. see: https://github.com/cosmos/iavl/blob/5c3826bff077e511cf4288b681718a62f775dcb4/proof.go#L56-L57 or https://github.com/cosmos/iavl/blob/7cab3597de7d0446fdff3845f2bccd484304e6f7/node.go#L200-L205 https://github.com/cosmos/iavl/blob/a7d2e7bbf6a07ea0240437232781bc2dc2232a22/mutable_tree.go#L470

Ideally, the caller could pass in a hash function to use (for everything), or at least there would be a central place s.t. the hash can easily be changed (like with tendermint's tmhash).

liamsi avatar Nov 08 '20 19:11 liamsi