Is there an encryption library on EOS that we can use? For example, how can I encrypt a single string "hello". And I have checked the API documentation https://eosio.github.io/eosio.cdt/1.4.0/group__cryptoapi.html but still don't really understand how it works
- Phil Li @phil
The crypto api is used to hash a string, which is a one-way map that is hard to reverse.
Encryption/decryption also require a secret key for recovering input from the encrypted data. However, since everything on blockchain is open to the public including your smart contract's binary code, you cannot write the secret key in your contract code or allow users to fill it as an action parameter. So how do you want to use the encryption?
- O@OceanicSix
Oh, I see. So can I understand it in this way: It is useless to perform encryption on blockchain as both the code and user's parameter are public. The way to perform encryption is to do it off-chain and upload ciphertext to blockchain, then another user decrypt the ciphertext off-chain.
Phil Li @phil
Yes exactly. For example, you can use a centralized server for encryption/decryption aside from the blockchain.