Skip to content

Commit ecfcc4e

Browse files
committed
Update workshop steps
1 parent 9587dd5 commit ecfcc4e

File tree

6 files changed

+30
-14171
lines changed

6 files changed

+30
-14171
lines changed

.moon/toolchain.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
node:
2-
version: 22.3.0
2+
version: 22.11.0
33
packageManager: 'npm'

STEP_BY_STEP_GUIDE.md

+28-21
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This approach offers a technique for implementing privacy-preserving auctions in
2727

2828

2929

30-
### Step 1: Docker Services Overview
30+
### Step 1: Docker services overview
3131

3232
The following services are defined within the `docker-compose.yml` file:
3333

@@ -65,7 +65,7 @@ Let's open an interactive bash shell or terminal window in the container named `
6565
docker exec -it bls-bn254-js-container bash
6666
```
6767

68-
### Step 2: Encrypt Bids for Sealed-Bid Auction
68+
### Step 2: Encrypt bids for sealed-bid auction
6969

7070
1. **Encrypt the bid amount for Bidder A (0.3 ETH)**:
7171
```bash
@@ -81,7 +81,7 @@ docker exec -it bls-bn254-js-container bash
8181
```
8282
- This generates the ciphertext for Bidder B's bid amount of 0.4 ether, making Bidder B the highest bidder. Please make note of it.
8383

84-
### Step 3: Submit Sealed Bids to the Auction Contract
84+
### Step 3: Submit sealed bids to the auction contract with bidders as signers
8585

8686
1. **Bidder A submits sealed bid (0.3 ETH)**:
8787
```bash
@@ -126,9 +126,9 @@ cast wallet address --private-key 0xe46f7a0c8e6110e8386242cad3491bd38fb794a28dfa
126126
```
127127

128128

129-
### Step 4: Verify Submitted Sealed Bids
129+
### Step 4: Verify submitted sealed bids
130130

131-
1. **View Sealed Bids**:
131+
1. **View sealed bids**:
132132
- For **Bidder A** with bidID 1:
133133
```bash
134134
cast call 0xa945472E43646254913578f0dc0adb0c73a5F584 "getBidWithBidID(uint256)" 1 --rpc-url $RPC_URL
@@ -151,7 +151,7 @@ cast wallet address --private-key 0xe46f7a0c8e6110e8386242cad3491bd38fb794a28dfa
151151
cast call 0xa945472E43646254913578f0dc0adb0c73a5F584 "getBidWithBidID(uint256)" 2 --rpc-url $RPC_URL
152152
```
153153

154-
### Step 5: Skip to Auction End Block
154+
### Step 5: Skip to blocks to end the auction
155155

156156
As per the above outputs, the smart contract has not received any decryption keys for the sealed bids. This is because the bids were encrypted with the auction ending block number which is `56` as in Step 3 and this block number has not reached or been mined on the local Anvil blockchain. Therefore, without the decryption keys, none of the bids can be unsealed by the auctioneer.
157157

@@ -167,18 +167,19 @@ As per the above outputs, the smart contract has not received any decryption key
167167
npm run skip:to-block 57 $RPC_URL
168168
```
169169

170-
3. **Verify Fulfilled Timelock Requests**:
170+
3. **Verify fulfilled timelock requests**:
171171
When we check the logs for the timelock service from the project root folder:
172172
```bash
173173
docker compose logs blocklock
174174
```
175175
we should see a new transaction being sent at block `58` in the Anvil blockchain logs as well as the following logs in the timelock agent console showing that the timelock encryption agent has now signed the Ciphertexts from the two earlier sealed bid events and sent the decryption key to the `SignatureSender` smart contract which forwards the signature to the `SimpleAuction` smart contract via the `BlocklockSender` contract:
176176
```
177+
creating a timelock signature for block 56
177178
fulfilling signature request 1
178179
fulfilled signature request
179180
```
180181

181-
### Step 6: End the Auction
182+
### Step 6: End the auction
182183

183184
1. Use the auction smart contract deployer (auctioneer) private key to end the auction:
184185
```bash
@@ -187,9 +188,9 @@ we should see a new transaction being sent at block `58` in the Anvil blockchain
187188
--rpc-url $RPC_URL
188189
```
189190

190-
### Step 7: Reveal Bids and Verify Data
191+
### Step 7: Reveal bids and verify data
191192

192-
1. **View Bid Data and Get Decryption Key**:
193+
1. **View bid data and retrieve decryption key**:
193194
- Retrieve and decode data for Bidder A to view the `decryptionKey` and check the `revealed` status and `unsealedAmount`:
194195
```bash
195196
cast call 0xa945472E43646254913578f0dc0adb0c73a5F584 "getBidWithBidID(uint256)" 1 --rpc-url $RPC_URL
@@ -199,6 +200,7 @@ we should see a new transaction being sent at block `58` in the Anvil blockchain
199200
```
200201
cast abi-decode "getBidWithBidID(uint256)(bytes,bytes,uint256,address,bool)" <place output from command above here>
201202
```
203+
202204
This should return five outputs on separate lines. These are:
203205
* `bytes sealedAmount` - the ciphertext representing the (timelock encrypted) sealed bid.
204206
* `bytes decryptionKey` - the decryption key used to decrypt the sealedAmount.
@@ -208,7 +210,7 @@ we should see a new transaction being sent at block `58` in the Anvil blockchain
208210
209211
We can now see that the decryptionKey has been sent to the auction smart contract after the auction end block number was identified by the timelock agent. The decryptionKey is no longer an empty byte string `0x`. Using the ciphertext and decryption key from the output above, we can decrypt the sealed bid to reveal the bid amount and confirm that the amount is the same as the amounts we encrypted to ciphertexts earlier for each bidder - Bidder A and Bidder B.
210212
211-
2. **Decrypt Bid Amounts Using Decryption Keys (Signature over Ciphertext)**:
213+
2. **Decrypt bid amounts with decryption keys (i.e., signature over the Ciphertext)**:
212214
```bash
213215
npm run timelock:decrypt -- --ciphertext <replace with ciphertext from decoded output> --signature <replace with signature or decryption key from decoded output>
214216
```
@@ -235,35 +237,35 @@ we should see a new transaction being sent at block `58` in the Anvil blockchain
235237

236238
We can repeat the same steps for Bidder B's sealed bid.
237239

238-
3. **Convert Decrypted Value from Wei to Ether**:
240+
3. **Convert decrypted value from Wei to Ether**:
239241
If we convert the decrypted value from wei to ether, we should get 0.3 ether which we encrypted as wei earlier for Bidder A in Step 4.
240242
```bash
241243
cast from-wei 300000000000000000
242244
```
243245
We can repeat the decryption steps for Bidder B and confirm the decrypted amount.
244246

245-
4. **Reveal Bid Amounts on-chain with Auctioneer Key**:
246-
Now the auctioneer can reveal the bid amounts in the smart contract and with the decryption keys, anyone can verify the revealed amounts are correct with the decryption keys which have only been made available after the auction ending block number.
247+
4. **Reveal bid amounts on-chain with auctioneer as transaction signer**:
248+
Now the auctioneer can reveal the bid amounts in the smart contract and with the decryption keys, and anyone can verify that the revealed amounts are correct with the decryption keys which are now on-chain and have only been made available to the auction smart contract after the auction ending block number.
247249

248250
Reveal bid amounts -
249251
- For **Bidder A**:
250252
```bash
251253
cast send 0xa945472E43646254913578f0dc0adb0c73a5F584 "revealBid(uint256,uint256)" \
252254
1 \
253255
300000000000000000 \
254-
--private-key 0xecc372f7755258d11d6ecce8955e9185f770cc6d9cff145cca753886e1ca9e46 \
256+
--private-key 0xecc372f7755258d11d6ecce8955e9185f770cc6d9cff145cca753886e1ca9e46 \
255257
--rpc-url $RPC_URL
256258
```
257259
- For **Bidder B**:
258260
```bash
259261
cast send 0xa945472E43646254913578f0dc0adb0c73a5F584 "revealBid(uint256,uint256)" \
260262
2 \
261263
400000000000000000 \
262-
--private-key 0xecc372f7755258d11d6ecce8955e9185f770cc6d9cff145cca753886e1ca9e46 \
264+
--private-key 0xecc372f7755258d11d6ecce8955e9185f770cc6d9cff145cca753886e1ca9e46 \
263265
--rpc-url $RPC_URL
264266
```
265267

266-
5. **View Revealed Bid Data**:
268+
5. **View revealed bid data**:
267269
- Retrieve and decode data for Bidder A to confirm `revealed` status and `unsealedAmount`:
268270
```bash
269271
cast call 0xa945472E43646254913578f0dc0adb0c73a5F584 "getBidWithBidID(uint256)" 1 --rpc-url $RPC_URL
@@ -282,7 +284,7 @@ we should see a new transaction being sent at block `58` in the Anvil blockchain
282284
283285
We can now see that the `unsealedAmount` is the amount in Wei that was encrypted in Step 4 and the `revealed` flag in the bid data has now been set to `true` for both bidders.
284286
285-
6. **View Highest Bid Amount and Highest Bidder Address**:
287+
6. **View highest bid amount and highest bidder address**:
286288
```bash
287289
cast call 0xa945472E43646254913578f0dc0adb0c73a5F584 "getHighestBid()" --rpc-url $RPC_URL
288290
```
@@ -310,7 +312,7 @@ we should see a new transaction being sent at block `58` in the Anvil blockchain
310312

311313
### Step 8: Optional extra tasks to finalise the auction process.
312314

313-
1. **Fulfil Highest Bid**:
315+
1. **Fulfil highest bid**:
314316
To finish off the auction process, bidder B can fulfil the highest bid by paying 0.3 ether which is the difference between the highest bid amount of 0.4 ether and the reserve price of 0.1 ether paid by all bidders during the sealed bid transaction.
315317
```bash
316318
cast send 0xa945472E43646254913578f0dc0adb0c73a5F584 "fulfilHighestBid()" \
@@ -327,8 +329,13 @@ we should see a new transaction being sent at block `58` in the Anvil blockchain
327329
--rpc-url $RPC_URL
328330
```
329331

330-
### Step 9: Tidying Up
331-
We can stop all the running services / containers from the project root folder:
332+
### Step 9: Tidying up
333+
We can exit the terminal window running within the `bls-bn254-js` container, with the following commans:
334+
```bash
335+
exit
336+
```
337+
338+
We can also stop all the running services / containers from the project root folder:
332339
```bash
333340
docker compose down
334341
```

blocklock-agent/package.json

-3
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,5 @@
4545
"esbuild": "^0.24.0",
4646
"eslint": "^9.13.0",
4747
"typescript-eslint": "^8.12.2"
48-
},
49-
"engines": {
50-
"node": ">=22.3.0"
5148
}
5249
}

bls-bn254-js/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ COPY --from=skeleton /app/.moon/docker/workspace .
5252
# Install project dependencies
5353
RUN moon docker setup
5454

55+
# Install the esbuild package
5556
RUN npm install -g esbuild
5657

5758
# Copy project sources from skeleton

0 commit comments

Comments
 (0)