Skip to content

Commit

Permalink
[rooch-networkgh-2381] fix the issue of verification.
Browse files Browse the repository at this point in the history
  • Loading branch information
Feliciss committed Sep 8, 2024
1 parent 47c5a51 commit 1258e62
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions crates/rooch/src/commands/account/commands/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::cli_types::{CommandAction, WalletContextOptions};
use async_trait::async_trait;
use clap::Parser;
use moveos_types::{h256::sha2_256_of, state::MoveState};
use moveos_types::state::MoveState;
use rooch_types::{
crypto::RoochSignature,
error::RoochResult,
Expand Down Expand Up @@ -37,13 +37,16 @@ impl CommandAction<Option<bool>> for VerifyCommand {
let sign_data =
SignData::new_without_tx_hash(MESSAGE_INFO_PREFIX.to_vec(), self.message.to_bytes());
let encoded_sign_data = sign_data.encode();
let message_hash = sha2_256_of(&encoded_sign_data).0.to_vec();
let _ = self.signature.into_inner().verify(&message_hash);
let verify_result = self
.signature
.into_inner()
.verify(&encoded_sign_data)
.is_ok();

if self.json {
Ok(Some(true))
Ok(Some(verify_result))
} else {
println!("Verification succeeded");
println!("Verification result: {}", verify_result);
Ok(None)
}
}
Expand Down

0 comments on commit 1258e62

Please sign in to comment.