Skip to content

Fountech-ai-Limited/fairseq-sdk

Fairseq SDK

Temporal ordering proofs for blockchain protocols.

Fairseq is the Rust SDK for generating and verifying cryptographic proofs that transactions were sequenced fairly (FIFO), anchored to verifiable time via the Lighthouse Network.

Installation

Add Fairseq to your Cargo.toml:

[dependencies]
fairseq-sdk = "0.1"
tokio = { version = "1", features = ["full"] }

Quick Start

use fairseq_sdk::{Config, Prover, Transaction};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a prover
    let config = Config::default();
    let prover = Prover::new(config).await?;

    // Record transactions with timestamps
    let transactions = vec![
        Transaction::new("0xabc123...", 1704067200000000000), // nanoseconds
        Transaction::new("0xdef456...", 1704067200100000000),
        Transaction::new("0x789ghi...", 1704067200200000000),
    ];

    // Generate a temporal ordering proof
    let proof = prover.prove(transactions).await?;

    println!("Proof ID: {}", proof.id);
    println!("Transactions: {}", proof.transaction_count);
    println!(
        "Epochs: {} -> {}",
        proof.epoch_start.epoch_number, proof.epoch_end.epoch_number
    );

    Ok(())
}

Verification

use fairseq_sdk::{Config, Verifier};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = Config::default();
    let verifier = Verifier::new(config).await?;

    // Verify a proof
    let result = verifier.verify(&proof).await?;

    if result.valid {
        println!("✓ Proof is valid");
    } else {
        println!("✗ Proof is invalid: {:?}", result.error);
    }

    Ok(())
}

Configuration

use fairseq_sdk::Config;

// From environment variables
let config = Config::from_env();

// Or manually
let config = Config::default()
    .with_lighthouse_url(
        "https://lighthouse.fairseq.io",
        "wss://lighthouse.fairseq.io/ws"
    )
    .with_api_key("fsk_...")
    .with_debug(true);

Environment Variables

  • FAIRSEQ_LIGHTHOUSE_URL - Lighthouse HTTP endpoint
  • FAIRSEQ_LIGHTHOUSE_WS_URL - Lighthouse WebSocket endpoint
  • FAIRSEQ_API_KEY - API key for hosted services
  • FAIRSEQ_DEBUG - Enable debug logging

Documentation

Full documentation: https://fairseq.io/docs

License

MIT OR Apache-2.0

About

Rust SDK for temporal ordering proofs. Prove your sequencer is fair — with math.

Resources

License

MIT, Apache-2.0 licenses found

Licenses found

MIT
LICENSE
Apache-2.0
LICENSE-APACHE

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages