-
Notifications
You must be signed in to change notification settings - Fork 130
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
Using KeyMap and DescriptorSecretKey for signing transactions #495
Comments
This is an interesting API question. I think the most common signing workflow we (the rust-minisrcipt devs) encounter involves iterating over public keys, then requesting a HWW produce a signature with those keys. To do this directly with private keys we would need an API that could produce derived secret keys .. presumably a variant of the There is also an open question about how much sighashing support or PSBT support belongs in this libarry. |
I'd be +1 on making a |
Maybe we should have a structure which paired these, and added a
Ah right! We should make a separate issue about this because I keep forgetting it (and even when I'm reminded, my first impulse is to say "but we provide the leafhash!" ... but you're talking about keyspends, not scriptspends). |
Thanks for comments. Now I understand that |
No, but maybe it should :)
What I'm saying is that I never use
Yes, the |
Okay. Thank you. I was able to use DescriptorSecretKey::XPrv(prv) => {
let extended = prv.xkey;
let private = extended.derive_priv(&self.secp, &prv.derivation_path).unwrap();
let public = private.private_key.public_key(&self.secp);
let sig = self.secp.sign_ecdsa(&msg, &private.private_key);
assert!(self.secp.verify_ecdsa(&msg, &sig, &public).is_ok());
psbt.inputs[0].partial_sigs.insert(
public.to_public_key(),
bitcoin::EcdsaSig {
sig,
hash_ty: hash_ty,
},
);
},
I understood it. This is my next step to try to export extended keys from various of hardware wallets and apps and sign transactions using descriptors with public keys. It was quite handy to me to design in-software signing because I am going to prototype something not just for signing transactions exclusively. |
From an outsider point of view
KeyMap
looks like interesting way to handle keys after importing descriptor.Let's say for example we have such descriptor where we supply
tprv
which will be imported intoKeyMap
We could use
KeyMap
later in similar loopThe problem though is that
public
andprivate
areDescriptorPublicKey
andDescriptorSecretKey
objects do not really contain convenient API even for extracting keys and using them in signing. I have a code example and honestly I am not entirely sure I didn't something wrong. Besides It doesn't actually work and I think the problem is that there is just wrong key in&prv.xkey.private_key
.The text was updated successfully, but these errors were encountered: