1

I am trying to use the hash obtained from keccak256 (applied to a number or input) and using it into sha256packet from ZoKrates (or other function) for comparing it with the Hash obtained in Zokrates for the same input. Is there a way at least for obtaining the same return value of this function from keccak256?

Thanks in advance.

1

I think I solved it.

What you have to do is using the method web3.eth.abi.encodeParameters(VALUES) inside function web3.utils.keccak256.

This means:

web3.utils.keccak256(web3.eth.abi.encodeParameters(YOUR VALUES))

The Hash obtained from this functions is the same as the hash obtained in solidity after applying keccak256(abi.encode(YOUR VALUES))

Therefore, by using this methods we can obtain the same value of hash both in the smart contract using solidity and in the script using web3.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.