Unveiling the power of first-price sealed-bid Auctions in Aleo Leo: tutorial

HEORHII YABLONSKYI
4 min readJan 15, 2024

Hey, tech enthusiasts! I’m Heorhii, and today we embark on an exciting journey into Aleo Leo, exploring the intricacies of first-price sealed-bid auctions. As we delve into this fascinating topic, we’ll not only understand the fundamentals of running a sealed-bid auction but also witness the seamless integration of this mechanism into the privacy-focused world of Aleo Leo. Buckle up, and let’s unlock the potential of decentralized, transparent, and secure bidding!

Why Aleo Leo for Auction deployment?

  • Privacy assurance. In a first-price sealed-bid auction, confidentiality is paramount. Aleo Leo’s privacy features ensure that bids remain hidden, fostering an environment where participants submit their bids without knowledge of others’ values. This not only guarantees a fair and unbiased auction but also aligns with the principles of privacy and security that blockchain technology promises.
  • Decentralized trust. Aleo Leo introduces robust features such as record declarations and ownership, providing a decentralized mechanism to verify the honesty of the auctioneer. This ensures that bids are resolved in the order received without any tampering, establishing trust within the auction process.

Tutorial overview:

  1. Auction setup: initializing the environment. The foundation of any auction is crucial. We begin by setting up the auction with three key players: the auctioneer and two bidders.
  • Bidder: a participant in the auction.
  • Auctioneer: the party responsible for conducting the auction.

Each party is equipped with a private key and an associated address.

We make following assumptions about the auction:

  • The auctioneer is honest. That is, the auctioneer will resolve all bids in the order they are received. The auctioneer will not tamper with the bids.
  • There is no limit to the number of bids.
  • The auctioneer knows the identity of all bidders, but bidders do not necessarily know the identity of other bidders.

Under this model, we require that: bidders do not learn any information about the value of other bids.

The three parties we’ll be emulating are as follows:

First Bidder Private Key:  
APrivateKey1zkpG9Af9z5Ha4ejVyMCqVFXRKknSm8L1ELEwcc4htk9YhVK
First Bidder Address:
aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke

Second Bidder Private Key:
APrivateKey1zkpAFshdsj2EqQzXh5zHceDapFWVCwR6wMCJFfkLYRKupug
Second Bidder Address:
aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4

Auctioneer Private Key:
APrivateKey1zkp5wvamYgK3WCAdpBQxZqQX8XnuN2u11Y6QprZTriVwZVc
Auctioneer Address:
aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh

2. Bidding stage: the first bid. With the stage set, the first bidder steps in, placing an initial bid of 10.

Swap in the private key and address of the first bidder to .env.

echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpG9Af9z5Ha4ejVyMCqVFXRKknSm8L1ELEwcc4htk9YhVK
" > .env

The process involves invoking the place_bid function, a fundamental step in any sealed-bid auction.

leo run place_bid aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke 10u64

3. Next bidder enters: the second bid. The auction gains momentum as the second bidder joins the fray, submitting a bid of 90.

Swap in the private key of the second bidder to .env.

echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpAFshdsj2EqQzXh5zHceDapFWVCwR6wMCJFfkLYRKupug
" > .env

This step ensures that bids can be of varying amounts, contributing to the flexibility of the auction model.

leo run place_bid aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4 90u64

4. Select the winner: auctioneer’s decision. The auctioneer, armed with knowledge of all bids, enters the scene. The resolve function is invoked to determine the winning bid. The auctioneer, being honest and transparent, resolves bids in the order they were received.

leo run resolve "<FirstBidRecord>" "<SecondBidRecord>"

Swap in the private key of the auctioneer to .env.

echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkp5wvamYgK3WCAdpBQxZqQX8XnuN2u11Y6QprZTriVwZVc
" > .env

Provide the two Bid records as input to the resolve transition function.

leo run resolve "{
owner: aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh.private,
bidder: aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke.private,
amount: 10u64.private,
is_winner: false.private,
_nonce: 4668394794828730542675887906815309351994017139223602571716627453741502624516group.public
}" "{
owner: aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh.private,
bidder: aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4.private,
amount: 90u64.private,
is_winner: false.private,
_nonce: 5952811863753971450641238938606857357746712138665944763541786901326522216736group.public
}"

5. Finish the auction: declaring the winner. The final act involves officially closing the auction and declaring the winner. The finish function is called with the winning bid record, completing the auction cycle.

leo run finish "<WinningBidRecord>"

Call the finish transition function with the winning Bid record.

leo run finish "{
owner: aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh.private,
bidder: aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4.private,
amount: 90u64.private,
is_winner: false.private,
_nonce: 5952811863753971450641238938606857357746712138665944763541786901326522216736group.public
}"

Advantages of Aleo Leo for auction deployment:

  • Enhanced privacy. Aleo Leo’s commitment to privacy ensures that the details of bids remain confidential. This not only aligns with the ethos of blockchain but also instills trust among participants, making Aleo Leo an ideal platform for privacy-centric auctions.
  • Verifiable integrity. The decentralized nature of Aleo Leo, coupled with features like record ownership, allows participants to independently verify the integrity of the auctioneer. This transparency contributes to a trustful bidding environment.

The example and instructions you can find here:

Conclusion. Congratulations! You’ve successfully orchestrated a private auction on Aleo Leo. This tutorial has illuminated the seamless integration of first-price sealed-bid auctions into Aleo Leo’s privacy-focused blockchain. As you explore further, leverage the power of Aleo Leo to create innovative, secure, and decentralized auction solutions.

To know more, join now!
Aleo Twitter
Aleo Discord — updated link!!!
Aleo Website
List of Aleo and Leo code and resourses

Prepared by Colliseum

--

--