Skip to content

10234567Z/Aegis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

105 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ DeFiGuardian

TypeScript Solidity Python Circom Uniswap License

The best hack is the one that never happens.

A cryptographic airlock that makes DeFi exploits expensive, slow, and detectable using ML threat detection, guardian consensus, and cryptographic time-locks.

πŸ“– Technical Docs

πŸ¦„ Uniswap Integration β€’ πŸ”— LI.FI Integration β€’ πŸ“› ENS Integration


🎯 The Problem We Solve

⚠️ Three Critical Security Crises in DeFi:

πŸ”“ Single Points of Failure

  • Admin keys get compromised through phishing, malware, or insiders
  • One key = total control over protocol funds

⚑ Attacks Complete Instantly

  • Exploits happen in one block β€” no time to react
  • $3.8B stolen in 2022 with most hacks taking seconds

🏝️ Chains Are Isolated

  • Attackers hop between chains after draining one
  • No cross-chain coordination for security responses

πŸ“Š Market Reality

  • $3.8B stolen from DeFi protocols in 2022 alone
  • Many hacked protocols were audited β€” audits aren't enough
  • Zero security infrastructure that works across chains

πŸš€ The DeFiGuardian Solution

DeFiGuardian creates a mandatory security checkpoint between users and protocols. Think of it like an airlock on a spaceship β€” nothing gets through without proper verification. By combining ML threat detection, distributed guardian consensus, cryptographic time-locks, and cross-chain coordination, we turn "seconds to exploit" into "30 minutes to defend".

✨ Key Features:

πŸ€– ML Threat Detection

  • AI trained on thousands of past exploits
  • Catches flash loans, oracle manipulation, unusual patterns
  • Flags suspicious transactions before execution

πŸ” No Single Point of Failure

  • 10 independent guardians, need 7/10 to approve
  • FROST threshold signatures β€” no admin keys
  • ZK private voting β€” can't bribe individual guardians

⏱️ Forced Time Delays

  • 30-minute VDF lock on suspicious transactions
  • Can't be parallelized β€” attackers can't speed it up
  • Guardians can bypass by voting to approve

🌐 Cross-Chain Security

  • Threat detected on Ethereum? All chains know instantly
  • Emergency pause propagates everywhere via LayerZero
  • Blacklisted addresses blocked on every chain

DeFiGuardian Architecture


πŸ› οΈ Technical Architecture

πŸ”§ Core Technologies

πŸ” FROST

Threshold Signatures 7-of-10 Ed25519 Schnorr signing

⏱️ VDF

Verifiable Delay Functions Wesolowski with RSA-2048

🎭 ZK Proofs

Private Guardian Voting Groth16 via Circom + snarkjs

πŸ€– XGBoost ML

Fraud Detection 47 features from Etherscan data

πŸ¦„ Uniswap v4

Hook Integration Security built into every swap

πŸ”— LI.FI + LayerZero

Cross-Chain Routing & security propagation

The Security Flow:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Step 1: User Intent                                         β”‚
β”‚ - Transaction submitted to SDK                              β”‚
β”‚ - Pre-flight: Is protocol paused? Is sender blacklisted?    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Step 2: ML Analysis                                         β”‚
β”‚ - XGBoost model analyzes sender history (47 features)       β”‚
β”‚ - Score >= 50 = FLAGGED for VDF delay                       β”‚
β”‚ - ENS security profile applied if user has one              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Step 3: Parallel Processing                                 β”‚
β”‚                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  VDF Time-Lock   β”‚     β”‚  Guardian Network            β”‚  β”‚
β”‚  β”‚  (if flagged)    β”‚     β”‚  10 guardians vote           β”‚  β”‚
β”‚  β”‚                  β”‚     β”‚  ZK proofs for privacy       β”‚  β”‚
β”‚  β”‚  30 min delay    β”‚     β”‚  FROST signature if approved β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Step 4: Execution                                           β”‚
β”‚ - VDF proof + FROST signature verified on-chain             β”‚
β”‚ - Transaction executes (or blocked if rejected)             β”‚
β”‚ - Cross-chain broadcast if needed                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ† Partner Integrations

πŸ¦„ Uniswap v4

GuardianHook

Security checks on every swap:

  • Blacklist enforcement
  • Protocol pause
  • ENS security profiles
  • Large swap detection

πŸ“– Integration Docs

πŸ”— LI.FI

Cross-Chain Routing

Protected bridges & swaps:

  • Optimal route finding
  • Security before execution
  • Multi-chain aggregation

πŸ“– Integration Docs

πŸ“› ENS

Security Profiles

User-defined protection:

  • Personal thresholds
  • Whitelist-only mode
  • Webhook notifications

πŸ“– Integration Docs


πŸ“œ Deployed Contracts (Sepolia)

Contract Address Role
πŸ”’ SecurityMiddleware 0x8A4364c08147b1Ec0025e7B1e848BF675f9Dc7b9 Main airlock β€” queue + execute
πŸ‘₯ GuardianRegistry 0x702e8307Bc9c8EC7489C6f9e5562EdA44bB9fB7d Security state & proposals
πŸ¦„ GuardianHook 0xFce40025E4a77D5395188d82657A728521D839ec Uniswap v4 integration
⏱️ VDFVerifier 0xFAf997119B0FFDF62E149Cbfc3713267a7C8DaEA VDF proof verification
✍️ FROSTVerifier 0x02a59687A130D198a23F790866500489F6f88C12 Threshold signature verification
🎭 ZKVoteVerifier 0xb638C0997778F172ba4609B8E20252483cD87eEE Private voting verification

Network: Sepolia (Chain ID: 11155111) Deployer: 0x69E135540F4F5B69592365DFE7730c08ACe96CCb


πŸ“ Project Structure

DeFiGuardian/
β”‚
β”œβ”€β”€ πŸ“‚ sdk/                      # TypeScript SDK β€” main integration point
β”‚   β”œβ”€β”€ core/                    # Middleware, VDF client, ZK client, LI.FI, ENS
β”‚   └── mockExamples/            # 5 demo scripts for testing
β”‚
β”œβ”€β”€ πŸ“‚ agent/                    # Python ML Agent (Flask API)
β”‚   β”œβ”€β”€ main.py                  # /analyze, /review endpoints + SSE
β”‚   └── models/                  # XGBoost model + preprocessors
β”‚
β”œβ”€β”€ πŸ“‚ guardian-mock/            # Mock Guardian Network (Express)
β”‚   └── src/                     # Voting simulation + FROST signing
β”‚
β”œβ”€β”€ πŸ“‚ lib/                      # Cryptographic libraries
β”‚   β”œβ”€β”€ frost/                   # FROST threshold signatures (Ed25519)
β”‚   β”œβ”€β”€ vdf/                     # Wesolowski VDF prover/verifier
β”‚   └── zk/                      # Circom circuits + Groth16
β”‚
β”œβ”€β”€ πŸ“‚ contracts/                # Solidity smart contracts
β”‚   β”œβ”€β”€ SecurityMiddleware.sol  # Main airlock
β”‚   β”œβ”€β”€ GuardianRegistry.sol    # Security state manager
β”‚   β”œβ”€β”€ hooks/GuardianHook.sol  # Uniswap v4 Hook
β”‚   └── verifiers/              # VDF, FROST, ZK verifiers
β”‚
β”œβ”€β”€ πŸ“‚ docs/                     # Documentation
β”‚   β”œβ”€β”€ TECHNICAL.md            # Complete technical reference
β”‚   β”œβ”€β”€ UNISWAP_INTEGRATION.md  # Uniswap v4 partner docs
β”‚   β”œβ”€β”€ LIFI_INTEGRATION.md     # LI.FI partner docs
β”‚   └── ENS_SECURITY_PROFILES.md # ENS integration docs
β”‚
└── πŸ“‚ ML_bot/                   # Jupyter notebook for model training

πŸš€ Quick Start

πŸ“‹ Prerequisites

  • Node.js 18+
  • Python 3.11+
  • Sepolia RPC URL (Infura/Alchemy)
  • Funded wallet (>0.01 ETH)

⚑ Installation

# Clone the repository
git clone https://github.com/Jayanth-M0625/DeFiGuardian.git
cd DeFiGuardian

# Start ML Agent (Terminal 1)
cd agent && uv run python main.py

# Start Guardian Mock (Terminal 2)
cd guardian-mock && npm install && npx ts-node src/server.ts

# Start VDF Worker (Terminal 3)
cd lib/vdf && npm install && npx ts-node server.ts

# Run demo (Terminal 4)
cd sdk && npm install
npx ts-node mockExamples/smallTx.ts --sepolia

πŸ“œ Demo Scripts

Command Scenario Result
npx ts-node mockExamples/smallTx.ts --sepolia 0.1 ETH normal tx βœ… PASS
npx ts-node mockExamples/bigTxPass.ts --sepolia 500 ETH + VDF + approve βœ… PASS
npx ts-node mockExamples/bigTxFail.ts --sepolia 1000 ETH attack ❌ BLOCKED
npx ts-node mockExamples/BigTxCrossPass.ts --sepolia Cross-chain 500 ETH βœ… PASS
npx ts-node mockExamples/SmallTxCross.ts --sepolia Cross-chain 0.5 ETH βœ… PASS

πŸ“– Documentation

Document Description
πŸ“˜ Technical Documentation Complete SDK API, contract details, integration guide
πŸ¦„ Uniswap v4 Integration GuardianHook for security-first trading
πŸ”— LI.FI Integration Cross-chain security with LI.FI aggregation
πŸ“› ENS Security Profiles User-defined security rules via ENS
πŸ“„ Project Overview Non-technical overview of problem & solution

βš™οΈ Protocol Constants

Constant Value Description
πŸ‘₯ GUARDIAN_COUNT 10 Total guardians in network
βœ… GUARDIAN_THRESHOLD 7 Required approvals (7/10)
⏱️ VDF_DELAY 30 min Time-lock when ML flags
πŸ”’ VDF_ITERATIONS 300M Sequential squarings
πŸ€– ML_THRESHOLD 50 Score >= 50 = flagged

⚠️ Disclaimer

Proof of Concept

This project is a proof of concept built for ETHGlobal 2025. It demonstrates potential directions for DeFi security infrastructure and is NOT intended for production use or real financial transactions.

No Warranty

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY.


πŸ›‘οΈ DeFiGuardian

Made with ❀️ for Hack Money 2026

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors