Examples

Real-world usage patterns and code samples for Genin402 Privacy.

Basic Privacy Analysis

Analyze a single wallet transfer configuration

from genin402 import PrivacyEngine, ShadowTransfer

engine = PrivacyEngine()

transfer = ShadowTransfer(
    wallet_address="7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
    transfer_amount_sol=25.0,
    hop_count=7,
    mixer_pools_used=3,
    decoy_tx_count=15,
    payment_gate_active=1,
)

report = engine.analyze(transfer)
print(report.verdict)        # JONIN
print(report.privacy_score)  # 81.4
Batch Analysis

Analyze multiple transfers at once, sorted by privacy score

from genin402 import PrivacyEngine, ShadowTransfer

engine = PrivacyEngine()

transfers = [
    ShadowTransfer(wallet_address="wallet1...", hop_count=3, ...),
    ShadowTransfer(wallet_address="wallet2...", hop_count=7, ...),
    ShadowTransfer(wallet_address="wallet3...", hop_count=5, ...),
]

reports = engine.analyze_batch(transfers)
# Results sorted by privacy_score descending

for report in reports:
    print(f"{report.wallet}: {report.verdict} ({report.privacy_score})")
REST API Integration

Use the HTTP API for external integrations

# Start the server
uvicorn genin402.server:app --reload

# API Endpoints:
# POST /analyze          → ShadowReport
# POST /analyze/batch    → list[ShadowReport]
# GET  /health           → { "status": "ok" }

# Example cURL request:
curl -X POST http://localhost:8000/analyze \
  -H "Content-Type: application/json" \
  -d '{"wallet_address": "7xKX...", "hop_count": 7, ...}'
TypeScript CLI

Command-line interface for quick analysis

# Build the CLI
cd ts && npm install && npm run build

# Analyze a single wallet
node dist/cli.js analyze 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU

# Batch analyze multiple wallets
node dist/cli.js batch wallet1 wallet2 wallet3

# Output:
# wallet1: JONIN (81.4) - DARK
# wallet2: CHUNIN (65.2) - GREY
# wallet3: GENIN (48.1) - DIM
Docker Deployment

Run the full stack with Docker Compose

# docker-compose.yml already configured
docker-compose up

# Services:
# API  → http://localhost:8000
# UI   → http://localhost:3000

# Health check:
curl http://localhost:8000/health
# {"status": "ok"}
Maximizing Privacy Score

Configuration for achieving ANBU rank (90+)

# ANBU-level configuration
transfer = ShadowTransfer(
    wallet_address="...",
    transfer_amount_sol=25.0,
    
    # Stealth patterns (all 10 active = 100 stealth_score)
    hop_count=7,              # multi_hop: >= 5
    mixer_pools_used=3,       # pool_routed: >= 2
    decoy_tx_count=15,        # decoy_flood: >= 10
    payment_gate_active=1,    # gate_active: == 1
    route_splits=4,           # split_route: >= 3
    time_delay_blocks=35,     # time_shifted: >= 20
    dummy_outputs=7,          # dummy_outputs: >= 5
    memo_obfuscated=1,        # memo_dark: == 1
    token_program_obscured=1, # program_masked: == 1
    fee_randomized=1,         # fee_noise: == 1
)

# Result: ANBU (90+) - DARK cloak status

Ready to measure your shadow depth?