Skip to content

Zero-Collateral Lottery System for Arkade#19

Open
pingu-73 wants to merge 15 commits into
mainfrom
trustless-lottery
Open

Zero-Collateral Lottery System for Arkade#19
pingu-73 wants to merge 15 commits into
mainfrom
trustless-lottery

Conversation

@pingu-73
Copy link
Copy Markdown
Owner

@pingu-73 pingu-73 commented Aug 14, 2025

Overview

This PR introduces zero-collateral lottery system built on top of the Ark Protocol, enabling provably fair, self-custodial lottery games with $O(log N)$ complexity as described in the 1. The implementation leverages Ark's efficient off-chain execution layer while maintaining Bitcoin's security guarantees.

Closes #10, #7, #6, #5

Architecture Overview

The lottery system implements a cryptographic commitment-reveal scheme on Ark:

  1. Participants commit to random values using cryptographic commitments
  2. All commitments are collected in a coordinated phase
  3. Participants reveal their secrets in a subsequent phase
  4. Winner is determined through deterministic randomness extraction
  5. Payouts are executed via Ark's batch swap mechanism

Features

1. Provably Fair Randomness

The system implements a mathematically sound randomness extraction mechanism:

Mathematical Proof of Fairness:
Let P = {p₁, p₂, ..., pₙ} be the set of n participants, each submitting:

  • Secret: sᵢ ∈ {0,1}^{256}
  • Nonce: nᵢ ∈ {0,1}^{256}
  • Commitment: cᵢ = H(sᵢ || nᵢ || lottery_id || pᵢ)

Randomness Extraction:

  1. Seed Generation: seed = H(∑(sᵢ || nᵢ)) for all i ∈ [1,n]
  2. Winner Selection: winner_index = seed mod n
  3. Deterministic Outcome: Given all valid reveals, outcome is deterministic

Security Properties:

  • Binding: Participants cannot change commitments after submission
  • Hiding: Secrets remain hidden until reveal phase
  • Unbiasability: No single participant can bias the outcome
  • Verifiability: All participants can verify fairness

2. Trustless Execution BUT with ASP Cosigning

The system operates in a trustless manner while leveraging the Ark Service Provider (ASP) as a cosigner:

Trust Model:

  • Self-Custodial: Participants maintain unilateral exit rights at all times
  • ASP Role: Cosigner for off-chain coordination (cannot steal funds)
  • Zero Collateral: No security deposits required from participants
  • Verifiable: All state transitions are Bitcoin-enforceable

Security Guarantees:

  • Unilateral Exit: Participants can always reclaim funds via Bitcoin Script
  • Double-Spend Protection: Commitment signatures prevent cheating
  • Timeout Safety: Automatic refunds if phases timeout
  • ASP Non-custodial: ASP cannot access participant funds without cooperation

Paper Compliance:

  • O(log N) Complexity: Single-round implementation (can be extended to full tournament)
  • Zero Collateral: No security deposits required
  • Commitment Scheme: Cryptographic hiding and binding
  • Fairness: Provably unbiased winner selection
  • Timeout Handling: Graceful abort/recovery mechanisms

Current Implementation Scope:
While the 1 describes full binary tournament trees, this pr focuses on the core cryptographic mechanisms and single-round lotteries as a foundation for more complex tournament structures.

Enhancements to Ark Protocol and Bitcoin Ecosystem

1. Application Layer

This implementation demonstrates Ark's capability to support complex cryptographic protocols beyond simple payments:

  • Programmable VTXOs: Custom Taproot scripts for lottery escrows
  • Batch Coordination: Multi-party commitment-reveal coordination
  • State Management: Complex state transitions with timeouts
  • Fairness Proofs: Cryptographic verification of game outcomes

2. Scalability Benefits

Leveraging Ark's batching capabilities provides significant scalability improvements:

  • Reduced On-Chain Footprint: Multiple lottery operations compress to single Bitcoin tx
  • Lower Fees: Amortized costs across participants
  • Faster Settlement: Near-instant off-chain coordination
  • Parallel Execution: Independent lotteries execute concurrently

3. Bitcoin Ecosystem Value

The system enhances Bitcoin's utility as a gaming and financial platform:

  • Self-Custodial Gaming: True ownership without platform risk
  • Provably Fair: Mathematical guarantees of fairness
  • Bitcoin-Native: Direct integration with Bitcoin's security model
  • Composability: Can be integrated into larger DeFi applications

