Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let the user choose the underlying hash function #327

Open
liamsi opened this issue Nov 8, 2020 · 0 comments
Open

Let the user choose the underlying hash function #327

liamsi opened this issue Nov 8, 2020 · 0 comments

Comments

@liamsi
Copy link
Contributor

liamsi commented Nov 8, 2020

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

While several hash functions are benchmarked internally,

{"ripemd160", 64, crypto.RIPEMD160.New()},
{"ripemd160", 512, crypto.RIPEMD160.New()},
{"sha2-256", 64, crypto.SHA256.New()},
{"sha2-256", 512, crypto.SHA256.New()},
{"sha3-256", 64, crypto.SHA3_256.New()},
{"sha3-256", 512, crypto.SHA3_256.New()},

only sha256 is really used and hardcoded in some places, e.g. see:

iavl/proof.go

Lines 56 to 57 in 5c3826b

func (pin ProofInnerNode) Hash(childHash []byte) []byte {
hasher := sha256.New()

or

iavl/node.go

Lines 200 to 205 in 7cab359

func (node *Node) _hash() []byte {
if node.hash != nil {
return node.hash
}
h := sha256.New()

existingHash = sha256.New().Sum(nil)

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants