Skip to content

Commit

Permalink
refactor: rename k1 to message_hash for better clarity and remove Aut…
Browse files Browse the repository at this point in the history
…hManager unused fields.
  • Loading branch information
EthanYuan committed Dec 22, 2024
1 parent 9680f7c commit db56ef4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mutiny-core/src/authmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::str::FromStr;
#[derive(Clone)]
pub struct AuthManager {
hashing_key: SecretKey,
_xprivkey: Xpriv,
context: Secp256k1<All>,
}

Expand All @@ -28,14 +27,16 @@ impl AuthManager {

Ok(Self {
hashing_key,
_xprivkey: xprivkey,
context,
})
}

pub fn sign(&self, k1: &[u8; 32]) -> Result<(ecdsa::Signature, PublicKey), MutinyError> {
pub fn sign(
&self,
message_hash: &[u8; 32],
) -> Result<(ecdsa::Signature, PublicKey), MutinyError> {
let pubkey = self.hashing_key.public_key(&self.context);
let msg = Message::from_digest_slice(k1).expect("32 bytes, guaranteed by type");
let msg = Message::from_digest_slice(message_hash).expect("32 bytes, guaranteed by type");
let sig = self.context.sign_ecdsa(&msg, &self.hashing_key);
Ok((sig, pubkey))
}
Expand Down

0 comments on commit db56ef4

Please sign in to comment.