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

Provide kecccak256 host function #203

Open
seanyoung opened this issue Sep 2, 2020 · 3 comments
Open

Provide kecccak256 host function #203

seanyoung opened this issue Sep 2, 2020 · 3 comments

Comments

@seanyoung
Copy link

EVM has an keccak instruction, webassembly does not. Because of this, https://github.com/hyperledger-labs/solang has to include a keccak implementation in any contract which does keccak hashing. Keccak hashing is used for mappings and storage arrays.

It would be much better if the EEI provided a keccak host function.

Note that Substrate wasm interface does provide this and another hashing functions too: https://github.com/paritytech/substrate/blob/master/frame/contracts/src/wasm/runtime.rs#L1199

@seanyoung
Copy link
Author

This file is compiled to wasm by clang and linked into every ewasm contract: https://github.com/hyperledger-labs/solang/blob/master/stdlib/sha3.c

@axic
Copy link
Member

axic commented Sep 2, 2020

Please note there is a proposed precompile instead of a host function: https://github.com/ewasm/design/blob/master/system_contracts.md#keccak256

@seanyoung
Copy link
Author

Ah I had missed that, thanks.

A host function is much better, this has much lower gas cost (no call overhead). This would help make ewasm competitive with evm.

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

2 participants