A custom-built digital cryptocurrency inspired by Bitcoin's architecture, engineered with enhanced security features to improve transaction integrity and network resilience. Designed for decentralized use with a focus on robust encryption and tamper-proof ledger management.
- Quantum-Resistant Cryptography: Implements lattice-based cryptographic algorithms alongside classical ECDSA
- Hybrid Signature System: Combines classical and quantum-resistant signatures for maximum security
- Multi-Signature Wallets: Support for M-of-N multi-signature transactions
- Zero-Knowledge Proofs: Privacy-preserving transaction validation
- Advanced Encryption: AES-256-GCM for data encryption with secure key derivation
- BFT Consensus Mechanism: Tolerates up to 1/3 Byzantine validators
- Validator Slashing: Automatic penalty system for malicious behavior
- Finality Guarantees: Immediate transaction finality with 2/3+ validator agreement
- Reputation System: Dynamic validator reputation based on performance
- Liveness Monitoring: Automatic detection and handling of inactive validators
- Anti-ASIC Mining: Memory-hard hashing algorithms to promote decentralization
- Dynamic Difficulty Adjustment: Automatic difficulty adjustment based on block times
- Mining Pools: Built-in support for collaborative mining
- Progressive Hashing: Multi-round hashing with increasing complexity
- Reward Distribution: Fair reward distribution based on contribution
- Hierarchical Deterministic (HD) Wallets: BIP32-compatible wallet derivation
- Hardware Wallet Support: Secure hardware wallet integration
- Multi-Signature Wallets: Enterprise-grade multi-party transaction approval
- Wallet Backup & Recovery: Secure mnemonic-based backup system
- Transaction History: Comprehensive transaction tracking and analysis
- Secure Virtual Machine: Gas-metered execution environment
- Security Validation: Automatic detection of dangerous code patterns
- Reentrancy Protection: Built-in protection against reentrancy attacks
- Gas Mechanism: Comprehensive gas system for resource management
- Contract Templates: Pre-built contracts for common use cases
- P2P Network: Decentralized peer-to-peer communication
- DHT Integration: Distributed hash table for peer discovery
- Message Encryption: End-to-end encrypted peer communication
- Anti-Spam Measures: Rate limiting and message validation
- Bootstrap Nodes: Automatic network bootstrapping
- JWT Authentication: Secure token-based authentication
- API Key Management: Granular API access control
- Rate Limiting: Comprehensive rate limiting system
- Input Validation: Strict input sanitization and validation
- Security Headers: OWASP-compliant security headers
- Python 3.8 or higher
- PostgreSQL 12+ (optional, SQLite for development)
- Redis (optional, for production caching)
-
Clone the repository:
git clone https://github.com/MugishaProsper/PoloCoin.git cd PoloCoin -
Create virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set environment variables:
export POLOCOIN_ENV=development export DB_HOST=localhost export DB_NAME=polocoin
-
Initialize the database:
python -c "from src.utils.Database import Database; Database.initialize_sqlite()" -
Start the API server:
python src/app/api.py
curl -X POST http://localhost:8080/api/v1/auth/create-api-key \
-H "Content-Type: application/json" \
-d '{"name": "My API Key"}'curl -X POST http://localhost:8080/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": "secure_password"}'curl http://localhost:8080/api/v1/blockchain/infocurl -X POST http://localhost:8080/api/v1/transactions \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"sender": "sender_address",
"recipient": "recipient_address",
"amount": 100,
"signature": "transaction_signature"
}'curl -H "X-API-Key: your_api_key" \
http://localhost:8080/api/v1/wallet/balance/${wallet_address}curl -X POST http://localhost:8080/api/v1/staking/stake \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{"sender": "staker_address", "amount": 1000}'from src.blockchain.wallet import WalletManager
# Create wallet manager
wallet_manager = WalletManager()
# Create different types of wallets
standard_wallet_id = wallet_manager.create_wallet("standard", initial_balance=1000)
hd_wallet_id = wallet_manager.create_wallet("hd")
multisig_wallet_id = wallet_manager.create_wallet(
"multisig",
required_signatures=2,
total_signers=3,
signers=["signer1", "signer2", "signer3"]
)
# Get wallet instance
wallet = wallet_manager.get_wallet(standard_wallet_id)
# Create transaction
transaction = wallet.create_transaction("recipient_address", 100)from src.app.mining import SecureMiner, MiningManager
from src.blockchain.blockchain import Blockchain
# Initialize components
blockchain = Blockchain()
mining_manager = MiningManager()
# Register miner
miner = mining_manager.register_miner("miner_001", "reward_address")
# Start mining
success = miner.start_mining(blockchain, num_threads=4)
if success:
print("Mining started successfully")python -m pytest tests/ -vpython -m pytest tests/test_security.py -vpython -m pytest tests/test_integration.py -v- Quantum Resistance: Future-proof against quantum computer attacks
- Hybrid Signatures: Combines ECDSA with lattice-based signatures
- Multi-Signature: Requires multiple signatures for high-value transactions
- Zero-Knowledge Proofs: Privacy-preserving transaction validation
- Secure Random Generation: Cryptographically secure randomness for all operations
- Byzantine Fault Tolerance: Handles up to 1/3 malicious validators
- Validator Slashing: Economic penalties for malicious behavior
- Double-Signing Detection: Automatic detection of conflicting signatures
- Finality Guarantees: Immediate transaction finality with sufficient votes
- Liveness Monitoring: Ensures network progress even with offline validators
- Message Encryption: All peer communications are encrypted
- Rate Limiting: Protection against spam and DoS attacks
- Input Validation: Comprehensive validation of all network messages
- Peer Authentication: Cryptographic peer identity verification
- Anti-Sybil Measures: Protection against Sybil attacks
- JWT Authentication: Secure token-based authentication
- API Key Management: Granular access control with rate limits
- Input Sanitization: Protection against injection attacks
- CORS Protection: Cross-origin request security
- Security Headers: OWASP-compliant HTTP security headers
- Transaction Throughput: 1,000+ transactions per second
- Block Time: 10-second average block confirmation
- Network Latency: Sub-second transaction propagation
- Memory Usage: Optimized for low memory footprint
- Storage Efficiency: Compressed blockchain storage
- Horizontal Scaling: Support for multiple validator nodes
- Sharding Ready: Architecture prepared for future sharding implementation
- Layer 2 Compatible: Ready for Lightning Network-style payment channels
- State Pruning: Automatic pruning of old blockchain state
- Efficient Sync: Fast blockchain synchronization for new nodes
This project follows PEP 8 style guidelines:
black src/ tests/ # Format code
flake8 src/ tests/ # Check style
mypy src/ # Type checking- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
PoloCoin supports multiple environments with different configurations:
- Development: SQLite database, reduced security for testing
- Testing: In-memory database, fast block times
- Production: PostgreSQL database, full security features
Key security parameters can be configured in config.py:
class SecurityConfig:
ENABLE_QUANTUM_RESISTANCE = True
MULTI_SIGNATURE_THRESHOLD = 2
MAX_TRANSACTION_SIZE = 1024 * 1024 # 1MB
MIN_TRANSACTION_FEE = 0.0001
RATE_LIMIT_REQUESTS = 100 # per minutecurl http://localhost:8080/api/v1/healthcurl -H "X-API-Key: your_api_key" http://localhost:8080/api/v1/mining/statsDatabase Connection Errors
# Initialize database
python -c "from src.utils.Database import Database; Database.ensure_schema()"Mining Not Starting
# Check mining configuration
python -c "from config import config; print(config.mining.__dict__)"This project is licensed under the MIT License.
- Quantum-resistant cryptography
- Byzantine fault tolerant consensus
- Enhanced wallet security
- Smart contract platform
- Secure API implementation
- Advanced peer discovery
- Network partition recovery
- Cross-chain compatibility
- Sharding implementation
- State channels
- Zero-knowledge rollups
Made with π by Mugisha Prosper