1

How can I approach a smart contract design that would allow me to encrypt inputs from multiple transactions and allow only the smart contract itself to be able to decrypt this data?

Use case example: the smart contract would run an auction where the bidders can't see each other's offers. Then, only once the auction is finished is the winning offer made public.

2 Answers 2

1

This is not possible. Smart contracts cannot know secrets.

But there is another solution for your use case. You need to split the auction into two rounds. In the first round the bidders commit to an offer through a hash of the price (concatenated with a random string). In the second round all bidders disclose their offer (I.e. the concatenated string) and the smart contract can check who is the winner.

1
  • Thanks @Jey. This is what I discovered yesterday but I was still waiting someone to answer here just to make sure that really isn't possible to encrypt data on the script for a certain amount of time. Thanks again.
    – FTM
    Jan 12 at 13:53
1

Remember Cardano is a public ledger, so anyone can read the values that are submitted to contracts.

It is possible to blind the data on a redeemer until after a deadline. You could have each submitted redeemer be hashed against a secret only known to the bidder. Once the deadline is passed, each bidder can choose to reveal their secrets, and thus their bids.

This still has a glaring problems though. The bid needs to also lock the funds for the bid (or else someone could just bid a billion ADA and never claim it). Each bidder would need to include more than their bid amount to be locked up, thus blinding the amount as well as giving some wiggle room for the next bidder. This seems less-than-ideal, since it still leaks information about their bid.

You'd need the bidders to lock their funds when they reveal their bid. This prevents a DoS from insincere bidders. Even then, you need to take into account that people might be incentivized to wait as long as possible to reveal their bids. This could create strange game theory.

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.