Skip to content

trusts-stack-network/trust-stack-network

Repository files navigation

Trust Stack Network

Trust Stack Network (TSN)

Post-quantum privacy blockchain — Plonky3 STARKs · ML-DSA-65 · Poseidon2 · Shielded Transactions

Version Rust Tests Testnet License

WebsiteWhitepaperDocsBlogExplorerRun a NodeDiscord


Note: TSN is currently in private testnet. TSN tokens have no monetary value at this stage. They will only become meaningful once the incentivized testnet and eventually mainnet are launched. Do not purchase or trade TSN tokens — they can be mined for free by running a node.


What is TSN?

Trust Stack Network is a Layer 1 blockchain designed from the ground up for privacy and post-quantum security. Every transaction is shielded by default using zero-knowledge proofs, and all cryptographic primitives are quantum-resistant — protecting funds against both classical and future quantum adversaries.

Key Features

Feature Description
Plonky3 STARKs AIR-based zero-knowledge proofs wired into block validation — no trusted setup, truly post-quantum
ML-DSA-65 (FIPS 204) NIST post-quantum digital signatures for all transactions and blocks
SLH-DSA (FIPS 205) Stateless hash-based signatures as secondary post-quantum layer
Poseidon2 PoW ZK-friendly hash function over Goldilocks field — same hash for mining AND ZK proofs
Shielded Transactions Working V2 transactions with ZK proofs, broadcast and validated across the network
Interactive Wallet ./tsn wallet — generate, restore (BIP39 24-word seed), send, receive, history
P2P Auto-Update Nodes detect new versions via peer handshake, download, verify, and self-update
Anti-Reorg Protection MAX_REORG_DEPTH=100, Fork ID verification, anchor block filtering
zkVM Smart Contracts Stack-based VM with 30+ opcodes, gas metering, and ZK execution traces
MIK Consensus Mining Identity Key — Proof of Work with numeric difficulty and 512-bit nonce
Fast Sync Snapshot-based synchronization — full sync in ~2 seconds
3 Node Roles Miner, Relay, Light Client — each with auto-update capability

Security Model

TSN is designed to be fully quantum-safe — not just signatures, but the entire stack:

Layer Primitive Standard Purpose
Signatures ML-DSA-65 FIPS 204 Transaction & block signing
Backup Signatures SLH-DSA (SPHINCS+) FIPS 205 Stateless hash-based fallback
ZK Proofs Plonky3 STARKs (AIR) Shielded transaction validity
Hash Function Poseidon2 PoW mining, Merkle trees, commitments
Field Goldilocks p = 2⁶⁴ - 2³² + 1 ZK-friendly arithmetic
Encryption ChaCha20-Poly1305 RFC 8439 Note payload encryption
Anti-Sybil MIK One identity per miner

Mining Identity Key (MIK)

Every miner must register a Mining Identity Key before mining:

  • Derived from their ML-DSA-65 public key: MIK_ID = SHA-256("TSN_MIK_ID_v1" || pubkey || block_height)
  • One active MIK per public key — prevents Sybil attacks
  • Lifecycle: registration → activation delay (10 blocks) → active → optional expiry/revocation
  • Block signatures verified against the miner's registered MIK

Signature Sizes

Parameter ML-DSA-65
Public Key 1,952 bytes
Secret Key 4,032 bytes
Signature 3,309 bytes

Commitment Scheme

Note Commitment = Poseidon(domain=1, value, pk_hash, randomness)
Nullifier       = Poseidon(domain=3, nullifier_key, commitment, position)
Merkle Node     = Poseidon(domain=5, left, right)

Architecture

┌──────────────────────────────────────────────────────────────────────┐
│                         TSN Node v1.3.0                              │
├──────────────┬──────────────┬──────────────┬─────────────────────────┤
│    Core      │    Crypto    │  Consensus   │        Network          │
│  Block       │  Poseidon2   │  PoW Mining  │  libp2p (GossipSub)     │
│  Transaction │  ML-DSA-65   │  MIK Anti-   │  Kademlia DHT           │
│  UTXO State  │  Plonky3 ZK  │    Sybil     │  Auto-Update (P2P)      │
│  Validation  │  SLH-DSA     │  LWMA Diff   │  Anti-Eclipse           │
│              │  Nullifiers  │    Adjust    │  Rate Limiting          │
├──────────────┴──────────────┴──────────────┴─────────────────────────┤
│  VM (zkVM)   │  Contracts (Escrow, Multisig, AMM)  │  Stablecoin    │
├──────────────┼─────────────────────────────────────┼────────────────┤
│  Storage     │  Wallet (Shielded ZK + BIP39)       │  RPC (REST)    │
├──────────────┼─────────────────────────────────────┼────────────────┤
│  Explorer    │  Faucet (Testnet)                   │  Metrics       │
└──────────────┴─────────────────────────────────────┴────────────────┘

