Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cast): do not strip 0x / hex decode message before EIP-191 hashing #9130

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions crates/cast/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,7 @@ async fn main_args(args: CastArgs) -> Result<()> {
}
CastSubcommand::HashMessage { message } => {
let message = stdin::unwrap_line(message)?;
let input = match message.strip_prefix("0x") {
Some(hex_str) => hex::decode(hex_str)?,
None => message.as_bytes().to_vec(),
};
let input = message.as_bytes().to_vec();
DaniPopes marked this conversation as resolved.
Show resolved Hide resolved
println!("{}", eip191_hash_message(input));
}
CastSubcommand::SigEvent { event_string } => {
Expand Down
2 changes: 1 addition & 1 deletion crates/cast/tests/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ casttest!(hash_message, |_prj, cmd| {
"#]]);

cmd.cast_fuse().args(["hash-message", "0x68656c6c6f"]).assert_success().stdout_eq(str![[r#"
0x50b2c43fd39106bafbba0da34fc430e1f91e3c96ea2acee2bc34119f92b37750
0x83a0870b6c63a71efdd3b2749ef700653d97454152c4b53fa9b102dc430c7c32

"#]]);
});
Loading