0

I want to store some hashed data in my contract. Which is better, hashing on the backend(contract) or the frontend. Also, is there any security consideration to look at when doing this? Thank you.

1

Hash it in the front end, only store the generated hash in the blockchain. Its more secure & costs less gas.

0

It's a hashing function so in theory it can't be reversed. Therefore the possible security concerns are:

1) Someone guessing the inputs by trying to generate the same hash output

2) Someone using the same hash string for other possible malicious uses

If you generate it in the smart contract everyone can see the input values. So it depends on your needs which approach you should take.

2
  • Thank you for your reply. Aside from miners, how is it possible for everyone to see the input values if modifiers are used to limit access. Feb 10 '20 at 7:50
  • All data is public if you know how to interpret it. Visibility settings (private) basically just make it impossible for other contracts to directly see the value - it doesn't prevent for external system from seeing the data. So two options: 1) Analyze transactions to see what modifications have been made to the values (rather complicated) 2) Look into the contract state. Feb 10 '20 at 7:55

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.