0

I was wondering that can I encrypt a string, send it to a smart contract, for that to be decrypted only by some address's private key?

e.g "Hello" to be encrypted in a way that it would be decrypted only by the owner of 0x00000000000000000 who has its private key.

EDIT

Notice: I don't have the private key of 0x00000000000000000

1

1 Answer 1

1

You can encrypt a message and store in your smart contract.

But to decrypt it, the only thing you can do is to make a call() to get encrypted data from the caller. It's a special function that will only read something on the smart contract.

You can't make a transaction with the private key as an argument but it will be FORBIDDEN because anyone would see the private key on the network and you will be hacked within secondes.

I don't see the point to store an encrypted message on the blockchain. But what you can do is using EIP712.

In our project (CryptoPuzzle.com) for token n°139 own by 0xDB59, I (address 0x28B9) made a bid to buy this token. The bid is a signed message like this :

{
expiry: 1625503749
maker: "0x28b9dd12fa0dd64fdf3f7e02a02ab87c4167342c"
makerIds: Array []
makerWei: "10000000000000000"
taker: "0x0000000000000000000000000000000000000000"
takerIds: Array [ 139 ]
takerWei: 0
sig: "0xfad5d54022f1a9d89ad0543b31dce38866e79e36cd40022ed626117ecf75d62e3e4f55d0c53f9b7a87c7acb9f8399743a9041f562e581e30a58da52dde9d8bf21b"
​​}

The important part is "sig" because it's EIP712 compatible so I can know that address 0x28b9 want to pay 10000000000000000 wei (0.01ETH) for token [ 139 ]. Please look at EIP712 to understand it.

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.