<p>This is not possible. Smart contracts cannot know secrets.</p>
<p>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.</p>

CC BY-SA 4.0
2022-01-12T13:53:59.517Z
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
CC BY-SA 4.0
2022-01-11T22:51:05.243Z
2022-01-11T22:51:05.243Z
Jey
<p>Remember Cardano is a public ledger, so anyone can read the values that are submitted to contracts.</p>
<p>It is possible to <em>blind</em> 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.</p>
<p><strike>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.</strike></p>
<p>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.</p>

CC BY-SA 4.0
2022-01-11T22:46:28.997Z
2022-01-12T17:51:55.020Z
2022-01-12T17:51:55.020Z
Mitchell Turner
<p>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?</p>
<p>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.</p>

<plutus><smart-contract>
How to make certain script inputs available only to the script iself?
# How to make certain script inputs available only to the script iself?

(Asked by: username_0 on 2022-01-11)

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.

**Tags:** plutus, smart-contract

---

## 2 answers

### Answer by username_1 on 2022-01-11. Score: 1 | Accepted answer

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.

> **Comments:**
> **username_0**: 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.  

---

### Answer by username_2 on 2022-01-11. Score: 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.


---

