-
Notifications
You must be signed in to change notification settings - Fork 29
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
descriptor_parse: crash with tr
descriptor
#69
Comments
With Taproot descriptors you need to set the pubkey type that you're parsing to I'm kinda curious how Core represents the thing that you're parsing here. Does it always accept 32-byte keys in all descriptors? Or does its "descriptor public key" type support 32-byte keys but there's an extra check when parsing Taproot descriptors? Or what? |
Broadly speaking, I'm open to us rethinking the relationship between x-only and old-style keys in rust-miniscript. Maybe all keys should be representable either in 33- or 32-byte form, with |
I think this is done. See: https://github.com/brunoerg/bitcoinfuzz/blob/v2/modules/rustminiscript/rust_miniscript_lib/src/lib.rs#L21
I quickly debugged it, and I noticed that "02d1d11100A0000000000000000000003509693017680d02d00008c0d00008cc" becomes "0202d1d11100A0000000000000000000003509693017680d02d00008c0d00008cc" which is valid. When the data is 32-byte and under P2TR, it puts a 0x02 at the start. } else if (data.size() == 32 && ctx == ParseScriptContext::P2TR) {
unsigned char fullkey[33] = {0x02};
std::copy(data.begin(), data.end(), fullkey + 1);
pubkey.Set(std::begin(fullkey), std::end(fullkey));
if (pubkey.IsFullyValid()) {
ret.emplace_back(std::make_unique<ConstPubkeyProvider>(key_exp_index, pubkey, true));
return ret;
}
} |
I think you're gonna fail to parse with
Hmm. I'm skeptical that we want to reproduce this behavior. What do you think @sanket1729? |
It seems Core converts x-only keys to compressed public keys for validation. |
I think we already do something similar. See the test here that checks that x-only keys are parsed correctly in tr context. Desc::from_str(&format!("tr({},pk({}))", x_only_key, x_only_key)).unwrap(); // works @apoelstra the issue is about The code can be simplified to use only If you want to also parse private keys, you can use the parse_descriptor API . Summary, the core issue here is bitcoin core accepts private key descriptors, but our |
One of the annoying thing we still have is, it hard to accurately report which Pk parsing failed that is no-std compatible. Maybe when using On master this fails with
which is incorrect, but also does not provide any info about which key failed. |
rust-bitcoin/rust-miniscript#786 . Fixing the error message, we can discuss identification of which key failed in a separate issue |
Cool, I'm gonna address it. |
Descriptor:
tr(02d1d11100A0000000000000000000003509693017680d02d00008c0d00008cc,pkh(L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1))
Bitcoin Core successfully parses it, rust-miniscript returns the following error "pubkey string should be 66 or 130 digits long, got: 64".
The text was updated successfully, but these errors were encountered: