diff --git a/crates/rooch/src/commands/account/commands/sign.rs b/crates/rooch/src/commands/account/commands/sign.rs index 7e772fdc5..fbb2a03d8 100644 --- a/crates/rooch/src/commands/account/commands/sign.rs +++ b/crates/rooch/src/commands/account/commands/sign.rs @@ -9,7 +9,6 @@ use moveos_types::state::MoveState; use rooch_key::keystore::account_keystore::AccountKeystore; use rooch_types::{ address::ParsedAddress, - crypto::Signature, error::RoochResult, framework::auth_payload::{SignData, MESSAGE_INFO, MESSAGE_INFO_PREFIX}, }; @@ -37,7 +36,7 @@ pub struct SignCommand { #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] pub struct SignAccountOutput { - pub signature: Signature, + pub signature_hash: String, pub message_hash: String, } @@ -62,14 +61,17 @@ impl CommandAction> for SignCommand { .sign_hashed(&rooch_address, &encoded_sign_data, password)?; let output = SignAccountOutput { - signature, + signature_hash: signature.encode_hex(), message_hash: encoded_sign_data.encode_hex(), }; if self.json { Ok(Some(output)) } else { - println!("Sign message succeeded with the sign output: {:?}", output); + println!( + "Sign message succeeded with the signatue hash {} and the message hash: {}", + output.signature_hash, output.message_hash + ); Ok(None) } } diff --git a/crates/rooch/src/commands/account/commands/verify.rs b/crates/rooch/src/commands/account/commands/verify.rs index 49b1f71ce..69317ca33 100644 --- a/crates/rooch/src/commands/account/commands/verify.rs +++ b/crates/rooch/src/commands/account/commands/verify.rs @@ -9,7 +9,6 @@ use fastcrypto::{ secp256k1::{Secp256k1PublicKey, Secp256k1Signature}, traits::ToFromBytes, }; -use moveos_types::state::MoveState; use rooch_types::{ crypto::{RoochSignature, Signature}, error::{RoochError, RoochResult}, @@ -20,7 +19,7 @@ use rooch_types::{ pub struct VerifyCommand { /// A signature for verify #[clap(short = 's', long)] - signature: String, + signature_hash: String, /// A hashed message to be verified #[clap(short = 'm', long)] @@ -37,7 +36,9 @@ pub struct VerifyCommand { #[async_trait] impl CommandAction> for VerifyCommand { async fn execute(self) -> RoochResult> { - let signature_bytes = self.signature.to_bytes(); + let signature_bytes = hex::decode(self.signature_hash).map_err(|e| { + RoochError::CommandArgumentError(format!("Decode hex failed: {}", e.to_string())) + })?; let signatrue = Signature::from_bytes(&signature_bytes).map_err(|e| { RoochError::CommandArgumentError(format!( "Invalid signature argument: {}", @@ -65,7 +66,7 @@ impl CommandAction> for VerifyCommand { Ok(Some(true)) } else { println!("Verification succeeded"); - Ok(Some(true)) + Ok(None) } } } diff --git a/crates/testsuite/features/cmd.feature b/crates/testsuite/features/cmd.feature index cde70c4df..ff7f7e284 100644 --- a/crates/testsuite/features/cmd.feature +++ b/crates/testsuite/features/cmd.feature @@ -88,7 +88,7 @@ Feature: Rooch CLI integration tests # account sign and verify Then cmd: "account sign -a {{$.account[-1].account0.address}} -m 'empty' --json" - Then cmd: "account verify -s {{$.account[-1].signature}} -m {{$.account[-1].message_hash}}" + Then cmd: "account verify -s {{$.account[-1].signature_hash}} -m {{$.account[-1].message_hash}}" # account balance Then cmd: "account balance"