<p>According to UniSat documentation <a href="https://docs.unisat.io/dev/unisat-developer-center/unisat-wallet#getpublickey" rel="nofollow noreferrer">here</a>, I can call <code>window.unisat.getPublicKey</code> to get the public key of the current account.</p>
<p>My address type is Taproot. After calling this function, I get a compressed public key in hex encoding (66 hex digits). I'm wondering if this is the internal key or the output key?</p>
<p>In addition, how to derive the Taproot address? I know a SegWit address is derived by concatenating the following:</p>
<ol>
<li>Human readable part. <code>bc</code> in mainnet.</li>
<li>Separator <code>1</code>.</li>
<li>Some data. Always a single bech32 digit (representing SegWit version) + some extra data.</li>
<li>Checksum or correction code.</li>
</ol>
<p>But I don't know what the 3rd part should be in the case of Taproot. I've heard it's a special form of public key, but how can I derive this from the return value of UniSat's <code>window.unisat.getPublicKey</code>?</p>

CC BY-SA 4.0
2024-08-20T08:19:34.380Z
`internal key or output key`
I think this post https://bitcoin.stackexchange.com/questions/117580/how-to-extract-the-internal-key-of-a-simple-p2tr-address, is a better answer for you.
Jack Tsia
CC BY-SA 4.0
2024-08-28T05:24:04.930Z
you get back the internal key, which can be used to generate a raw taproot address with bec32m, then you can use the default bip341 tweak of the internal key to get the tweakpubkey and bech32m it, to get the taproot addressed used by the wallets.
jaybny
<public-key><taproot><p2tr><bip350-bech32m>
UniSat's `getPublicKey` returns internal key or output key when using Taproot?
Yan
# UniSat's `getPublicKey` returns internal key or output key when using Taproot?

(Asked by: username_0 on 2024-08-20)

According to UniSat documentation [here](https://docs.unisat.io/dev/unisat-developer-center/unisat-wallet#getpublickey), I can call `window.unisat.getPublicKey` to get the public key of the current account.

My address type is Taproot. After calling this function, I get a compressed public key in hex encoding (66 hex digits). I'm wondering if this is the internal key or the output key?

In addition, how to derive the Taproot address? I know a SegWit address is derived by concatenating the following:

1. Human readable part. `bc` in mainnet.
2. Separator `1`.
3. Some data. Always a single bech32 digit (representing SegWit version) + some extra data.
4. Checksum or correction code.

But I don't know what the 3rd part should be in the case of Taproot. I've heard it's a special form of public key, but how can I derive this from the return value of UniSat's `window.unisat.getPublicKey`?

**Tags:** public-key, taproot, p2tr, bip350-bech32m

> **Comments:**
> **username_1**: `internal key or output key` I think this post https://bitcoin.stackexchange.com/questions/117580/how-to-extract-the-internal-key-of-a-simple-p2tr-address, is a better answer for you.  
> **username_2**: you get back the internal key, which can be used to generate a raw taproot address with bec32m, then you can use the default bip341 tweak of the internal key to get the tweakpubkey and bech32m it, to get the taproot addressed used by the wallets.  

---

## 0 answers

