ewasm-precompiles icon indicating copy to clipboard operation
ewasm-precompiles copied to clipboard

Adapt blake2 precompile to match the EIP

Open axic opened this issue 6 years ago • 5 comments

See https://github.com/ethereum/EIPs/issues/152

axic avatar Dec 22 '18 14:12 axic

Could you explain a bit further what has to be done?

Here is what I understand so far: Current blake2 implementation just reads an input data and calculates the blake2b hash using the blake2 crate. In order to change it to match the EIP the following has to be done:

  • Read input data h (current state)
  • Read input data t (data length)
  • Read input data m (message/data) with length t
  • Read input data f (finalization flag)
  • Read input data r (rounds)

Based on data length t we can calculate if we need to call Blake2b or Blake2s. Then set h (using new_keyed fn, and request the output, but currently the result fn sets 0 as finalization flag.

hugo-dc avatar Jan 29 '19 05:01 hugo-dc

@hugo-dc sorry for the delay. Yes, that is correct, it needs to follow what specification of the EIP. I'm not sure if we can use the current crate - likely not -, because we need direct access to all parameters of blake2.

axic avatar Feb 13 '19 01:02 axic

The current version of the Blake2 precompile is here: https://github.com/ethereum/EIPs/pull/2024

Our code is pretty close to that and would be easy to update.

axic avatar Jun 13 '19 09:06 axic

It seems the now-current proposal is at https://github.com/ethereum/EIPs/pull/2129, which brings us back to a specification similar to https://github.com/ewasm/ewasm-precompiles/issues/36#issuecomment-458416477

axic avatar Jun 24 '19 11:06 axic

The final EIP, which went live 2 days ago with Istanbul, is quite different: https://eips.ethereum.org/EIPS/eip-152

axic avatar Dec 10 '19 12:12 axic