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: ikc cosmos signature error #89

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion imkey-core/ikc-wallet/coin-cosmos/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use ikc_common::utility::{hex_to_bytes, secp256k1_sign, sha256_hash};
use ikc_device::device_binding::KEY_MANAGER;
use ikc_transport::message::{send_apdu, send_apdu_timeout};
use secp256k1::{self, ecdsa::Signature as SecpSignature};
use ikc_common::path::check_path_validity;

#[derive(Debug)]
pub struct CosmosTransaction {
Expand All @@ -19,6 +20,7 @@ pub struct CosmosTransaction {

impl CosmosTransaction {
pub fn sign(self) -> Result<CosmosTxOutput> {
check_path_validity(&self.path).unwrap();
let sign_hash = sha256_hash(hex_to_bytes(&self.sign_data)?.as_slice());
let mut sign_pack = "0120".to_string();
sign_pack.push_str(&sign_hash.to_hex());
Expand Down Expand Up @@ -56,7 +58,7 @@ impl CosmosTransaction {
ApduCheck::check_response(&response)?;
}

let sign_apdu = CosmosApdu::sign_digest(constants::COSMOS_PATH);
let sign_apdu = CosmosApdu::sign_digest(&self.path);

let sign_result = send_apdu(sign_apdu)?;
ApduCheck::check_response(&sign_result)?;
Expand Down