README
ΒΆ
Veritas Chain (In Progress) πβοΈ
A Blockchain-Based Academic Credential Verification System
Overview
Veritas Chain is a proof-of-authority blockchain system designed specifically for secure academic credential verification among universities. The system ensures data integrity through cryptographic signatures, maintains privacy through hashed certificate IDs, and provides verifiable authenticity through university-signed blocks using ECDSA cryptography.
The project features a comprehensive CLI interface for node management, identity generation, and interactive blockchain operations.
Inspired by(stole) my boss's vision for blockchain-based credential verification - thank you!
Key Features
- π Privacy-First Design: Certificate data is cryptographically hashed before blockchain storage
- ποΈ Proof-of-Authority: Only authorized universities can create and sign blocks
- π ECDSA Cryptography: Blocks signed with university private keys using P-256 elliptic curves
- π€ University Identity System: Authorized universities (Harvard, MIT, Stanford, Yale) with persistent identities
- β‘ Fast Verification: Instant block and signature verification
- π Tamper-Proof Records: Immutable blocks with cryptographic signatures
- πΎ Persistent Storage: BadgerDB for efficient blockchain data persistence
- π‘οΈ Signature Validation: Real-time verification of block signatures
- π₯οΈ CLI Interface: Comprehensive command-line interface for node management and operations
- π§ Interactive Mode: Real-time blockchain interaction through terminal commands
- π Merkle Trees: Efficient certificate verification with Merkle proof generation
- π Chain Validation: Comprehensive blockchain integrity validation
Quick Start
Prerequisites
- Go 1.25+ installed
- Git for version control
- Basic understanding of blockchain concepts
Installation
# Clone the repository
git clone https://github.com/amanechibana/veritas-chain.git
cd veritas-chain
# Install dependencies
go mod tidy
# Build the CLI tool
go build -o veritas .
Basic Usage
1. Generate a Signer Key
# Generate a new P-256 private key for your node
./veritas identity keygen
# Output example:
# Generated signer key:
# SIGNER_PRIVATE_KEY_HEX=1234567890abcdef...
# Address=1H8vrviwK5Ep83sDkP8m8XsYpprVNiB8dU
2. Set Environment Variables
# Set your private key (use the output from keygen)
export SIGNER_PRIVATE_KEY_HEX=1234567890abcdef...
# Optional: Set authorized signers file
# cp authorized_signers.json.example authorized_signers.json
3. Start Interactive Node
# Start the node in interactive mode
./veritas node interactive
# This will:
# 1. Load your signer from environment
# 2. Initialize or load existing blockchain
# 3. Start interactive terminal for blockchain operations
4. Interactive Commands
veritas> help # Show available commands
veritas> add CERT-001,CERT-002 # Add certificates to new block
veritas> list # List all blocks
veritas> validate # Validate blockchain integrity
veritas> stats # Show blockchain statistics
veritas> exit # Exit interactive mode
CLI Commands
Identity Management
# Generate a new P-256 private key
./veritas identity keygen
# Output:
# Generated signer key:
# SIGNER_PRIVATE_KEY_HEX=1234567890abcdef...
# Address=1H8vrviwK5Ep83sDkP8m8XsYpprVNiB8dU
Node Management
# Start node in interactive mode
./veritas node interactive
# Global flags available for all commands:
./veritas --verbose --config /path/to/config.yaml node interactive
Interactive Commands
Once in interactive mode (./veritas node interactive), you can use:
# Add certificates to a new block
veritas> add CERT-001,CERT-002,CERT-003
# List all blocks in the chain
veritas> list
# Validate the entire blockchain
veritas> validate
# Show blockchain statistics
veritas> stats
# Show help
veritas> help
# Exit interactive mode
veritas> exit
Environment Variables
# Required: Your private key (from identity keygen)
export SIGNER_PRIVATE_KEY_HEX=1234567890abcdef...
# Optional: Configuration file path
export VERITAS_CONFIG=/path/to/config.yaml
# Optional: Database path override
export VERITAS_DB_PATH=/custom/db/path
Example Output
1. Generate Signer Key
$ ./veritas identity keygen
Generated signer key:
SIGNER_PRIVATE_KEY_HEX=1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
Address=1H8vrviwK5Ep83sDkP8m8XsYpprVNiB8dU
2. Start Interactive Node
$ export SIGNER_PRIVATE_KEY_HEX=1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
$ ./veritas node interactive
Configuration:
Address: 1H8vrviwK5Ep83sDkP8m8XsYpprVNiB8dU
DB Path: ./tmp/blocks_1H8vrviwK5Ep83sDkP8m8XsYpprVNiB8dU
Resolved Name: harvard
Created new blockchain with genesis block
=== Veritas Chain Interactive Mode ===
Type 'help' for available commands
Signer Address: 1H8vrviwK5Ep83sDkP8m8XsYpprVNiB8dU
=====================================
3. Interactive Commands
veritas> add CERT-001,CERT-002,CERT-003
Block added successfully!
Height: 1
Hash: da0d5b2cf6823599657599319ce3d8cba595fed6bbeab37bfd4799178d4f20eb
Address: 1H8vrviwK5Ep83sDkP8m8XsYpprVNiB8dU
veritas> list
Blockchain:
Block 0: Height=0, Hash=6d72c343fd0e485d977d60702cb61b41a70be3820d219c1a39c5da01418fb71c, Address=1H8vrviwK5Ep83sDkP8m8XsYpprVNiB8dU
Block 1: Height=1, Hash=da0d5b2cf6823599657599319ce3d8cba595fed6bbeab37bfd4799178d4f20eb, Address=1H8vrviwK5Ep83sDkP8m8XsYpprVNiB8dU
veritas> validate
Chain validation successful
veritas> stats
Blockchain Statistics:
Total Blocks: 2
Total Certificates: 3
veritas> exit
Goodbye!
Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Veritas Chain Node β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββ βββββββββββββββ β
β β CLI β β Interactive β β
β β Interface β β Mode β β
β ββββββββ¬βββββββ ββββββββ¬βββββββ β
β β β β
β ββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββΌββββββββββββββββββββββββ β
β β Blockchain Core β β
β β βββββββββββββββ βββββββββββββββ β β
β β β Block β β Merkle β β β
β β β Management β β Trees β β β
β β βββββββββββββββ βββββββββββββββ β β
β β βββββββββββββββ βββββββββββββββ β β
β β β Proof β β Validation β β β
β β β of Authorityβ β Engine β β β
β β βββββββββββββββ βββββββββββββββ β β
β βββββββββββββββββββββββββ¬ββββββββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββΌββββββββββββββββββββββββ β
β β Identity System β β
β β βββββββββββββββ βββββββββββββββ β β
β β β Signer β β Registry β β β
β β β Management β β (JSON) β β β
β β βββββββββββββββ βββββββββββββββ β β
β βββββββββββββββββββββββββ¬ββββββββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββΌββββββββββββββββββββββββ β
β β Storage Layer β β
β β βββββββββββββββ βββββββββββββββ β β
β β β BadgerDB β β File β β β
β β β (Blocks) β β System β β β
β β βββββββββββββββ βββββββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Future Multi-Node Network β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β Harvard β β MIT β β Stanford β β
β β Node βββββΊβ Node βββββΊβ Node β β
β β β β β β β β
β β βββββββββββ β β βββββββββββ β β βββββββββββ β β
β β β gRPC β β β β gRPC β β β β gRPC β β β
β β β Server β β β β Server β β β β Server β β β
β β βββββββββββ β β βββββββββββ β β βββββββββββ β β
β β βββββββββββ β β βββββββββββ β β βββββββββββ β β
β β β gRPC β β β β gRPC β β β β gRPC β β β
β β β Client β β β β Client β β β β Client β β β
β β βββββββββββ β β βββββββββββ β β βββββββββββ β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Project Structure
veritas-chain/
βββ blockchain/ # Core blockchain implementation
β βββ block.go # Block structure and operations
β βββ blockchain.go # Blockchain management and validation
β βββ merkle.go # Merkle tree implementation
β βββ proof.go # Proof-of-authority consensus
βββ cmd/ # CLI command implementations
β βββ root.go # Root command and global flags
β βββ node.go # Node management commands
β βββ identity.go # Identity and key management
βββ identity/ # University identity system
β βββ identity.go # Identity structure and cryptography
β βββ registry.go # Identity registry management
β βββ signer.go # Signer interface and implementations
β βββ utils.go # Serialization and utility functions
βββ test/ # Test utilities and examples
β βββ test_client.go # Test client utilities
βββ tmp/ # Runtime data storage
β βββ blocks_*/ # BadgerDB blockchain data (per signer)
βββ authorized_signers.json # Authorized university mappings
βββ main.go # Main application entry point
βββ go.mod # Go module dependencies
βββ README.md # This file
Blockchain Features
- Proof-of-Authority Consensus: Only authorized universities can create blocks
- ECDSA P-256 Signatures: 64-byte signatures for block authentication
- BadgerDB Storage: High-performance key-value database for blockchain data
- Chain Validation: Comprehensive validation of block integrity and signatures
- Identity Persistence: JSON-based university identity storage
Security Features
- Cryptographic Hashing: SHA-256 for certificate ID hashing
- Digital Signatures: ECDSA for block authentication
- Private Key Security: In-memory private key management
- Signature Verification: Real-time validation of block signatures
- Tamper Detection: Any modification breaks signature validation
Current Capabilities
- Create and manage university identities
- Generate genesis blocks with university signatures
- Add blocks with certificate data
- Verify block signatures in real-time
- Persist blockchain data across sessions
- Validate entire blockchain integrity
Development
Running Tests
# Run all tests
go test ./...
# Run with verbose output
go test -v ./...
# Run specific package tests
go test ./blockchain
go test ./identity
go test ./server
Building
# Build the CLI application
go build -o veritas .
# Run the built binary
./veritas --help
# Build with specific Go version
GO_VERSION=1.25 go build -o veritas .
Generating Protocol Buffers
# Install protoc and Go plugins (if not already installed)
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
# Generate Go code from proto files
protoc --go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
proto/blockchain.proto
Dependencies
- BadgerDB: High-performance key-value database for blockchain storage
- Base58: Address encoding/decoding for university identities
- Cobra: CLI framework for command-line interface
- gRPC: High-performance RPC framework for API services
- Protocol Buffers: Language-neutral data serialization
- Go Standard Library: Cryptography and utilities
Current State vs Final Vision
Current Implementation
CLI-Enabled Single-Node Proof-of-Authority Blockchain
- β CLI Interface: Full command-line interface with interactive mode
- β Identity Management: P-256 key generation and signer management
- β Merkle Trees: Efficient certificate verification with proof generation
- β Persistent Storage: BadgerDB with per-signer database isolation
- β Chain Validation: Comprehensive blockchain integrity validation
- β οΈ Single Node: Runs on a single machine (no networking yet)
- β οΈ Local Identities: University identities managed locally
Final Goal: Consortium Blockchain
Multi-Node Distributed Network
- π P2P Networking: Each university runs their own node with network communication
- π Distributed Consensus: Harvard, MIT, Stanford, Yale(For example) each host independent nodes
- π Block Propagation: gRPC-based block sharing across university network
- π True Distribution: Each university maintains their own copy of the blockchain
- π Network Discovery: Automatic peer discovery and connection management
TODO / Future Enhancements
Phase 1: Core Infrastructure β COMPLETED
- β Merkle Trees: Implement Merkle trees for efficient certificate verification
- β CLI Interface: Command-line interface for blockchain operations
- β Identity Management: P-256 key generation and signer management
- π Network Layer: Add P2P networking for multi-university consensus
- π Node Discovery: Implement network discovery and peer management
- π Block Propagation: Share blocks across university nodes
Phase 2: Consortium Features
- π gRPC API: Programmatic access through gRPC services for multi-node networking
- π Distributed Consensus: Multi-node agreement on blockchain state
- π Validator Rotation: Universities take turns creating blocks
- π Network Resilience: Handle node failures and network partitions
- π Cross-University Validation: Verify blocks from other universities
- π Peer-to-Peer Communication: gRPC-based node-to-node communication
Phase 3: Production Features
- π Web Interface: Web-based dashboard for university management or public certificate verification access
- π Certificate Standards: Support for standard academic credential formats (W3C Verifiable Credentials, etc.)
- π Monitoring & Metrics: Blockchain health monitoring and performance metrics
- π Backup & Recovery: Automated backup and disaster recovery procedures
Security Considerations
- Private Key Management: Private keys are managed through environment variables (
SIGNER_PRIVATE_KEY_HEX) - consider using secure key management systems (HSM, key vaults) for production - Database Security: BadgerDB files are stored locally - ensure proper file permissions and consider encryption at rest
- Network Security: Future network layer will require TLS encryption for gRPC communication
- Access Control: Role-based access control for university operations (planned for multi-node setup)
- Audit Logging: Comprehensive logging of all blockchain operations (enhanced logging planned)
- Signature Validation: All blocks are cryptographically signed and validated in real-time
- Chain Integrity: Comprehensive blockchain validation ensures tamper detection
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Inspired/Based on @TensorProgramming's guide to blockchain with golang on youtube
Veritas Chain - Truth in Education, Secured by Blockchain
Documentation
ΒΆ
There is no documentation for this package.