Blockchain Concepts
Cryptographic Security
Ensures transaction integrity and wallet security using elliptic curve cryptography.
Implementation
Implemented in lib/wallet.ts (key pair generation, transaction signing) and lib/cryptoUtil.ts (hashing). Uses ECDSA for signing transactions.
Visual Breakdown
Distributed Ledger
A decentralized record of all transactions maintained across nodes.
Implementation
Managed in lib/blockchain.ts (chain array) and persisted via prisma/schema.prisma. Nodes sync via /api/blockchain/receive.
Visual Breakdown
Consensus Algorithm
Uses Proof-of-Work to agree on the valid chain state.
Implementation
Implemented in lib/block.ts (mineBlock method) and lib/blockchain.ts (difficulty adjustment).
Visual Breakdown
Immutable Records
Ensures blocks cannot be altered once added to the chain.
Implementation
Enforced in lib/blockchain.ts (isChainValid method) by checking hash integrity and previousHash links.
Visual Breakdown
Smart Contracts
Programmable logic to automate transactions (placeholder for future implementation).
Implementation
Not yet implemented. Planned for lib/contract.ts and execution in transactions.
Visual Breakdown
Peer-to-Peer Network
Nodes communicate to share blocks and transactions.
Implementation
Managed in lib/blockchain.ts (peers Set, broadcastBlock) and api/peers/add.ts, api/peers/list.ts endpoints.