Quick Start

Download binary (recommended)

# Download latest release
curl -LO https://github.com/trusts-stack-network/trust-stack-network/releases/latest/download/tsn-linux-x86_64.tar.gz
tar xzf tsn-linux-x86_64.tar.gz
cd tsn-*

# Run a miner (4 threads)
./tsn miner -t 4

# Run a relay node
./tsn relay

# Run a light client
./tsn light

Build from source

Requires Rust nightly (automatically selected via rust-toolchain.toml):

# Install Rust if needed
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

git clone https://github.com/trusts-stack-network/trust-stack-network.git
cd trust-stack-network
cargo build --release

# Run (seeds and wallet auto-detected)
./target/release/tsn miner -t 4

Peer discovery is automatic via DNS seeds (seed1-4.tsnchain.com). New nodes fast-sync from a snapshot in ~2 seconds.

CLI Reference

./tsn miner -t 4           # Mine with 4 threads
./tsn relay                 # Run relay node
./tsn light                 # Run light client
./tsn wallet                # Interactive wallet menu
./tsn balance               # Check balance
./tsn send --to <addr> --amount 10  # Send TSN
./tsn new-wallet            # Generate new wallet (24-word BIP39 seed)
./tsn --version             # Print version info

Node Types

TSN supports 3 distinct node roles, selectable at startup:

Miner Node (./tsn miner)

Full node that validates, stores the entire blockchain, relays transactions/blocks, and mines new blocks. Miners earn 92% of the block reward (46 TSN per block). This is the default role.

Relay Node (./tsn relay)

Full node that stores the complete chain and relays blocks/transactions to peers, but does not mine. Relays are the backbone of the network — they ensure fast block propagation via GossipSub and serve snapshots to new nodes via fast-sync. They earn from the 3% relay reward pool.

Light Client (./tsn light)

Minimal node that does not store the full chain — it syncs only block headers and verifies transactions using ZK proofs. Designed for mobile wallets and resource-constrained devices.

Type Stores Chain Mines Relays Auto-Update Reward
Miner Yes Yes Yes Yes 92% block reward
Relay Yes Yes Yes 3% relay pool
Light Client Yes

All node types auto-update when a new version is detected on the network.

P2P Auto-Update

TSN is one of the first blockchains with fully decentralized automatic updates. No other blockchain combines P2P version signaling with multi-source download and cryptographic verification.

How it works:

  1. Peers announce their version during the libp2p Identify handshake
  2. If a peer has a newer version, the node queries the official release
  3. Binary is downloaded from GitHub (primary) or tsnchain.com (fallback)
  4. SHA256 integrity check + Ed25519 signature verification
  5. Current binary backed up, new binary installed, node restarts
Node A (v1.1.0) connects to Node B (v1.2.0)
  → A detects newer version via P2P handshake
  → A downloads v1.2.0 from GitHub, verifies signature
  → A self-updates and restarts
  → A is now v1.2.0
  → A's other peers detect the update via handshake
  → Network propagates the update in minutes

Manual update: ./tsn update

Mining & Hashrate — Poseidon2 Proof of Work

TSN uses Poseidon2 as its PoW hash function instead of SHA-256 (Bitcoin) or RandomX (Monero):

  • ZK-native: Same hash for mining AND shielded transaction proofs (Plonky3 STARKs). One hash for the entire stack.
  • Post-quantum friendly: Algebraic hashes over large fields resist Grover's algorithm.
  • ASIC-resistant: Field arithmetic is complex enough that ASICs offer limited advantage over CPUs.

How Mining Works

1. Build block template (transactions + coinbase)
2. Generate random 512-bit nonce
3. Hash: Poseidon2(header_fields, nonce) → 32 bytes
4. Check: first_8_bytes_as_u64 < (u64::MAX / difficulty)
5. Valid → broadcast block. Invalid → new nonce.

Hashrate Benchmarks

CPU Threads Hashrate
EPYC 7742 1T 121 KH/s
EPYC 7742 4T 257 KH/s
EPYC 7742 8T 454 KH/s
Xeon E5-2697A v4 2T ~80 KH/s

Note: Poseidon2 hashrates are not comparable to SHA-256 or RandomX. Different hash functions have different work-per-hash. TSN's difficulty adjusts via LWMA (45-block window) to target 10-second blocks.

Network Hashrate Formula

network_hashrate = difficulty / block_time

Displayed in the explorer and /chain/info API.

Smart Contracts

TSN includes a stack-based zkVM with gas metering and ZK execution traces:

  • 30+ opcodes: arithmetic, storage, memory, crypto (Poseidon hash, signature verify), control flow, events
  • Contract templates: Escrow (with arbitration & timeout), Multisig (N-of-M), AMM Pool, Governance
  • Gas model: per-opcode costs, block gas limit 1M, max 64KB bytecode, 100K storage slots

Network Parameters

Parameter Value
Default Port 9333
Block Reward 50 TSN (92% miner, 5% dev fees, 3% relay pool)
Halving Interval 4,200,000 blocks (~16 months)
Target Block Time ~10 seconds
Difficulty Adjustment LWMA per-block (N=45 window)
P2P Protocol libp2p GossipSub mesh (D=6, heartbeat 700ms)
Max Reorg Depth 100 blocks
Min Difficulty 1000
Nonce Size 512 bits
Max TX Size 1 MB
Max Supply ~420,000,000 TSN (~10 years to reach)

Synchronization & Anti-Fork System

Fast-Sync Protocol

New nodes join the network in seconds by downloading a compressed state snapshot:

┌─────────────┐     GET /snapshot/info      ┌─────────────┐
│  New Node   │ ──────────────────────────>  │  Seed Node  │
│             │     GET /snapshot/download   │             │
│  --fast-sync│ <────────────────────────── │  (gzip)     │
│             │                              │             │
│  Load state │     GET /blocks?from=N       │             │
│  Sync rest  │ ──────────────────────────>  │             │
└─────────────┘                              └─────────────┘
  1. New node requests a gzip-compressed state snapshot from a peer
  2. Loads the snapshot and verifies state_root integrity
  3. Syncs only the missing blocks since the snapshot height
  4. Ready to mine in ~2 seconds

Anti-Fork Protections

Protection Description
Heaviest chain rule Fork choice based on cumulative work, not height
MAX_REORG_DEPTH = 100 Hard limit — no reorg deeper than 100 blocks
Checkpoint finality Every 100 blocks, a checkpoint is created
Fork ID verification Genesis hash checked at sync — prevents silent splits
Anchor block filter Blocks must reference a recent valid ancestor
P2P version gate Disconnect peers below MINIMUM_VERSION

Testnet Status

The private testnet is live with 5 nodes and 29,000+ blocks mined.

TSN tokens currently have no value. The testnet is for development and testing only. Tokens can be mined for free by anyone running a node. Economic value will only be introduced at the incentivized testnet phase.

Roadmap:

  1. Private Testnet — Active now. Internal testing and development.
  2. Open Testnet — Code on GitHub. Anyone can run a node and mine. No value.
  3. Incentivized Testnet — Rewards for miners and node operators. Tokens begin to have value.
  4. Mainnet — Genesis block. Fair launch. No premine.

Roadmap

Phase 1 — Foundations ✅

Core blockchain engine: blocks, transactions, UTXO, Poseidon2 hashing, ML-DSA-65 signatures, Proof of Work consensus with MIK anti-Sybil, P2P networking with Kademlia DHT, SledDB storage, shielded wallet, REST API, block explorer, and testnet faucet.

Phase 2 — Advanced Features ✅

Multi-role nodes (Miner, Relay, Light Client), Plonky3 STARK migration (AIR-based proofs via p3-uni-stark), enhanced shielded wallet with BIP39 recovery and viewing keys, hardened fast-sync with state_root verification, security audit (8.1/10 score).

Phase 3 — Smart Contracts & DeFi ✅

zkVM (30+ opcodes), contract templates (Escrow, Multisig, AMM Pool, Governance), stablecoin module (ZST — gold-backed), P2P auto-update system.

Phase 4 — Launch

┌──────────────────────────────────────────────────────────────────┐
│                                                                  │
│  APRIL 2026          MAY — JULY 2026            Q3 2026          │
│                                                                  │
│  ┌──────────┐        ┌──────────────────┐       ┌────────────┐  │
│  │ PRIVATE  │───────>│   INCENTIVIZED   │──────>│  MAINNET   │  │
│  │ TESTNET  │        │  PUBLIC TESTNET  │       │  LAUNCH    │  │
│  └──────────┘        └──────────────────┘       └────────────┘  │
│                                                                  │
│  • 5 internal nodes   • Open to everyone        • Genesis block  │
│  • Stress testing     • Bug bounty program      • Fair launch    │
│  • Core validation    • Node operator rewards   • No premine     │
│  • ZK proof testing   • Security audit          • Full privacy   │
│                       • 2-3 months duration     • zkVM live      │
│                                                                  │
└──────────────────────────────────────────────────────────────────┘

Ecosystem

TSN is more than a blockchain — it's a full ecosystem of decentralized applications.

Whispr — Decentralized Private Social Network (v0.4.0, Live)

A peer-to-peer social network with zero tracking, no email/phone required, and end-to-end encrypted messaging. Think Discord + Twitter + Medium, but decentralized and private.

ZST — Gold-Backed Stablecoin (In Development)

A stablecoin pegged to gold (1 ZST = 1g XAU), over-collateralized in TSN. Djed/Zephyr-inspired reserve model with stress fees, circuit breaker, and oracle price feeds.

  • 3 assets: TSN (collateral) → ZST (stablecoin) + ZRS (reserve share)
  • Reserve engine: 76 tests passing, mint/burn with dynamic fees
  • Protections: stress fees 0.3%-5%, circuit breaker at 120%, cooldown mechanism

NetherSwap — Decentralized Exchange (In Development)

A cross-chain anonymous DEX built on TSN with AMM pools, escrow P2P, yield farming, governance DAO, and prediction markets.

  • AMM Swap with smart router (multi-hop), limit orders
  • Liquidity Pools with yield farming rewards
  • P2P Escrow for trustless OTC trades
  • DAO Governance — community-driven proposals and voting
  • Cross-chain — relayers staked in TSN
  • Privacy — anonymous trading via TSN shielded transactions

Changelog

v1.3.0 — Chain Reset, Halving Fix & Sync Stability

  • Halving interval: 210,000 → 4,200,000 blocks (~16 months per halving, supply max in ~10 years)
  • Chain reset: fresh genesis block with correct economics
  • Critical fix: rollback canonical_height bug causing infinite sync loops
  • P2P Auto-Update: nodes detect + download + verify + self-update
  • Explorer URL: points to explorer.tsnchain.com
  • Default mode: ./tsn auto-creates wallet and mines (no subcommand needed)
  • Verification keys: searched next to binary + parent dirs (build from source works)
  • Firewall: port 9333 open on all nodes for HTTP sync

v1.1.0 — Performance & Production Hardening

Feature Before After
Mining Hot Loop Full header rebuilt per hash MiningHashContext — zero heap alloc
Hashrate Display Truncated hash, no KH/s Real-time KH/s, full hash
Explorer Hashrate Wrong formula Corrected: difficulty / block_time
Wallet TX History Not saved Sent + received persisted (WalletTxRecord)
Received TX Detection Manual Automatic at wallet scan
Nullifier Check At send only At scan + send (prevents double-spend)
P2P Version Gate Accept all peers Disconnect peers below MINIMUM_VERSION
CLI Multiple flags required ./tsn miner -t 4 — everything auto-detected
Auto-Update None P2P signaling + multi-source download + SHA256 verification

v0.8.0 — Transactions, Wallet & Security

  • Working V2 shielded transactions (create, sign, broadcast, validate)
  • Interactive wallet menu with BIP39 recovery
  • MAX_REORG_DEPTH = 100, Fork ID verification, anchor block filtering
  • Dual mining across multiple nodes

v0.7.1 — Security Audit & Hardening

Full security audit: 29 findings, 23 fixes applied. Score: 5.4/10 → 8.1/10. Zero critical vulnerabilities remaining.

v0.7.0 — Scaling & Reliability

  • LWMA per-block difficulty adjustment (N=45 window)
  • GossipSub mesh P2P (replaced flood protocol)
  • Cryptographic random nonces (zero miner collisions)
  • Concurrent block relay, canonical height in DB

v0.6.0 — Major Network Upgrade

  • Numeric difficulty system with 512-bit nonce
  • Poseidon2 PoW (plonky3)
  • Fast sync (~2 seconds)
  • BIP39 wallet recovery
  • DNS seed discovery
  • Chain Watchdog monitoring

Codebase

Metric Value
Language Rust 2021 edition
Lines of code 94,000+
Source files 298
Tests 369 passing
Commits 32+
Nodes 5 (1 miner + 4 seeds)

API

Endpoint Description
GET /chain/info Block height, difficulty, latest hash, version
GET /peers Connected peers
GET /sync/status Sync progress and peer count
GET /block/height/:n Get block by height
POST /tx/submit Submit shielded transaction
GET /explorer Built-in block explorer
GET /version.json Node version info (used by auto-update)

Links

License

MIT — Open source.

About

Post-quantum privacy blockchain — Proof of Work · Plonky3 STARKs · ML-DSA-65 · Poseidon2 PoW · Shielded Transactions · P2P Auto-Update · 94k+ lines of Rust

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages