{"id":27000078,"url":"https://github.com/arec1b0/blockchain-on-java","last_synced_at":"2025-04-04T03:18:45.365Z","repository":{"id":248193887,"uuid":"828028754","full_name":"arec1b0/blockchain-on-java","owner":"arec1b0","description":"A Java-based blockchain implementation featuring Proof of Work (PoW) and Proof of Stake (PoS) consensus mechanisms.","archived":false,"fork":false,"pushed_at":"2024-09-10T00:09:20.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-20T23:33:59.133Z","etag":null,"topics":["blockchain","cryptography","decentralized","java","proof-of-stake","proof-of-work"],"latest_commit_sha":null,"homepage":"https://github.com/dkrizhanovskyi/blockchain-on-java","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arec1b0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-12T23:35:40.000Z","updated_at":"2024-09-10T00:11:45.000Z","dependencies_parsed_at":"2024-07-15T18:47:09.511Z","dependency_job_id":"b045a65a-51e4-439a-bc91-4a579a22a6f1","html_url":"https://github.com/arec1b0/blockchain-on-java","commit_stats":null,"previous_names":["dkrizhanovskyi/blockchain-on-java","arec1b0/blockchain-on-java"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arec1b0%2Fblockchain-on-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arec1b0%2Fblockchain-on-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arec1b0%2Fblockchain-on-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arec1b0%2Fblockchain-on-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arec1b0","download_url":"https://codeload.github.com/arec1b0/blockchain-on-java/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247112873,"owners_count":20885622,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","cryptography","decentralized","java","proof-of-stake","proof-of-work"],"created_at":"2025-04-04T03:18:44.873Z","updated_at":"2025-04-04T03:18:45.355Z","avatar_url":"https://github.com/arec1b0.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blockchain-on-Java\n\n### Version: 1.1.0  \n**Author**: Daniil Krizhanovskiyi  \n**Date**: September 2024  \n\n## Project Overview\n\nBlockchain-on-Java is a basic blockchain system built using Java. The project supports two consensus algorithms: **Proof of Work (PoW)** and **Proof of Stake (PoS)**. The blockchain is decentralized, allowing multiple nodes to communicate through a peer-to-peer (P2P) network, propagate blocks, and process transactions securely.\n\n---\n\n## Project Structure\n\nThe project follows a modular architecture adhering to **SOLID** principles for maintainability and scalability.\n\n```bash\nblockchain-on-java\n├── pom.xml                  # Maven configuration file\n├── README.md                # Project documentation\n├── src\n│   ├── main\n│   │   └── java\n│   │       └── com\n│   │           └── example\n│   │               └── blockchain\n│   │                   ├── blockchain\n│   │                   │   ├── Block.java        # Core blockchain block class\n│   │                   │   ├── Blockchain.java   # Blockchain management class\n│   │                   ├── consensus\n│   │                   │   ├── Consensus.java    # Consensus algorithm interface\n│   │                   │   ├── PoWConsensus.java # Proof of Work consensus implementation\n│   │                   │   ├── PoSConsensus.java # Proof of Stake consensus implementation\n│   │                   ├── cryptography\n│   │                   │   ├── CryptoUtil.java   # Utility for cryptographic functions (signing, hashing)\n│   │                   │   ├── StringUtil.java   # SHA-256 hashing utility\n│   │                   ├── network\n│   │                   │   ├── Node.java         # Peer-to-peer node implementation\n│   │                   │   ├── P2PNetwork.java   # Network management for nodes\n│   │                   ├── transactions\n│   │                   │   ├── Transaction.java  # Transaction representation\n│   └── test\n│       └── java\n│           └── com\n│               └── blockchain\n│                   ├── BlockTest.java            # Unit tests for the Block class\n│                   ├── BlockchainTest.java       # Unit tests for the Blockchain class\n│                   ├── ConsensusTest.java        # Unit tests for PoW and PoS consensus mechanisms\n│                   ├── TransactionTest.java      # Unit tests for the Transaction class\n```\n\n---\n\n## Core Components\n\n### 1. **Blockchain**\nThe `Blockchain.java` class manages the blockchain, which includes adding blocks, validating the chain's integrity, and mining blocks according to the consensus algorithm in use.\n\n### 2. **Block**\nThe `Block.java` class represents a block in the blockchain. It contains:\n- A list of transactions.\n- A timestamp.\n- A nonce for mining.\n- A hash generated using **SHA-256**.\n\n### 3. **Transactions**\nThe `Transaction.java` class represents a transaction between two entities in the blockchain. It includes:\n- **Sender**: The sender's address.\n- **Recipient**: The recipient's address.\n- **Amount**: The value being transferred.\n\n---\n\n## Consensus Mechanisms\n\n### 1. **Proof of Work (PoW)**\n`PoWConsensus.java` implements the Proof of Work algorithm. Miners must solve a cryptographic puzzle to create a new block by finding a nonce that satisfies the block's hash difficulty.\n\n### 2. **Proof of Stake (PoS)**\n`PoSConsensus.java` implements the Proof of Stake algorithm, where validators are selected to mine blocks based on the amount of cryptocurrency they hold (their stake).\n\n---\n\n## Cryptography\n\n### 1. **SHA-256 Hashing**\n`StringUtil.java` provides SHA-256 hashing functionality used to generate block and transaction hashes.\n\n### 2. **Digital Signatures**\n`CryptoUtil.java` implements digital signatures using RSA, allowing transactions to be securely signed by the sender and verified by others.\n\n---\n\n## Peer-to-Peer (P2P) Network\n\n### 1. **Node**\n`Node.java` represents a node in the blockchain's P2P network. Nodes can:\n- Connect to peer nodes.\n- Broadcast transactions and blocks.\n- Receive transactions and blocks from other nodes.\n\n### 2. **P2PNetwork**\n`P2PNetwork.java` manages the decentralized network of nodes, allowing them to communicate and synchronize the blockchain.\n\n---\n\n## Installation and Setup\n\n### 1. **Prerequisites**\n- **Java 17** or later\n- **Maven** for dependency management\n\n### 2. **Build the Project**\nTo build the project, run the following command:\n```bash\nmvn clean install\n```\n\n### 3. **Run the Application**\nTo run the blockchain simulation, navigate to `Blockchain.java` in the `src/main/java/com/example/blockchain/blockchain/` directory and execute it.\n\n---\n\n## Running Tests\n\nThe project includes comprehensive unit tests to ensure correctness. Tests cover blockchain functionality, consensus mechanisms, transaction handling, and networking.\n\nTo run the tests:\n```bash\nmvn test\n```\n\n---\n\n## Future Enhancements\n\n### 1. **Smart Contracts**\nImplement smart contracts on top of the blockchain for automated execution of agreements.\n\n### 2. **Scalability**\nIntroduce Layer-2 solutions, such as sharding, to improve the scalability of the blockchain.\n\n### 3. **Zero-Knowledge Proofs (ZKP)**\nAdd ZKPs to improve privacy and allow for the validation of transactions without revealing details.\n\n---\n\n## Conclusion\n\nBlockchain-on-Java is a foundational project designed to demonstrate core blockchain principles. It can be extended with advanced features such as smart contracts, dynamic consensus adjustments, and improved cryptography to support real-world use cases.\n\n---\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farec1b0%2Fblockchain-on-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farec1b0%2Fblockchain-on-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farec1b0%2Fblockchain-on-java/lists"}