Enhancement: Implement binary Merkle tree root in Block header
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- java
- Domain
- blockchain, cryptography
Research direction
Start with Block.java, Transaction.java, Blockchain.java, and Main.java to trace how transaction data is hashed, addresses are assigned, and RSA keys sign transactions. Then review BlockchainTest.java and Storage.java for the affected behavior. Done means transaction hashes include all listed fields, blocks use a Merkle root, addresses derive from public keys, and signing uses Ed25519 with updated tests and storage.
Written by the indexing model from the issue text.
Description
Summary
The current cryptographic implementation and block hashing mechanisms in mini-chain rely on deprecated primitives (RSA-1024), fragile string formatting (toString()), and unverified string aliases.
This issue proposes modernizing the project's cryptographic and data architecture to reflect production blockchain standards while keeping zero external dependencies (leveraging native Java 17 features).
Current Problems & Proposed Solutions
1. Merkle Trees for Block Transactions
- Location:
Block.java - Current Behavior: Transactions are hashed using basic string concatenation:
String content = index + "|" + timestamp + "|" + previousHash + "|" + nonce + "|" + transactions; - Problem: Blocks do not use a cryptographic accumulator tree. This prevents demonstrating Merkle inclusion proofs and SPV (Simplified Payment Verification).
- Proposed Solution: Build a binary Merkle Tree from transaction hashes and store the resulting 32-byte
merkleRootin theBlockheader instead of concatenating transaction lists.
2. Decouple Block Hashing from Transaction.toString()
- Location:
Block.java&Transaction.java - Current Behavior: Concatenating
transactionsinvokesTransaction.toString(), which only returns:return from + " -> " + to + ": " + amount; - Problem: Crucial fields like
id,senderKey, andsignatureare completely excluded from the block hash. Modifying any of these fields on an existing transaction in a block leavesblock.computeHash()unchanged. - Proposed Solution: Introduce a deterministic
hash()method onTransactionthat hashes all fields (id,from,to,amount,senderKey,signature), and compute the block hash/Merkle root strictly from transaction hashes.
3. Cryptographic Address Derivation (Prevent Name Squatting)
- Location:
Blockchain.java - Current Behavior: The chain associates a human-readable string (e.g.
"asha") with the first public key seen inknownKeys:PublicKey known = knownKeys.get(tx.from()); if (known == null) { knownKeys.put(tx.from(), tx.senderKey()); } - Problem: Front-running vulnerability — anyone can claim and lock another user's name before that user broadcasts their first transaction.
- Proposed Solution: Derive user addresses directly from public keys (e.g., hex-encoded SHA-256 of the public key), decoupling identities from vulnerable arbitrary usernames.
4. Transition from RSA-1024 to Native Ed25519 Signatures
- Location:
Main.java,Transaction.java,BlockchainTest.java - Current Behavior: Uses
RSA1024-bit key pairs andSHA256withRSA. - Problem: RSA-1024 is cryptographically deprecated, produces large keys/signatures, and is not representative of modern blockchains.
- Proposed Solution: Migrate to Java 17’s native built-in
EdDSA(Ed25519) using:
This delivers compact 32-byte public keys and 64-byte signatures natively with zero third-party dependencies.KeyPairGenerator.getInstance("Ed25519"); Signature.getInstance("Ed25519");
Action Items
- Add
Transaction.hash()incorporating all record fields. - Implement binary Merkle Tree computation in
Blockand replacetransactionsincomputeHash()withmerkleRoot. - Migrate key generation and signing from RSA-1024 to standard Java 17
Ed25519. - Derive account addresses from public key hashes to eliminate name squatting.
- Update
BlockchainTest.javaandStorage.javato support the updated structure.
- Dominant language
- Java
- Stars
- 0
- Forks
- 3
- Avg merge
- 16h 38m
- Merged PRs (30d)
- 7
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from techcsispit/mini-chain
-
Tests: no test covers a payment of 0 or the genesis block meeting the difficultyPossibly taken @tanujb03 claimed this 5 days ago. Opengood first issue tests
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
techcsispit/mini-chain#23 ·
Maintainers usually reply within 1 day
-
README says changing Block or Transaction makes chain.dat stop loading, but adding a field or method still loads itPossibly taken @tanujb03 claimed this 5 days ago. Opendocumentation good first issue
Difficulty 1/5 Under an hour Newbie friendliness 25/100
techcsispit/mini-chain#21 ·
Maintainers usually reply within 1 day
-
BlockchainTest: signature tampering tests pass on the hash check; Block.mine() is a no-op so signature verification is not testedPossibly taken @tanujb03 claimed this 5 days ago. Opengood first issue tests
Difficulty 3/5 1-2 days Newbie friendliness 25/100
techcsispit/mini-chain#19 ·
Maintainers usually reply within 1 day
-
Blockchain: a payment that was already mined can be submitted again, and it is accepted and mined a second timePossibly taken @tanujb03 claimed this 5 days ago. Openbug good first issue
Difficulty 3/5 1-2 days Newbie friendliness 52/100
techcsispit/mini-chain#16 ·
Maintainers usually reply within 1 day
-
A signed payment can be altered (payee and amount) and still pass signature verificationPossibly taken @tanujb03 claimed this 5 days ago. Openadvanced bug
Difficulty 3/5 1-2 days Newbie friendliness 55/100
techcsispit/mini-chain#15 ·
Maintainers usually reply within 1 day
All issues in techcsispit/mini-chain
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
MCModderAnchor/TACZ#758 ·
-
agent-java community triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
elastic/apm-agent-java#4594 ·
Maintainers usually reply within 1 day
-
area/plugin good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
kestra-io/plugin-soda#137 ·
-
area/plugin good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
kestra-io/plugin-aws#816 ·
Maintainers usually reply within 2 days
-
area/plugin good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
kestra-io/plugin-kestra#200 ·
Maintainers usually reply within 1 day