segregated witness – How can I discover the general public key akin to a P2TR enter?

0
75


From BIP341:

A Taproot output is a local SegWit output (see BIP141) with model
no 1, and a 32-byte witness program. […]

  • Let q be the 32-byte array containing the witness program (the second push within the scriptPubKey) which represents a public key
    in response to BIP340.
  • Fail if the witness stack has 0 parts.
  • If there are at the least two witness parts, and the primary byte of the final ingredient is 0x50, this final ingredient is named annex a
    and is faraway from the witness stack. The annex (or the dearth of
    thereof) is all the time lined by the signature and contributes to
    transaction weight, however is in any other case ignored throughout taproot
    validation.
  • If there may be precisely one ingredient left within the witness stack, key path spending is used:
    • The only witness stack ingredient is interpreted because the signature and should be legitimate (see the following part) for the general public key
      q (see the following subsection).
  • If there are at the least two witness parts left, script path spending is used:
    • Name the second-to-last stack ingredient s, the script.

In different phrases, Taproot key path spends solely have one1 witness merchandise, the signature. Script path spends all the time have at the least two witness objects, and often extra to offer an preliminary stack for the script execution.

Since BIP340 signatures do not permit public key restoration, you possibly can’t compute the general public key (and due to this fact tackle) from the signature alone in a key path spend. In a script path spend, you possibly can mix the revealed inside key with the foundation of the script to get the general public key.

Nonetheless, getting the output script of the output being spent is so simple as trying up the transaction output referenced by the txid and index within the enter, so there’s hardly ever a motive to make use of a way that solely works for some output scripts, and requires you to know the output kind (P2TR on this case) within the first place.


1 Assuming the annex shouldn’t be current.

LEAVE A REPLY

Please enter your comment!
Please enter your name here