Skip to content

test(grey-crypto): add proptests for blake2b-256 and keccak-256#827

Open
wangzishuai1987 wants to merge 1 commit into
jarchain:masterfrom
wangzishuai1987:test/crypto-hash-proptest
Open

test(grey-crypto): add proptests for blake2b-256 and keccak-256#827
wangzishuai1987 wants to merge 1 commit into
jarchain:masterfrom
wangzishuai1987:test/crypto-hash-proptest

Conversation

@wangzishuai1987
Copy link
Copy Markdown

Summary

Adds property-based tests for the two core hash functions used throughout the JAM protocol:

blake2b-256 (H):

  • Deterministic: same input always produces the same hash
  • Output size: always exactly 32 bytes
  • Collision resistance: different inputs produce different hashes
  • Avalanche: flipping any single bit changes the output
  • Concatenation order: H(a‖b) ≠ H(b‖a) for distinct a, b
  • accumulate_entropy is deterministic and sensitive to both inputs

keccak-256 (H_K):

  • Deterministic hashing
  • Output size: always exactly 32 bytes
  • Collision resistance: different inputs produce different hashes
  • Avalanche: flipping any single bit changes the output
  • Prefix distinctness: H(a) ≠ H(a‖extra)

These properties are fundamental to the security of Merkle trees, state commitments, and signature schemes in the protocol.

Refs: #229

Add property-based tests for the two core hash functions:

blake2b-256:
- Deterministic hashing
- Output is always 32 bytes
- Different inputs produce different hashes
- Avalanche: flipping any bit changes the hash
- Concatenation order matters: H(a||b) != H(b||a)
- accumulate_entropy is deterministic and input-sensitive

keccak-256:
- Deterministic hashing
- Output is always 32 bytes
- Different inputs produce different hashes
- Avalanche: flipping any bit changes the hash
- Prefix distinctness: H(a) != H(a||extra)

Refs: jarchain#229
@github-actions
Copy link
Copy Markdown
Contributor

Genesis Review

Comparison targets:

How to review

Post a comment with the following format (rank from best to worst):

/review
difficulty: <commit1>, <commit2>, ..., <commitN>, currentPR
novelty: <commit1>, <commit2>, ..., <commitN>, currentPR
design: <commit1>, <commit2>, ..., <commitN>, currentPR
verdict: merge

Use the short commit hashes above and currentPR for this PR.
Each line ranks all comparison targets + this PR from best to worst.

To meta-review another reviewer's comment, react with 👍 or 👎.

@johandroid
Copy link
Copy Markdown
Contributor

/review
difficulty: 7dff858, 1b8b2e0, 1e8d908, 9980091, currentPR, c308bd8, b859d8f, 0bd11af
novelty: 1e8d908, 1b8b2e0, 9980091, currentPR, 7dff858, c308bd8, b859d8f, 0bd11af
design: 7dff858, 1e8d908, 1b8b2e0, 9980091, currentPR, c308bd8, b859d8f, 0bd11af
verdict: merge

Adds useful property coverage for the core Blake2b and Keccak hash wrappers, including determinism, output size, input sensitivity, and accumulate_entropy behavior. It ranks below the RPC validation fix, formal codec proof, safrole proptests, and erasure recovery properties because the assertions are mostly standard hash sanity checks rather than new protocol behavior. Merge is reasonable as focused crypto test coverage.

@github-actions
Copy link
Copy Markdown
Contributor

JAR Bot: Review recorded from @johandroid (1 reviews, 0 meta-reviews).
Merge weight: 0/37665 (need >50%).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants