The type returned by `Witness::taproot_control_block()` was just `&[u8]` which wasn't very nice since users then had to manually decode it which so far also required allocation. Thanks to previous improvements to `ControlBlock` it is now possible to return a `ControlBlock` type directly. To avoid expensive checks, this change adds a new type `SerializedXOnlyPublicKey` which is a wrapper around `[u8; 32]` that is used in `ControlBlock` if complete checking is undesirable. It is then used in the `ControlBlock` returned from `Witness::taproot_control_block`. Users can still conveniently validate the key using `to_validated` method. It then uses this type in the recently-added `P2TrSpend` type. As a side effect this checks more properties of `Witness` when calling unrelated methods on `Witness`. From correctness perspective this should be OK: a witness obtained from a verified source will be correct anyway and, if these checks were done by the caller, they can be removed. From performance perspective, if the `Witness` was obtained from a verified source (e.g. using Bitcoin Core RPC) these checks are wasted CPU time. But they shouldn't be too expensive, we already avoid `secp256k1` overhead and, given that they always succeed in such case, they should be easy to branch-predict. |
||
---|---|---|
.. | ||
contrib | ||
embedded | ||
examples | ||
src | ||
tests | ||
CHANGELOG.md | ||
Cargo.toml |