Additions

  1. Lottery Coordinator: Central coordination logic for lottery phases
  2. Escrow Scripts: Custom Taproot scripts for lottery escrow addresses
  3. Commitment Manager: Cryptographic commitment-reveal handling
  4. Winner Determination: Fair randomness extraction algorithm
  5. Payout Engine: Batch swap integration for fund distribution

Mathematical Fairness Proof

Lottery is provably fair and unbiased.

Proof:

Let the system have n participants, each submitting secret sᵢ and nonce nᵢ.

  1. Hiding Property:

    • Commitment cᵢ = H(sᵢ || nᵢ || lottery_id || pᵢ)
    • Given only cᵢ, finding sᵢ requires inverting SHA256 (computationally infeasible)
  2. Binding Property:

    • Participant signs commitment: σᵢ = Sign(pᵢ, cᵢ)
    • Changing commitment requires breaking Schnorr signature scheme
  3. Unbiasability:

    • Seed generation: seed = H(∑(sᵢ || nᵢ))
    • Winner selection: index = seed mod n
    • Assuming at least one honest participant, seed is uniformly distributed
    • Therefore, P(winner = pᵢ) = 1/n for all i
  4. Verifiability:

    • All participants can verify: H(sᵢ || nᵢ || lottery_id || pᵢ) = cᵢ
    • All participants can verify: Sign(pᵢ, cᵢ) = σᵢ
    • All participants can verify: H(∑(sᵢ || nᵢ)) mod n = winner_index

Trust Model

Trustless Properties:

  • Participants maintain self-custody
  • Zero additional deposits needed
  • Mathematical proof of fairness
  • Bitcoin Script guarantees fund recovery

Ark Service Provider Role (Cosigner):

  • Coordination: Facilitates off-chain communication
  • Signature: Required for off-chain transaction efficiency
  • Non-custodial: Cannot access funds without participant cooperation
  • Limited Power: Cannot bias outcomes or steal funds

Security Assumptions:

  • SHA256 Security: Collision resistance and preimage resistance
  • Schnorr Signatures: EUF-CMA security
  • Honest Majority: At least one participant is honest for fairness
  • ASP Availability: ASP must be available for optimal experience (not for security)

Current Limitations:

  • Single-round implementation (1 describes O(log N) tournament)
  • Limited escrow script paths (1 requires full Taproot tree)
  • No automatic tournament bracket progression

Future Extensions:

  • Binary tournament bracket implementation
  • Full escrow script tree with all spending paths
  • Automated tournament progression
  • Cross-lottery coordination

Footnotes

  1. Miller, A., & Bentov, I. (2017). Zero-Collateral Lotteries in Bitcoin and Ethereum. arXiv:1612.05390. https://arxiv.org/abs/1612.05390 2 3 4

pingu-73 added 10 commits August 8, 2025 11:22
Signed-off-by: Dikshant <dikshant.073@gmail.com>
Signed-off-by: Dikshant <dikshant.073@gmail.com>
Signed-off-by: Dikshant <dikshant.073@gmail.com>
Signed-off-by: Dikshant <dikshant.073@gmail.com>
Signed-off-by: Dikshant <dikshant.073@gmail.com>
Signed-off-by: Dikshant <dikshant.073@gmail.com>
Signed-off-by: Dikshant <dikshant.073@gmail.com>
Signed-off-by: Dikshant <dikshant.073@gmail.com>
Signed-off-by: Dikshant <dikshant.073@gmail.com>
Signed-off-by: Dikshant <dikshant.073@gmail.com>
Signed-off-by: Dikshant <dikshant.073@gmail.com>
Signed-off-by: Dikshant <dikshant.073@gmail.com>
Signed-off-by: Dikshant <dikshant.073@gmail.com>
Signed-off-by: Dikshant <dikshant.073@gmail.com>
Signed-off-by: Dikshant <dikshant.073@gmail.com>
@pingu-73 pingu-73 requested a review from tiero August 15, 2025 05:14
@tiero tiero changed the title Zero-Collateral Lottery System for Ark Protocol Zero-Collateral Lottery System for Arkade Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add e2e tests Tx amount discrepancies Ark Issues Identified Add GH Actions Workflow Config

1 participant