Problem
The Operation::hash() function in crates/jstz_proto/src/operation.rs uses Rust's {:?} debug formatting for certain types (HeaderMap, HttpBody), which includes Rust-specific type information and debug formatting. This makes it impossible for non-Rust systems or even rust systems with different versions to reproduce or verify operation hashes.
Evidence
Two unit tests have been added that prove this issue:
test_hash_includes_debug_info_problem
test_non_rust_system_hash_reproduction_challenge
Test Output
Hashed string: edpkuifh2JiPVYfEM4LuGBcPjhHR1GS88bc4ciNUqg15UcWM5zjFmn42jstz://tz1cD5CuvAALcxgypqBXcBQEA8dkLJivoFjU/testPOST{"content-type": "application/json"}HttpBody(Some([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]))
The hash includes:
- Rust struct names:
HttpBody
- Rust Option wrapper:
Some([...])
- Rust byte array representation:
[104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]
- Debug-formatted headers with quotes and colons
Code Location
The problematic code is in Operation::hash() around lines 84-91:
Content::RunFunction(RunFunction {
uri,
method,
headers,
body,
..
}) => Blake2b::from(
format!("{public_key}{nonce}{uri}{method}{headers:?}{body:?}").as_bytes(),
),
Also in OracleResponse around line 106:
format!("{}{}{}{:?}", public_key, nonce, request_id, response).as_bytes(),
Solution Needed
The hash function should use deterministic, language-agnostic serialization (e.g., canonical JSON or binary encoding) instead of Rust's debug formatting. This ensures:
- Cross-platform compatibility
- Version stability
- Proper cryptographic hash generation
Reference Branch
Tests demonstrating this issue are available in branch: fix/hash-debug-formatting-issue
cargo test -p jstz_proto operation::test -- --nocapture
Problem
The
Operation::hash()function incrates/jstz_proto/src/operation.rsuses Rust's{:?}debug formatting for certain types (HeaderMap,HttpBody), which includes Rust-specific type information and debug formatting. This makes it impossible for non-Rust systems or even rust systems with different versions to reproduce or verify operation hashes.Evidence
Two unit tests have been added that prove this issue:
test_hash_includes_debug_info_problemtest_non_rust_system_hash_reproduction_challengeTest Output
The hash includes:
HttpBodySome([...])[104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]Code Location
The problematic code is in
Operation::hash()around lines 84-91:Also in
OracleResponsearound line 106:Solution Needed
The hash function should use deterministic, language-agnostic serialization (e.g., canonical JSON or binary encoding) instead of Rust's debug formatting. This ensures:
Reference Branch
Tests demonstrating this issue are available in branch:
fix/hash-debug-formatting-issuecargo test -p jstz_proto operation::test -- --nocapture