Enhancement: Deterministic transaction hashing across all record fields
メンテナーはふだん 1 日以内に返信
@sohanjadyal がすでに取り組んでいます。
2026年10月15日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 74/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- java
- 領域
- blockchain
調査の方向性
src/main/java/minichain/Transaction.java の Transaction.toString()(49〜52行目付近)と、src/main/java/minichain/Block.java の Block.computeMerkleRoot() 内のリーフのループ(37〜39行目付近)から始めてください。Transaction に、レコードの各フィールドをダイジェスト化する hash() メソッドを追加し、その後リーフがそれを使うように変更します。BlockchainTest.java に、フィールドごとに1つずつハッシュが変わることを示すケースを追加し、既存のテストが固定の Merkle ルートをアサートしていないか確認してください。mvn clean test が通り、issue の受け入れ基準を満たしていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
Currently, Transaction does not have a dedicated cryptographic hash method. As a result, block transaction serialization and Merkle tree leaf computation rely on Transaction.toString():
return from + " -> " + to + ": " + amount;
This leaves out critical security fields: id, senderKey, and signature. An adversary or corrupted node could alter a transaction's ID, swap its public key, or tamper with its digital signature, and toString() would remain completely unchanged.
This issue proposes introducing a deterministic Transaction.hash() method that produces a SHA-256 digest covering all record fields, and updating Block.computeMerkleRoot() to use tx.hash() for leaf nodes.
Current Problem
- Location:
Transaction.java&Block.java - Behavior:
InBlock.computeMerkleRoot(), leaves are hashed as:tree.add(sha256(tx.toString())); - Vulnerability:
BecausetoString()only serializesfrom,to, andamount, changes to:id(e.g. replaying with altered transaction identifiers)senderKey(e.g. swapping public keys)signature(e.g. replacing with invalid signature bytes)
do not change the output oftx.toString(), leaving the computed Merkle root unchanged if signatures are not checked independently.
Proposed Solution
-
Add Deterministic
Transaction.hash()(Transaction.java):
Implement ahash()method that hashes all record fields deterministically using SHA-256:public String hash() { try { MessageDigest digest = MessageDigest.getInstance("SHA-256"); digest.update(id.getBytes(StandardCharsets.UTF_8)); digest.update(from.getBytes(StandardCharsets.UTF_8)); digest.update(to.getBytes(StandardCharsets.UTF_8)); digest.update(ByteBuffer.allocate(4).putInt(amount).array()); if (senderKey != null) { digest.update(senderKey.getEncoded()); } if (signature != null) { digest.update(signature); } return HexFormat.of().formatHex(digest.digest()); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException(e); } } -
Integrate with Merkle Tree Leaves (
Block.java):
UpdateBlock.computeMerkleRoot()so the leaf nodes are built directly fromtx.hash():for (Transaction tx : transactions) { tree.add(tx.hash()); } -
Unit Tests (
BlockchainTest.java):
Add unit tests verifying that changing any individual field (id,amount,senderKey, orsignature) results in a differenttx.hash().
Acceptance Criteria
-
Transaction.hash()deterministically returns a 64-character SHA-256 hex string. - Modifying
id,from,to,amount,senderKey, orsignatureproduces a different hash. -
Block.computeMerkleRoot()usestx.hash()for tree leaf nodes. - All existing tests and new unit tests pass (
mvn clean test).
- 主要言語
- Java
- スター
- 0
- フォーク
- 3
- 平均マージ
- 16時間 38分
- マージ済み PR(30日)
- 7
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
techcsispit/mini-chain のほかの issue
-
Tests: no test covers a payment of 0 or the genesis block meeting the difficulty対応中かも @tanujb03 が 6 日前に担当しました。 オープンgood first issue tests
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
techcsispit/mini-chain#23 ·
メンテナーはふだん 1 日以内に返信
-
Enhancement: Implement binary Merkle tree root in Block header対応中かも @sohanjadyal が 3 日前に担当しました。 オープンadvanced feature
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
techcsispit/mini-chain#27 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
README says changing Block or Transaction makes chain.dat stop loading, but adding a field or method still loads it対応中かも @tanujb03 が 6 日前に担当しました。 オープンdocumentation good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 25/100
techcsispit/mini-chain#21 ·
メンテナーはふだん 1 日以内に返信
-
BlockchainTest: signature tampering tests pass on the hash check; Block.mine() is a no-op so signature verification is not tested対応中かも @tanujb03 が 6 日前に担当しました。 オープンgood first issue tests
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
techcsispit/mini-chain#19 ·
メンテナーはふだん 1 日以内に返信
-
Blockchain: a payment that was already mined can be submitted again, and it is accepted and mined a second time対応中かも @tanujb03 が 6 日前に担当しました。 オープンbug good first issue
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
techcsispit/mini-chain#16 ·
メンテナーはふだん 1 日以内に返信
techcsispit/mini-chain の issue をすべて見る
似ている issue
-
StepExamBenchmarkTest runs a loop and prints a timing but asserts nothing対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンjules
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
open-learning-exchange/myplanet#18199 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
Scheme-less stream URLs throw NullPointerException instead of URISyntaxException対応中かも @blihio が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
pedroSG94/RootEncoder#2218 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
apache/rocketmq-dashboard#6872 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ADORSYS-GIS/token-status-link#168 ·
メンテナーはふだん 2 日以内に返信