0

I am trying to build a Dapp for healthcare where I must be able to allow patients(users) to enter their details after creating (say an account) by a password and next time they are able to view their data by entering the password they created.

2
  • I think you need to go into more detail what you are trying to do. Do you want to store the password on chain? Do you want to use the password offchain to encrypt the onchain data of the patients?
    – user11075
    Commented Dec 6, 2017 at 9:14
  • Yes, I want to encrypt the password a user provides while registering and save it on chain. Next time when the user login with the password, it should check with the encrypted value and provide access if both mathes Commented Dec 7, 2017 at 7:05

2 Answers 2

0

All data on the Blockchain is public. So you can not use the Blockchain to store and verify passwords, and you can not hide information on the Blockchain behind a password.

At best, you would need to encrypt the data offchain and you can store the encrypted data on the Blockchain.

You could assign a unique identifier for each user so that it points the their data, such as an address mapping(address => EncryptedPatientDataStruct).

After doing something like this to retrieve the user’s encrypted data, the data would have to be decrypted offchain.

0

After Noushads comment about him wanting to store the password on the chain:

If you want to store a password hash on the blockchain and grant access to your Dapp only if the user can correctly enter a password that produces a matching hash, it might work - but I am not seeing how you are benefiting from storing the password on the blockchain. There is no reason to store it in a publicly accessible database, if you are just using it for authentication against your frontend application.

If you want to use the password to encrypt data on the chain, and only allow decryption in the dapp if the user knows the right password, this would be a way to make the public data inaccessible to third parties. Please remember that nothing prevents third parties from loading the encrypted data from the chain and trying to bruteforce them, locally.

1
  • I now understand that storing and retrieving password on chain is a bad idea. Can you please explain more how I can do it off chain may be by any solidity code example. Commented Dec 11, 2017 at 4:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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