An open API service indexing awesome lists of open source software.

https://github.com/usexfg/xfg-stark

❄️ Winterfell-based STARKs for zero-knowledge COLD collateral proofs and XFG burn proofs πŸ”₯
https://github.com/usexfg/xfg-stark

cd cold embers fire fuego heat stark winterfell xfg zero-knowledge-proofs zk-collateral zk-starks zkstark

Last synced: about 2 months ago
JSON representation

❄️ Winterfell-based STARKs for zero-knowledge COLD collateral proofs and XFG burn proofs πŸ”₯

Awesome Lists containing this project

README

          

# XFG STARKs

[![Rust](https://img.shields.io/badge/rust-1.70+-blue.svg)](https://www.rust-lang.org)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Winterfell Standards](https://img.shields.io/badge/Winterfell%20Standards-Enforced-green.svg)](https://github.com/ColinRitman/xfgwinter)

**❄️Winterfell based zkSTARKs for XFG collateral burn proofsπŸ”₯**

A fortress of cryptographic strength, implementing STARK (Scalable Transparent Argument of Knowledge) proofs with the unyielding security of Winterfell's walls, memory safety as solid as the castle's foundation, and zero-cost abstractions that would make even the most cunning Lannister envious.

## βš”οΈ The XFG Winterfell Arsenal

### πŸ›‘οΈ Core Defenses

- **βš”οΈ Field Arithmetic**: Type-safe field element operations with constant-time implementations that would make the Night's Watch proud
- **πŸ“œ Polynomial Operations**: Efficient polynomial arithmetic and evaluation, more precise than even MΓ¦ster Luwin's calculations
- **🏰 STARK Proof System**: Complete STARK proof generation and verification- the cryptographic equivalent of Winterfell's defenses
- **𐂷 Type System**: Comprehensive type definitions for all cryptographic operations, as thorough as the Stark family tree

### πŸ›‘οΈ Security Fortifications

- Constant-time cryptographic operations that never reveal their secrets
- Secure secret management with zeroization.
- Type-level prevention of timing attacks, more reliable than the Wall's magic
- Memory safety through Rust's type system as strong as Valyrian steel
- Comprehensive error handling with Result types as true as the word of Ned Stark's son.

### ⚑ Performance ~~Weapons~~ Tools

- Zero-cost abstractions for all operations as efficient as Arya's water dancing
- Optimized field arithmetic implementations as fast as direwolves
- Efficient polynomial evaluation algorithms as precise as one of The L3-eyed Raven's visions
- Minimal runtime overhead for type safety as light as a crow's feather

## β›« Building Winterfell

### Prerequisites
#### The forge of the North

- Rust 1.70+ ([Install Rust](https://rustup.rs/)) -
- Cargo (comes with Rust)

### Construction

```bash
# Clone the repository
git clone https://github.com/ColinRitman/xfgwinter.git
cd xfgwinter

# Build the project
cargo build

# Run tests
cargo test

# Run benchmarks
cargo bench
```

## 🏰 Citadelian Architecture

```
xfgwinter/
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ lib.rs # Main library entry point - The Great Hall
β”‚ β”œβ”€β”€ types/ # Type system definitions - The Crypts
β”‚ β”‚ β”œβ”€β”€ mod.rs # Type system module - The Master's Chamber
β”‚ β”‚ β”œβ”€β”€ field.rs # Field element types - The Armory
β”‚ β”‚ β”œβ”€β”€ polynomial.rs # Polynomial types - The Library
β”‚ β”‚ β”œβ”€β”€ stark.rs # STARK proof types - The Godswood
β”‚ β”‚ └── secret.rs # Secret management types - The Secret Chambers
β”‚ β”œβ”€β”€ field/ # Field arithmetic implementations - The Training Yard
β”‚ β”œβ”€β”€ polynomial/ # Polynomial arithmetic implementations - The Maester's Tower
β”‚ β”œβ”€β”€ stark/ # STARK proof implementations - The Watchtower
β”‚ └── utils/ # Utility functions - The Kitchens
β”œβ”€β”€ agents/ # Background agent specifications - The Council Chamber
β”œβ”€β”€ background-agents/ # Background agent system - The War Room
β”œβ”€β”€ tests/ # Integration tests - The Training Grounds
β”œβ”€β”€ benches/ # Performance benchmarks - The Tourney Grounds
└── docs/ # Documentation - The Archives
```

## βš”οΈ Wielding XFG-STARK's Power

### Basic Field Operations

```rust
use xfg_stark::types::field::PrimeField64;

// Create field elements - Forging the weapons
let a = PrimeField64::new(5);
let b = PrimeField64::new(3);

// Perform arithmetic operations - The art of war
let sum = a + b;
let product = a * b;
let inverse = a.inverse().unwrap();

// Constant-time operations - The way of the North
let ct_sum = a.add_constant_time(&b);
let ct_product = a.mul_constant_time(&b);
```

### Polynomial Operations

```rust
use xfg_stark::types::polynomial::FieldPolynomial;
use xfg_stark::types::field::PrimeField64;

// Create polynomials - Crafting the spells
let coeffs = vec![PrimeField64::new(1), PrimeField64::new(2), PrimeField64::new(1)];
let poly = FieldPolynomial::new(coeffs);

// Evaluate polynomial - Casting the magic
let result = poly.evaluate(PrimeField64::new(3));

// Polynomial arithmetic - The maester's calculations
let poly2 = FieldPolynomial::constant(PrimeField64::new(1));
let sum = poly.add(&poly2);
let product = poly.multiply(&poly2);
```

### STARK Proof Components

```rust
use xfg_stark::types::stark::{StarkProof, ExecutionTrace, Air};
use xfg_stark::types::field::PrimeField64;

// Create execution trace - The witness of the North
let trace = ExecutionTrace {
columns: vec![vec![PrimeField64::new(1), PrimeField64::new(2)]],
length: 2,
num_registers: 1,
};

// Create AIR constraints - The laws of the realm
let air = Air {
constraints: vec![],
transition: TransitionFunction {
coefficients: vec![vec![PrimeField64::new(1)]],
degree: 1,
},
boundary: BoundaryConditions { constraints: vec![] },
security_parameter: 128,
};

// Create STARK proof - The seal of Winterfell
let proof = StarkProof {
trace,
air,
commitments: vec![],
fri_proof: FriProof {
layers: vec![],
final_polynomial: vec![PrimeField64::new(1)],
queries: vec![],
},
metadata: ProofMetadata {
version: 1,
security_parameter: 128,
field_modulus: "0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47".to_string(),
proof_size: 1024,
timestamp: 1234567890,
},
};
```

## πŸ†’β˜‘οΈ Testing Winterfell's Defenses

### Run All Tests

```bash
cargo test
```

### Run Specific Test Categories

```bash
# Field arithmetic tests - Testing the armory
cargo test field

# Polynomial tests - Testing the library
cargo test polynomial

# STARK proof tests - Testing the watchtower
cargo test stark

# Secret management tests - Testing the secret chambers
cargo test secret
```

### Run Benchmarks

```bash
cargo bench
```

## πŸ“œ The Library Tower

### API Documentation

Generate and view API documentation:

```bash
cargo doc --open
```

### Mathematical Background

This implementation is based on:

- **[STARK Proofs](https://eprint.iacr.org/2018/046.pdf&ved=2ahUKEwjftqeb0sqPAxXAM2IAHR3DMWsQFnoECCEQAQ&usg=AOvVaw3U0RHxBdGk62bzwjc2PIju)**: Scalable Transparent Arguments of Knowledge - The ancient magic of the North
- **[Field Arithmetic](https://www.anubhavprasadsharma.com/files/Sharma_FiniteFieldArithmeticAndItsApplicationsToCryptography.pdf&ved=2ahUKEwiH6eHq0sqPAxXvFVkFHZDMDiMQFnoECBcQAQ&usg=AOvVaw14hLfV867hrCUdFhfS-eJg)**: Finite field operations for cryptographic security - The foundation of Winterfell
- **[Polynomial Commitment Schemes](https://eprint.iacr.org/2020/081.pdf)**: Efficient polynomial evaluation and commitment - The maester's wisdom
- **[FRI Protocol](https://eprint.iacr.org/2024/1161)**: Fast Reed-Solomon Interactive Oracle Proof - The raven's message system

## Acknowledgments

- **[Winterfell by Meta](https://github.com/facebook/winterfell)**: cryptographic primitives and STARK implementation patterns

## πŸ§‘β€πŸ’» Join the Citadel

We welcome new maesters to xfgwin! Please see Archmæster or [How to become a mæster](https://github.com/usexfg) for details.
## πŸ”— Links

- [Repository](https://github.com/usexfg/xfg-stark)
- [Issues](https://github.com/usexfg/xfg-stark/issues)
- [Discussions](https://github.com/usexfg/xfg-stark/discussions)
- [Wiki](https://github.com/usexfg/xfg-stark/wiki)

---

Built with ❀️‍πŸ”₯ for the Fuego community

**2025 © Ξlderfire Privacy Group**

**2025 Β© USΞXFβ‚²**

Winter Is Coming