Skip to content

Commit

Permalink
fix: Sign tx hash instead of tx env with keychain
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethengelman committed Dec 4, 2024
1 parent 4bddd24 commit a72276d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/soroban-cli/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl Signer {
let decorated_signature = match &self.kind {
SignerKind::Local(key) => key.sign_tx_hash(tx_hash)?,
SignerKind::Lab => Lab::sign_tx_env(tx_env, network, &self.print)?,
SignerKind::SecureStore(entry) => entry.sign_tx_env(tx_env)?,
SignerKind::SecureStore(entry) => entry.sign_tx_hash(tx_hash)?,
};
let mut sigs = signatures.clone().into_vec();
sigs.push(decorated_signature);
Expand Down Expand Up @@ -297,11 +297,11 @@ pub struct SecureStoreEntry {
}

impl SecureStoreEntry {
pub fn sign_tx_env(&self, tx_env: &TransactionEnvelope) -> Result<DecoratedSignature, Error> {
pub fn sign_tx_hash(&self, tx_hash: [u8; 32]) -> Result<DecoratedSignature, Error> {
let entry = StellarEntry::new(&self.name)?;
let signed_tx_env = entry.sign_data(tx_env.to_xdr_base64(Limits::none())?.as_bytes())?;
let hint = SignatureHint(entry.get_public_key()?.0[28..].try_into()?);
let signature = Signature(signed_tx_env.clone().try_into()?);
let signed_tx_hash = entry.sign_data(&tx_hash)?;
let signature = Signature(signed_tx_hash.clone().try_into()?);
Ok(DecoratedSignature { hint, signature })
}
}

0 comments on commit a72276d

Please sign in to comment.