Skip to content

Built with Cairo, the Utu relay contract securely registers and verifies Bitcoin block data on Starknet, enabling smart contracts to validate Bitcoin transactions and access trust metrics.

Notifications You must be signed in to change notification settings

lfglabs-dev/utu_relay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Utu Relay

Utu Relay is a Starknet smart contract that enables secure verification of Bitcoin transactions and events. Named after the ancient Sumerian sun god who was believed to see everything that happened in the world, Utu Relay aims to provide a transparent and secure way to bridge Bitcoin data to the Starknet ecosystem.

Overview

Utu Relay allows anyone to register Bitcoin block headers on Starknet and set the canonical chain. Smart contracts can access these blocks, along with trust metrics like cumulative proof-of-work and unchallenged time, to verify that any Bitcoin transaction was accepted by the network.

Key features:

  • Verify any part of Bitcoin's history
  • Maintain canonical chain
  • Strong security guarantees
  • Game theory incentives for maintaining accuracy

Security Guarantees

  • Accurate proof-of-work reporting
  • Accurate block height reporting
  • Strongest proof-of-work chain selection
  • Economic incentives for maintaining the most up-to-date chain
  • On-chain detection of 51% attacks

Contract Interface

register_blocks(blocks: Span)

Register a list of Bitcoin block headers. Blocks don't need to be contiguous or in order.

update_canonical_chain(begin_height: u64, end_height: u64, end_block_hash: Digest, height_proof: Option<(ByteArray, Span)>)

Set the official canonical chain for a given interval [begin_height, end_height). Verifies that the end block hash and all its parents are registered. The height_proof parameter is optional and is used to verify the block height when the chain at begin-1 is not set.

challenge_block(block_height: u64, blocks: Array) → bool

Challenge and potentially update a registered block, with an incentive mechanism for successful updates. To be implemented.

get_status(block_hash: Digest) → BlockStatus

Retrieve information about a block using its hash, including its status and other relevant data.

get_block(height: u64) → Digest

Retrieve the block hash for a given block height.

Usage Example

Here's a simplified example of how to securely verify a Bitcoin transaction:

  1. Ensure the block containing the transaction is part of the canonical chain using update_canonical_chain.
  2. Verify the block's status using get_status to check if it's unchallenged and has been registered for a sufficient time.
  3. Adjust verification requirements based on the specific security needs of your application.

Fraud Detection and Reporting

  • Detect fraud: Compare registered block hash with Bitcoin Core output for the same height.
  • Report fraud: Call challenge_block with the correct block headers to replace the fraudulent entry.

Potential Attack Vectors

Two potential attack vectors exist:

  1. Submission of fraudulent block headers: An attacker could attempt to submit false block headers, particularly if no one is actively submitting fraud proofs or using the valid block hash.

  2. 51% attack: Theoretically, an attacker with control over 51% of the Bitcoin hashrate for an extended period could manipulate the relay.

However, these attacks are generally impractical due to:

  • Economic disincentives: The cost of executing such attacks typically outweighs potential gains.
  • Detection mechanisms: On-chain detection of 51% attacks allows contracts to implement additional security measures.
  • Active monitoring: Honest users and watchers can submit fraud proofs, quickly challenging any false submissions.

The combination of these factors significantly mitigates the risk of successful attacks on the Utu Relay system.

About

Built with Cairo, the Utu relay contract securely registers and verifies Bitcoin block data on Starknet, enabling smart contracts to validate Bitcoin transactions and access trust metrics.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages